Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ty] Add missing-type-argument lint rule#25617

Merged
JelleZijlstra merged 9 commits into
astral-sh:mainfrom
reginaldl:feature/missing-type-argument
Jun 5, 2026
Merged

[ty] Add missing-type-argument lint rule#25617
JelleZijlstra merged 9 commits into
astral-sh:mainfrom
reginaldl:feature/missing-type-argument

Conversation

@reginaldl

Copy link
Copy Markdown
Contributor

Summary

Add a new lint that detects generic types used without explicit type parameters in annotations (e.g. list instead of list[int]).
This is equivalent to mypy's --disallow-any-generics and pyright's reportMissingTypeArgument.

Can be enabled via:

    [rules]
    missing-type-argument = "warn"

It skips classes where all type parameters have PEP 696 defaults.

This should fix the following issue in ty:

Test Plan

Added tests covering stdlib generics, user-defined generics, PEP 696 defaults, dotted names, function signatures, and variable annotations.

Add a new lint that detects generic types used without explicit type
parameters in annotations (e.g. `list` instead of `list[int]`).
This is equivalent to mypy's `--disallow-any-generics` and pyright's
`reportMissingTypeArgument`.

The rule defaults to `Level::Ignore` (opt-in) and can be enabled via:

    [rules]
    missing-type-argument = "warn"

It skips classes where all type parameters have PEP 696 defaults.
Added tests covering stdlib generics, user-defined generics, PEP 696
defaults, dotted names, function signatures, and variable annotations.
@astral-sh-bot astral-sh-bot Bot added the ty Multi-file analysis & type inference label Jun 3, 2026
Comment thread crates/ty_test/src/db.rs Outdated
Comment thread crates/ty_python_semantic/resources/mdtest/diagnostics/missing_type_argument.md Outdated
@reginaldl reginaldl requested a review from jelle-openai June 4, 2026 00:28
@astral-sh-bot

astral-sh-bot Bot commented Jun 4, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 92.16%. The percentage of expected errors that received a diagnostic held steady at 87.31%. The number of fully passing files held steady at 92/134.

@astral-sh-bot

astral-sh-bot Bot commented Jun 4, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot

astral-sh-bot Bot commented Jun 4, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.

Full report with detailed diff (timing results)

Comment thread crates/ty_python_semantic/resources/mdtest/diagnostics/missing_type_argument.md Outdated
Comment thread crates/ty_python_semantic/src/types/infer/builder/type_expression.rs Outdated
@reginaldl reginaldl requested a review from JelleZijlstra June 4, 2026 21:37
Comment thread crates/ty_python_semantic/resources/mdtest/expression/yield_and_yield_from.md Outdated
Comment thread crates/ty_python_semantic/resources/mdtest/function/return_type.md Outdated
Comment thread crates/ty_python_semantic/resources/mdtest/generics/pep695/functions.md Outdated
Comment thread crates/ty_python_semantic/src/types/diagnostic.rs Outdated

@JelleZijlstra JelleZijlstra left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you! I pushed a few followups. I'll wait for CI to run and if everything looks good I'll merge this.

@reginaldl

Copy link
Copy Markdown
Contributor Author

Thank you! I pushed a few followups. I'll wait for CI to run and if everything looks good I'll merge this.

I wondered why I was getting conflicts trying to address feedback 😂
Thank you! Let me know if this needs further updates.

@JelleZijlstra

Copy link
Copy Markdown
Collaborator

Sorry for that! I think it's pretty much ready now, I had to fix up a few more CI issues.

@JelleZijlstra JelleZijlstra merged commit dc79edf into astral-sh:main Jun 5, 2026
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants