-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix various inheritances #3968
Comments
Would it make sense to add an option to disable these checks, so we could disable them in CI for now? |
Here's the results I get from running @hauntsaninja's branch on the stdlib in 2022. Several have been fixed, but there's also a few new ones:
|
It matches the protocol, but it's not an explicit subclass. As far as I can see, it seems okay to just remove that. related to python#3968
related to #3968 Co-authored-by: Stephen Morton <git@tungol.org>
…nixStreamServer related to python#3968
…mServer related to python#3968
related to python#3968
related to #3968 Co-authored-by: Stephen Morton <git@tungol.org>
This is an updated version of python#11187 In addition to shuffling defintions between files, these things got tweaked: - Removed several redundant definitions of __enter__. These seem to be an artifact of using TypeVar instead of Self originally - seek and truncate have inconsistent variable names. They're also positional only, so they were in the stubtest allowlist before, but I went ahead and made them explicit in the stubs - BytesIO.readlines shouldn't have been on the allowlist in the first place. It differs not only in variable name, but also default value. - A big block of functions in TextIOWrapper were commented that mypy needed them, but I don't think it does anymore, unless there's a problem with subclassing TextIOWrapper that doesn't show up in typeshed itself. No indication in the history about that. - In the implementation, the concrete classes inherit from the private implementation _*IOBase classes, not the classes in io which are actually metaclasses, but they are registered to those metaclasses at runtime. It wasn't technically required for any reason, but I split the difference on this by keeping the _*IOBase classes in their base classes directly. I think it's a bit of a reminder of the actual implementation, and means that a stubtest check for inheritance will show that typeshed is adding to the base classes, rather than replacing the base class, and I think that's a little cleaner. Partially related to python#3968
They call themselves "decimal.*" at runtime, so move them into decimal.pyi so typshed's name matches. related to python#3968
They call themselves "decimal.*" at runtime, so move them into decimal.pyi so typshed's name matches. related to #3968
Improves the MRO of ExitStack and AsyncExitStack related to python#3968
Improves the MRO of ExitStack and AsyncExitStack related to #3968
This version keeps it simple and clean: No changes to class bodies. The only changes here are moving between files and updating the naming and inheritance. Related to python#3968 and split from python#12740.
improves naming and inheritance for asyncio.Future and asyncio.Task related to python#3968
improves naming and inheritance for asyncio.Future and asyncio.Task related to #3968
Methods are passed through at runtime via __getattr__ related to python#3968
Methods are passed through at runtime via __getattr__ related to python#3968
This MR breaks out _frozen_importlib_external (which is the same thing as importlib._bootstrap_external) and _frozen_importlib (which is the same thing as importlib._bootstrap). related to python#3968
This MR breaks out _frozen_importlib_external (which is the same thing as importlib._bootstrap_external) and _frozen_importlib (which is the same thing as importlib._bootstrap). related to python#3968
This is getting very close to done now. With the original version of the check run on 3.12 on my macbook, here's what's still left, most of which is unfixable:
These are dynamic at runtime, depending on endianness. No way to accurately represent that in typeshed.
This one is piggy-backing on special casing of builtins.property, and I believe requires additional
This one shows up in the check, but it's just invalid.
On this one,
This one is waiting for PEP 661. We'll see what's possible if/when that becomes available.
At runtime,
These three are fixable, and #12775 fixes them. On 3.9 and lower, there's a few more:
I suspect this could be fixed, but I haven't paid it very much attention since it's both 3.9- only and
These showed up when I ran the check on 3.9 just now, but I don't remember them being there before.
Not fixable; These are artifacts of the fact that classes in
Finally this pair are 3.8 and lower only, which means they're going away soon I believe? I actually haven't run it on 3.13 yet, so let's do that now. 3.13 adds:
And that's everything! I've been working with various stricter versions of the inheritance check |
I had a patch to stubtest that added checking of base classes. Unfortunately, it was too noisy to consider merging, although some fixes did come out of it.
I complicated the patch today, and most of the following look actionable. Figured I'd jot the output down here, so it doesn't get forgotten about, since I'm not sure I want to merge this newly complicated patch (branch at https://github.com/hauntsaninja/mypy/tree/stubtestbaseclass). I'll chip away at these, but if someone reading this is looking to contribute to typeshed, this is a good place to start!
The text was updated successfully, but these errors were encountered: