Skip to content

Add ty phase 1 migration for the login flow#4709

Draft
strickvl wants to merge 1 commit intodevelopfrom
feat/ty-migration-part-1
Draft

Add ty phase 1 migration for the login flow#4709
strickvl wants to merge 1 commit intodevelopfrom
feat/ty-migration-part-1

Conversation

@strickvl
Copy link
Copy Markdown
Contributor

@strickvl strickvl commented Apr 9, 2026

Summary

This starts Phase 1 of the mypy-to-ty migration for the login/auth slice.

  • add ty to the dev toolchain and configure the initial Phase 1 ty settings in pyproject.toml
  • route src/zenml/login/** and src/zenml/cli/login.py through ty in scripts/lint.sh while keeping mypy on the rest of the repo
  • apply the small login-slice type fixes needed for ty to pass without changing runtime behavior
  • type SingletonMetaClass so singleton-backed constructors preserve their concrete instance types without noisy call-site casts

Why this change

ZenML's type checking is currently mypy-centric. The migration plan in design/ty_migration/gpt-5-4-plan.md recommends 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

  • pin ty==0.0.29 in the dev dependencies and add conservative Phase 1 ty config
  • make mypy skip the migrated modules via follow_imports = "skip" so the checker split remains non-overlapping
  • update scripts/lint.sh to run ty on the migrated slice and mypy on the remaining tree
  • fix ty diagnostics caused by response status code narrowing and Pro server URL handling
  • type SingletonMetaClass.__call__ / _clear / _instance generically so ZenMLProClient(...), LocalServerDeployer(...), and CredentialsStore() retain their concrete types under ty
  • tighten CredentialsStore.clear_token() so it only preserves entries that have a real fallback credential path

Impact

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.py
  • uv 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_failure

Notes

A full local scripts/lint.sh run still fails outside this slice in this environment because repo-wide mypy reaches unrelated FastAPI/SQLAlchemy/integration modules whose dependencies are not installed here.

@strickvl strickvl added the no-release-notes Release notes will NOT be attached and used publicly for this PR. label Apr 9, 2026
@github-actions github-actions Bot added the internal To filter out internal PRs and issues label Apr 9, 2026
@strickvl strickvl force-pushed the feat/ty-migration-part-1 branch from 5ab95aa to 959eafa Compare April 9, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal To filter out internal PRs and issues no-release-notes Release notes will NOT be attached and used publicly for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant