-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
Convert importlib.abc to use typing.Protocol #82963
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
Comments
Now that typing.Protocol exists we should convert the ABCs in importlib over to protocols as the import system functions off of structural typing and not nominal typing. |
Protocols are a better conceptual fit for these classes, but wouldn't this change break backwards compatibility? For example, protocols don't support |
Probably, which is why I figured the protocols would be separate since the ABCs also have default implementations that the protocols wouldn't have (I just forgot to update the issue with my latest thinking 😅). I had not decided if they should be in a separate module or just stick them in |
Yes, IIRC protocols a supposed to be "drop in" replacement for ABCs, in particular cpython/Lib/test/test_typing.py Line 3765 in f00512d
.register() well (or at all).
|
It would just be for the legacy ABC support. My expectation is the current ABCs will inherit from the protocols, but that most code will type to the protocols themselves and the type checkers will rely on that. But I would still have to either leave the abstract methods that are already there on the ABCs or use Since I have not written it down, the protocols/types will be for:
|
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: