Skip to content

👷 Add ty to precommit#15091

Merged
tiangolo merged 34 commits intofastapi:masterfrom
svlandeg:feat/ty
Mar 15, 2026
Merged

👷 Add ty to precommit#15091
tiangolo merged 34 commits intofastapi:masterfrom
svlandeg:feat/ty

Conversation

@svlandeg
Copy link
Copy Markdown
Member

@svlandeg svlandeg commented Mar 10, 2026

  • Add ty to pyproject, precommit and lint script
  • mypy is also kept for now
  • Update code to pass ty
    • 150 original issues
    • bulk of those were issues with ty complaining about _Unset default assignments
    • quite some where ty sees no issue though mypy does: these need an extra ignore on the same line - ugly but we can remove these when we remove mypy alltogether
    • then there are a handful where ty sees a problem that mypy thinks is fine, here we add ty: ignore statements that are ignored by mypy.

[UPDATE]: note that ignored deprecation warnings are handled more properly in cf #15101 🙂

@svlandeg svlandeg self-assigned this Mar 10, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 10, 2026

Merging this PR will not alter performance

✅ 20 untouched benchmarks


Comparing svlandeg:feat/ty (11a0f1b) with master (4b82602)1

Open in CodSpeed

Footnotes

  1. No successful run was found on master (04b279f) during the generation of this report, so 4b82602 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 10, 2026

Comment thread fastapi/security/http.py
self.model: HTTPBaseModel = HTTPBaseModel(
scheme=scheme, description=description
)
self.model = HTTPBaseModel(scheme=scheme, description=description)
Copy link
Copy Markdown
Member Author

@svlandeg svlandeg Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here (and in a few similar cases), I've moved the typing to the var on the class, assuming that it wouldn't get a different type at any time. By moving the typing in this way, type checkers can more easily deduce the correct type of class vars.

@svlandeg svlandeg marked this pull request as ready for review March 11, 2026 11:23
@svlandeg svlandeg requested a review from YuriiMotov March 11, 2026 11:23
@svlandeg svlandeg removed their assignment Mar 11, 2026
Copy link
Copy Markdown
Member

@YuriiMotov YuriiMotov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in general!

Added several suggestions in review comments. Can help with the implementation if needed)
@svlandeg, what do you think?

Comment thread fastapi/_compat/v2.py
Comment thread fastapi/encoders.py
Comment thread fastapi/param_functions.py Outdated
Comment thread fastapi/routing.py Outdated
Comment thread fastapi/dependencies/utils.py
Comment thread fastapi/dependencies/utils.py Outdated
Comment thread fastapi/openapi/utils.py Outdated
Comment thread fastapi/applications.py Outdated
Comment thread fastapi/routing.py Outdated
@svlandeg svlandeg self-assigned this Mar 11, 2026
svlandeg and others added 2 commits March 12, 2026 21:26
Co-authored-by: Motov Yurii <[email protected]>
@svlandeg
Copy link
Copy Markdown
Member Author

Thanks so much for the thorough review @YuriiMotov! I've addressed all comments in detail, let me know if there's any other concerns!

@svlandeg svlandeg marked this pull request as ready for review March 13, 2026 15:34
@svlandeg svlandeg removed their assignment Mar 13, 2026
@svlandeg svlandeg requested a review from YuriiMotov March 13, 2026 15:35
Copy link
Copy Markdown
Member

@tiangolo tiangolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome, thank you @svlandeg ! 🙌

And thanks @YuriiMotov for the thorough review too!

@tiangolo tiangolo merged commit 98b269b into fastapi:master Mar 15, 2026
38 checks passed
@svlandeg svlandeg deleted the feat/ty branch March 16, 2026 07:39
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.

3 participants