Skip to content

chore: add uv workspace and replace black with ruff#1718

Open
korbonits wants to merge 1 commit intomicrosoft:mainfrom
korbonits:chore/uv-ruff
Open

chore: add uv workspace and replace black with ruff#1718
korbonits wants to merge 1 commit intomicrosoft:mainfrom
korbonits:chore/uv-ruff

Conversation

@korbonits
Copy link
Copy Markdown

Summary

  • uv workspace: adds a root pyproject.toml declaring all four packages (markitdown, markitdown-mcp, markitdown-ocr, markitdown-sample-plugin) as workspace members, with [tool.uv.sources] wiring inter-package deps to the workspace instead of PyPI. Generates uv.lock for reproducible installs.
  • ruff replaces black: swaps psf/black (pinned at 23.7.0) in .pre-commit-config.yaml for astral-sh/ruff-pre-commit, covering both lint (ruff check --fix) and formatting (ruff format). Ruff is ~10-100× faster and handles both roles in one tool.
  • CI modernised: both tests.yml and pre-commit.yml use astral-sh/setup-uv instead of actions/setup-python + pipx install hatch; test job gains a proper matrix over Python 3.10–3.12.
  • Lint clean-up: 208 issues auto-fixed; 49 manually resolved across the codebase (SIM/B/C/F/UP rules — see commit message for full breakdown). ruff check and ruff format --check both pass with zero errors.

Test plan

  • uv sync --all-packages installs the full workspace cleanly
  • uv run ruff check packages/ → 0 errors
  • uv run ruff format packages/ --check → 0 files would change
  • uvx pre-commit run --all-files passes
  • Existing tests still pass: uv run pytest packages/markitdown/tests

🤖 Generated with Claude Code

- Add root pyproject.toml with uv workspace covering all four packages
- Add [tool.uv.sources] to markitdown-mcp, markitdown-ocr, and
  markitdown-sample-plugin so they resolve markitdown from the workspace
- Replace psf/black pre-commit hook with astral-sh/ruff-pre-commit
  (ruff lint + ruff format)
- Update CI workflows: drop hatch/setup-python in favour of
  astral-sh/setup-uv and uv run; add matrix strategy for 3.10-3.12
- Add ruff config to root pyproject.toml (E/W/F/I/UP/B/C4/SIM rules)
- Run ruff --fix + ruff format across all packages (208 auto-fixes,
  22 files reformatted)
- Manually fix all 49 remaining lint errors:
  - SIM103: collapse redundant if/return True/return False → return expr
  - SIM102: merge nested if statements
  - SIM105: try/except/pass → contextlib.suppress()
  - SIM108: if/else block → ternary
  - SIM113: manual index counters → enumerate()
  - SIM118: dict.keys() iteration → direct dict iteration
  - SIM210/211: True if x else False → bool(x) / not x
  - B006: mutable default argument in DocumentIntelligenceConverter
  - B007: unused loop vars renamed to _
  - B023: loop-variable capture in nested def fixed via default arg
  - B028: add stacklevel= to all warnings.warn() calls
  - B905: add strict=False to zip() calls
  - C408/C416: dict()/list() literals and unnecessary comprehensions
  - F601: remove duplicate "\u2192" key from latex_dict.py
  - UP031: % formatting → f-strings

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alex Korbonits <alex@korbonits.com>
@korbonits
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant