-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-pep-585PEP 585 (builtin generics)PEP 585 (builtin generics)
Description
Bug Report
Incomplete implementation of PEP 585. There are cases where explicit annotations of the first argument of class methods (or __new__
) are handled correctly for typing.Type[...]
but not for builtins.type[...]
To Reproduce
import typing
class Spam:
def __new__(cls: typing.Type[typing.Self]) -> typing.Self:
return super().__new__(cls)
class Eggs:
def __new__(cls: type[typing.Self]) -> typing.Self:
return super().__new__(cls)
Expected Behavior
I expected both Spam and Eggs classes to pass
Actual Behavior
Spam passes, Eggs fails:
error: Method cannot have explicit self annotation and Self type [misc]
Your Environment
- Mypy version used:
mypy 1.4.0+dev.1ee465c9bd06170ea1a82765ec744e64cbd2a4be (compiled: no) - Mypy command-line flags:
(none) - Mypy configuration options from
mypy.ini
(and other config files):
(none) - Python version used:
3.11.3
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-pep-585PEP 585 (builtin generics)PEP 585 (builtin generics)