Skip to content

Migrate Python tooling to UV and Ty#590

Open
frgfm wants to merge 14 commits into
mainfrom
codex/uv-ty-migration
Open

Migrate Python tooling to UV and Ty#590
frgfm wants to merge 14 commits into
mainfrom
codex/uv-ty-migration

Conversation

@frgfm
Copy link
Copy Markdown
Member

@frgfm frgfm commented May 12, 2026

Summary

  • Replace Poetry metadata and poetry.lock with a UV workspace and a single root uv.lock.
  • Split dependencies into UV groups for server, client, quality, tests, docs, and e2e usage.
  • Replace Mypy with Ty in local checks, CI, and client quality extras.
  • Run Docker and CI dependency installs through uv sync/uv run instead of Poetry exports.

Main choices

  • Kept the backend as a non-package application with tool.uv.package = false; pyroclient remains the only publishable package and is included as a workspace member.
  • Put backend runtime dependencies in a server dependency group rather than root project.dependencies, so Docker/CI can install exact slices from the lockfile.
  • Added a dependency sync checker that tracks UV/Ruff/Ty/Prek versions across pyproject, Dockerfiles, and workflows.
  • Preserved missing-import tolerance by configuring Ty with unresolved-import = "warn", then fixed or locally suppressed migration-specific diagnostics.
  • Updated the backend test AsyncClient fixture to use ASGITransport(app=...), matching current HTTPX syntax.
  • Made client tests use the dev compose superadmin credentials explicitly, so CI job env does not break auth against docker-compose.dev.yml.
  • Added client auth setup assertions so future login failures show status/body instead of KeyError: access_token.
  • Made the migration check upgrade to head before testing the downgrade/upgrade cycle.

Validation

  • make venv
  • uv lock --check
  • uv sync --locked --all-groups --all-packages --no-install-project
  • make quality
  • make test (481 passed)
  • make test-client (14 passed)
  • Exact client CI sequence with dummy env present and command-level superadmin override (14 passed)
  • Bad client credentials now fail as AssertionError: {"detail":"Invalid credentials."}, not KeyError: access_token
  • Migration check command from .github/workflows/backend.yml completed with --- Migration cycle successful ---
  • make docs-client
  • make e2e
  • Docker smoke: docker compose -f docker-compose.dev.yml up -d --build --wait plus backend /status check
  • YAML parse check for workflows, Dependabot, and pre-commit config
  • docker compose -f docker-compose.dev.yml config --quiet

Deliberately excluded

  • AGENTS.md
  • CLAUDE.md
  • docker/minio/setup-s3.sh
  • unrelated untracked workflows not needed for this migration

@frgfm frgfm added the type: improvement New feature or request label May 12, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.90%. Comparing base (dca6654) to head (00557f2).

Files with missing lines Patch % Lines
src/app/main.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #590      +/-   ##
==========================================
- Coverage   89.92%   89.90%   -0.03%     
==========================================
  Files          55       55              
  Lines        2451     2456       +5     
==========================================
+ Hits         2204     2208       +4     
- Misses        247      248       +1     
Flag Coverage Δ
backend ?
client ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@frgfm frgfm marked this pull request as ready for review May 12, 2026 22:06
@MateoLostanlen
Copy link
Copy Markdown
Member

Hello @frgfm ,

Thanks for this PR.

I was planning to switch from Poetry to uv, so this is perfect, thank you.

I really like the idea of moving to Ty, and the Astral team is doing great work. Do you have any concerns about the project still being relatively young?

Could you also explain the idea behind this new backend CI workflow, and why not reuse the existing ones?

@frgfm
Copy link
Copy Markdown
Member Author

frgfm commented May 13, 2026

I really like the idea of moving to Ty, and the Astral team is doing great work. Do you have any concerns about the project still being relatively young?

None at all, I had the same concerns a while back and since I migrated all my other projects, I feel like Ty is way more mature and serious than mypy (performance wise but also quality wise, remember all those mypy ignore). The nice part is that it's so fast, you can use it as a language server and pre commit hook (if you had done that with mypy, you would be waiting 30sec every time)

Could you also explain the idea behind this new backend CI workflow, and why not reuse the existing ones?

Yup I need to clear up some CI job redundancies actually!

@frgfm frgfm self-assigned this May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants