[ty] Add diagnostics for __init_subclass__ argument mismatch#22185
[ty] Add diagnostics for __init_subclass__ argument mismatch#22185AlexWaygood merged 2 commits intoastral-sh:mainfrom
__init_subclass__ argument mismatch#22185Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
| } | ||
|
|
||
| // (6) If the class is generic, verify that its generic context does not violate any of | ||
| // (6) Check that the class arguments matches the arguments of the |
There was a problem hiding this comment.
It's not very satisfying how big the check_class_definitions function is becoming, but refactors aside I think this is probably a reasonable place to add these checks? This is not really a part of the code base I've been modifying before though so I could be wrong :)
|
Thank you for your work on this feature. Almost the entire team was out last week and is out this week. It may take a few days before someone finds time to review your PR. Happy holidays. |
Absolutely no worries, we all need a well-deserved break :) Happy holidays to all of you! |
aa2acc3 to
98830bd
Compare
Add diagnostics when class definitions pass invalid arguments for a base class `__init_subclass__`.
98830bd to
47f9096
Compare
AlexWaygood
left a comment
There was a problem hiding this comment.
Thank you!
I wish we could make the diagnostics here a bit friendlier. Some users may not be aware of how the semantics of __init_subclass__ work, and the diagnostic doesn't try to explain it much at the moment:
But propagating context into (or out of) binding.report_diagnostics() in order to add subdiagnostics looks really complicated
I opened astral-sh/ty#2482 to track this |
|
(cc. @charliermarsh -- we discussed this PR a bit in #22291. It's now landed!) |
Summary
Add diagnostics when class definitions pass invalid arguments for a base class
__init_subclass__.Fixes astral-sh/ty#1541
Test Plan
New tests