Skip to content

feat(lint): replace mypy with ty type checker#1038

Open
Tranquility2 wants to merge 2 commits into
mainfrom
feat/replace-mypy-with-ty
Open

feat(lint): replace mypy with ty type checker#1038
Tranquility2 wants to merge 2 commits into
mainfrom
feat/replace-mypy-with-ty

Conversation

@Tranquility2
Copy link
Copy Markdown
Contributor

Closes #1001

Swaps mypy for Astral's ty as the project's static type checker.
ty is ~20x faster on this codebase (0.25s vs 4.9s locally) and provides clearer diagnostics.

Tooling changes

  • pyproject.toml: drop mypy>=1 and types-paramiko>=4 from the lint dep group, add ty.
    Replace the [tool.mypy] block + [[tool.mypy.overrides]] entries with [tool.ty.*] blocks.
    unresolved-import and possibly-missing-submodule are set to ignore to preserve the previous ignore_missing_imports behavior for docker / wrapt / requests / registry.
  • Makefile: replace mypy-core / mypy-core-report with ty-core.
  • .pre-commit-config.yaml: swap the local mypy hook for a local ty hook.
  • .github/workflows/ci-lint.yml: run make ty-core.
  • scripts/mypy_report.py: removed (no longer needed; ty's own output is concise).
  • README.md: add ty badge.

Code fixes for diagnostics surfaced by ty

  • container._transfer_into_container: default mode=0o644 to match with_copy_into_container.
  • container.get_wrapped_container / image.get_wrapped_image: annotate return as Optional[...] (they can be None before start()).
  • wait_strategies._get_status_tc_container: raise ContainerStartException when the container is not started instead of dereferencing None.
  • waiting_utils: use getattr(self.func, "__name__", repr(self.func)) for safer error messages.
  • Targeted # ty: ignore[...] for the hasattr-guarded add_note, the Protocol-narrowed container.exec call, the kwargs unpack into docker-py, and the wrapt decorator cast.

Verification

  • uv run ty check core/testcontainersAll checks passed!
  • make ty-core → passes
  • uv run pytest -q core/tests → 121 passed

@Tranquility2 Tranquility2 self-assigned this Jun 5, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.21%. Comparing base (be4c857) to head (9a19a67).

Files with missing lines Patch % Lines
core/testcontainers/core/wait_strategies.py 25.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1038      +/-   ##
==========================================
- Coverage   83.29%   83.21%   -0.09%     
==========================================
  Files          16       16              
  Lines        1754     1757       +3     
  Branches      193      194       +1     
==========================================
+ Hits         1461     1462       +1     
- Misses        236      237       +1     
- Partials       57       58       +1     

☔ View full report in Codecov by Harness.
📢 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.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Utilizing Ty astype checker (replacing mypy)

1 participant