-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[ty] Remove ClassBase::TypedDict
#22346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
d01f09c to
d60935b
Compare
|
|
The |
It's probably an issue due to typeshed telling us that Other type checkers do seem to issue these violations less frequently than ty (and we should look into why), but ultimately there's not much to be done about these. Typeshed has to pretend that I'm actually more concerned about the autosplit diagnostic. I don't think overriding |
|
Will look into it! |
|
@oconnor663 is part-way through astral-sh/ty#2277 so I'll just wait for that then rebase. |
|
For the generic issue... would it make sense to add something like the following to if remaining_bases.contains(&Type::SpecialForm(SpecialFormType::TypedDict)) {
return; // dict (from TypedDict) will bring in Generic
} |
|
I don't think so -- that doesn't look like it's what the runtime does? The issue is that if >>> from typing import Generic, TypeVar
>>> K = TypeVar("K")
>>> V = TypeVar("V")
>>> class dict(Generic[K, V]): ...
...
>>> BoolOrNoneT = TypeVar('BoolOrNoneT', bound=bool|None)
>>> class TypedDict(dict): ...
...
>>> class _BasePermissionsKwargs(Generic[BoolOrNoneT], TypedDict): ...
...
Traceback (most recent call last):
File "<python-input-6>", line 1, in <module>
class _BasePermissionsKwargs(Generic[BoolOrNoneT], TypedDict): ...
TypeError: Cannot create a consistent method resolution order (MRO) for bases Generic, TypedDict |
|
d60935b to
1886c7f
Compare
CodSpeed Performance ReportMerging #22346 will not alter performanceComparing Summary
Footnotes
|
1886c7f to
43892b1
Compare
43892b1 to
44a938a
Compare
Summary
This is likely present for a reason that I don't understand, but this removes some special-casing, better models runtime behavior (
dictin the MRO), and enables proper override checking. For reasons that (unfortunately) won't be clear in this PR, I believe this will also make functional TypedDict support a little simpler, since we can avoid extra TypedDict special-cases inClassMemberResultandInstanceMemberResult.