Add ty phase 1 migration for the login flow#4709
Draft
Conversation
5ab95aa to
959eafa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This starts Phase 1 of the mypy-to-ty migration for the login/auth slice.
tyto the dev toolchain and configure the initial Phase 1 ty settings inpyproject.tomlsrc/zenml/login/**andsrc/zenml/cli/login.pythroughtyinscripts/lint.shwhile keepingmypyon the rest of the repotyto pass without changing runtime behaviorSingletonMetaClassso singleton-backed constructors preserve their concrete instance types without noisy call-site castsWhy this change
ZenML's type checking is currently mypy-centric. The migration plan in
design/ty_migration/gpt-5-4-plan.mdrecommends proving the workflow on a small slice first before expanding coverage.The login/auth path is a good first target because it has enough real typing complexity to exercise the migration pattern, but keeps the blast radius small.
Implementation details
ty==0.0.29in the dev dependencies and add conservative Phase 1 ty configfollow_imports = "skip"so the checker split remains non-overlappingscripts/lint.shto runtyon the migrated slice andmypyon the remaining treeSingletonMetaClass.__call__/_clear/_instancegenerically soZenMLProClient(...),LocalServerDeployer(...), andCredentialsStore()retain their concrete types under tyCredentialsStore.clear_token()so it only preserves entries that have a real fallback credential pathImpact
This is internal tooling work. It does not change the public CLI surface, but it establishes the first reusable ty migration boundary and keeps the login/auth slice clean under
ty.Validation
uv run ty check src/zenml/utils/singleton.py src/zenml/login src/zenml/cli/login.pyuv run --extra dev --extra local pytest tests/integration/functional/cli/test_cli.py::test_connect_to_server_sets_project_after_success tests/integration/functional/cli/test_cli.py::test_connect_to_server_does_not_set_project_on_failureNotes
A full local
scripts/lint.shrun still fails outside this slice in this environment because repo-wide mypy reaches unrelated FastAPI/SQLAlchemy/integration modules whose dependencies are not installed here.