-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrong
Description
I used the object None, then error doesn't occur but the readability isn't good not to differentiate the type None and the default value None as shown below:
*Memo:
- mypy 1.18.2
- Windows 11
# Cannot differenciate
# ↓↓↓↓ ↓↓↓↓
def func(name: str | None = None) -> str:
return f'My name is {name}.'So, I used the type NoneType to improve the readability to differentiate the type NoneType and the default value None but the error occurs as shown below:
from types import NoneType
# Can differenciate
# ↓↓↓↓↓↓↓↓ ↓↓↓↓
def func(name: str | NoneType = None) -> str:
return f'My name is {x}.'$ mypy test.py
test.py:5: error: NoneType should not be used as a type, please use None instead [valid-type]
Found 1 error in 1 file (checked 1 source file)
Actually, it's not reasonable that the object None works but the type NoneType doesn't work.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong