You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pylint should be able to detect if PEP 604 (alternative Union Syntax) is used inappropriately.
The PEP will be implemented in 3.10, so the following should emit error messages in versions 3 - 3.9:
Alias=str|int# Should be an errorvar: str|int# Should be an errordeffunc(arg: int|str): # Should be an errorpassdeffunc2() ->int|str: # Should be an errorpass
Each line is a TypeError in Python, eg:
Traceback (most recent call last):
File "test.py", line 3, in <module>
Alias = str | int
TypeError: unsupported operand type(s) for |: 'type' and 'type'
With postponed evaluation of annotations enabled (3.7 - 3.9)
from __future__ importannotationsAlias=str|int# Should be an errorvar: str|intdeffunc(arg: int|str):
passdeffunc2() ->int|str:
pass
Only the alias definition is evaluated directly and thus an error.
Current situation
No errors are emitted, even in versions prior to 3.10 and without the future import.
Is your feature request related to a problem?
Pylint should be able to detect if PEP 604 (alternative Union Syntax) is used inappropriately.
The PEP will be implemented in 3.10, so the following should emit error messages in versions 3 - 3.9:
Each line is a
TypeError
in Python, eg:With postponed evaluation of annotations enabled (3.7 - 3.9)
Only the alias definition is evaluated directly and thus an error.
Current situation
No errors are emitted, even in versions prior to 3.10 and without the future import.
--
https://www.python.org/dev/peps/pep-0604/
The text was updated successfully, but these errors were encountered: