Summary
PYI061 is marked as a safe fix but it's not, and breaks code that uses typing.get_args to do input validation based on type hints. E.g. the two outputs from get_args are not the same before and after the fix
>>> from typing import Literal, get_args
>>> options = Literal['foo', 'bar', None] # violates PYI061
>>> print(get_args(options))
('foo', 'bar', None)
>>> options = Literal['foo', 'bar'] | None # auto-fix for PYI061
>>> print(get_args(options))
(typing.Literal['foo', 'bar'], <class 'NoneType'>)
This auto-fix breaks this code:
def thing(arg: options):
# Validate input
assert arg in get_args(options)
# Do useful stuff
...
Version
v0.13.3 (from pre-commit mirror)