[ty] Emit diagnostic when a type variable with a default is followed by one without a default#21787
Conversation
de829b0 to
4133dde
Compare
Diagnostic diff on typing conformance testsChanges were detected when running ty on typing conformance tests--- old-output.txt 2025-12-14 19:31:44.194785139 +0000
+++ new-output.txt 2025-12-14 19:31:47.826806321 +0000
@@ -439,6 +439,7 @@
generics_basic.py:171:1: error[invalid-generic-class] `Generic` base class must include all type variables used in other base classes
generics_basic.py:172:1: error[invalid-generic-class] `Generic` base class must include all type variables used in other base classes
generics_basic.py:199:5: error[type-assertion-failure] Type `Iterator[Any]` does not match asserted type `Unknown`
+generics_defaults.py:24:40: error[invalid-generic-class] Type parameter `T` without a default cannot follow earlier parameter `DefaultStrT` with a default
generics_defaults.py:30:1: error[type-assertion-failure] Type `type[NoNonDefaults[str, int]]` does not match asserted type `<class 'NoNonDefaults'>`
generics_defaults.py:31:1: error[type-assertion-failure] Type `type[NoNonDefaults[str, int]]` does not match asserted type `<class 'NoNonDefaults[str, int]'>`
generics_defaults.py:32:1: error[type-assertion-failure] Type `type[NoNonDefaults[str, int]]` does not match asserted type `<class 'NoNonDefaults[str, int]'>`
@@ -1025,4 +1026,4 @@
typeddicts_usage.py:28:17: error[missing-typed-dict-key] Missing required key 'name' in TypedDict `Movie` constructor
typeddicts_usage.py:28:18: error[invalid-key] Unknown key "title" for TypedDict `Movie`: Unknown key "title"
typeddicts_usage.py:40:24: error[invalid-type-form] The special form `typing.TypedDict` is not allowed in type expressions
-Found 1027 diagnostics
+Found 1028 diagnostics
|
|
|
Thanks for the PR! This is emitting two new diagnostics on the conformance suite. The one in The one at https://github.com/python/typing/blob/main/conformance/tests/generics_defaults_specialization.py#L42 looks wrong -- there should not be any diagnostic there, and the one we emit is clearly not right, since it references I haven't looked at the code here yet, but it looks like in that subclassing scenario we are checking the wrong set of type variables somehow. There are a lot of new diagnostics in the ecosystem here. I would recommend first fixing the above issue, and then seeing if the ecosystem impact is reduced. |
Thank you for the pointers! , I have updated the approach & added the new test as well. |
855552a to
9a83524
Compare
Signed-off-by: 11happy <bhuminjaysoni@gmail.com>
Signed-off-by: 11happy <bhuminjaysoni@gmail.com>
Signed-off-by: 11happy <bhuminjaysoni@gmail.com>
Signed-off-by: 11happy <bhuminjaysoni@gmail.com>
Signed-off-by: 11happy <bhuminjaysoni@gmail.com>
Signed-off-by: 11happy <bhuminjaysoni@gmail.com>
Signed-off-by: 11happy <bhuminjaysoni@gmail.com>
Signed-off-by: 11happy <bhuminjaysoni@gmail.com>
Signed-off-by: 11happy <bhuminjaysoni@gmail.com>
9c9709c to
723b514
Compare
|
ping! have resolved the merged conflict |
Signed-off-by: 11happy <soni5happy@gmail.com>
CodSpeed Performance ReportMerging #21787 will degrade performances by 5.02%Comparing Summary
Benchmarks breakdown
Footnotes
|
* origin/main: Update MSRV to 1.90 (#21987) [ty] Improve check enforcing that an overloaded function must have an implementation (#21978) Update actions/checkout digest to 8e8c483 (#21982) [ty] Use `ParamSpec` without the attr for inferable check (#21934) [ty] Emit diagnostic when a type variable with a default is followed by one without a default (#21787) [ty] Fix callout syntax in configuration mkdocs (#1875) (#21961) Update debug_assert which pointed at missing method (#21969) [ty] Add support for `__qualname__` and other implicit class attributes (#21966)
* origin/main: Fluent formatting of method chains (#21369) [ty] Avoid stack overflow when calculating inferable typevars (#21971) [ty] Add "qualify ..." code fix for undefined references (#21968) [ty] Use jemalloc on linux (#21975) Update MSRV to 1.90 (#21987) [ty] Improve check enforcing that an overloaded function must have an implementation (#21978) Update actions/checkout digest to 8e8c483 (#21982) [ty] Use `ParamSpec` without the attr for inferable check (#21934) [ty] Emit diagnostic when a type variable with a default is followed by one without a default (#21787)
Summary
This PR fixes astral-sh/ty#1651
Test Plan
I have added mdtest