Skip to content
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 several mypy errors when run on the 3.11 stdlib #7389

Merged
merged 2 commits into from
Feb 27, 2022

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Feb 26, 2022

If you apply @hauntsaninja's patch to mypy_test.py in python/mypy#12220, here is the output when running python tests/mypy_test.py -p3.11 on the master branch (using Python 3.10, mypy 0.931):

stdlib\typing.pyi:1166: error: Variable "typing.Never" is not valid as a type  [valid-type]
stdlib\typing.pyi:1166: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
stdlib\builtins.pyi:1713: error: Value of type "Type[type]" is not indexable  [index]
stdlib\builtins.pyi:1721: error: Variable "builtins._SplitCondition" is not valid as a type  [valid-type]
stdlib\builtins.pyi:1721: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
stdlib\builtins.pyi:1722: error: Variable "builtins._SplitCondition" is not valid as a type  [valid-type]
stdlib\builtins.pyi:1722: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
stdlib\enum.pyi:141: error: Decorated property not supported  [misc]
stdlib\enum.pyi:143: error: Decorated property not supported  [misc]
stdlib\enum.pyi:172: error: Decorated property not supported  [misc]
stdlib\enum.pyi:192: error: Signature of "value" incompatible with supertype "Flag"  [override]
stdlib\enum.pyi:203: error: Decorated property not supported  [misc]
stdlib\enum.pyi:205: error: Decorated property not supported  [misc]
stdlib\enum.pyi:233: error: Decorated property not supported  [misc]
stdlib\enum.pyi:236: error: Cannot inherit from final class "StrEnum"  [misc]
stdlib\enum.pyi:248: error: Cannot inherit from final class "StrEnum"  [misc]
stdlib\asyncio\base_events.pyi:301: error: Signature of "create_datagram_endpoint" incompatible with supertype "AbstractEventLoop"  [override]
stdlib\asyncio\base_events.pyi:301: note:      Superclass:
stdlib\asyncio\base_events.pyi:301: note:          def [_ProtocolT <: BaseProtocol] create_datagram_endpoint(self, protocol_factory: Callable[[], _ProtocolT], local_addr: Optional[Tuple[str, int]] = ..., remote_addr: Optional[Tuple[str, int]] = ..., *, family: int = ..., proto: int = ..., flags: int = ..., reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ..., allow_broadcast: Optional[bool] = ..., sock: Optional[socket] = ...) -> Coroutine[Any, Any, Tuple[BaseTransport, _ProtocolT]]
stdlib\asyncio\base_events.pyi:301: note:      Subclass:
stdlib\asyncio\base_events.pyi:301: note:          def [_ProtocolT <: BaseProtocol] create_datagram_endpoint(self, protocol_factory: Callable[[], _ProtocolT], local_addr: Optional[Tuple[str, int]] = ..., remote_addr: Optional[Tuple[str, int]] = ..., *, family: int = ..., proto: int = ..., flags: int = ..., reuse_port: Optional[bool] = ..., allow_broadcast: Optional[bool] = ..., sock: Optional[socket] = ...) -> Coroutine[Any, Any, Tuple[BaseTransport, _ProtocolT]]

Here is the output when running python tests/mypy_test.py -p3.11 with this patch applied:

stdlib\typing.pyi:1166: error: Variable "typing.Never" is not valid as a type  [valid-type]
stdlib\typing.pyi:1166: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
stdlib\enum.pyi:222: error: Cannot inherit from final class "StrEnum"  [misc]
stdlib\enum.pyi:234: error: Cannot inherit from final class "StrEnum"  [misc]

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra
Copy link
Member

Thanks! Are the Never errors with mypy master or the latest release?

And the StrEnum errors seem like a mypy bug, do you know if it's already tracked?

@JelleZijlstra JelleZijlstra merged commit 2d6ab4d into python:master Feb 27, 2022
@AlexWaygood AlexWaygood deleted the mypy-311 branch February 27, 2022 12:11
@AlexWaygood
Copy link
Member Author

AlexWaygood commented Feb 27, 2022

Thanks! Are the Never errors with mypy master or the latest release?

With the latest release (0.931); I assume (though I haven't checked) that python/mypy#12153 fixes them. I'll try running the same test with mypy master and get back to you.

And the StrEnum errors seem like a mypy bug, do you know if it's already tracked?

It's been raised in python/mypy#12220

@AlexWaygood
Copy link
Member Author

AlexWaygood commented Feb 27, 2022

Okay, if I run mypy_test.py -p3.11 using mypy master, the Never errors and the StrEnum errors go away. There is however this new error, which also seems like a mypy bug:

stdlib\enum.pyi:172: error: Only a single data type mixin is allowed for Enum subtypes, found extra "enum.ReprEnum"  [misc]
stdlib\enum.pyi:213: error: Only a single data type mixin is allowed for Enum subtypes, found extra "enum.ReprEnum"  [misc]

I've filed an issue over at mypy: python/mypy#12258

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants