Closed MSafariyan closed 8 months ago
requires-python = ">=3.11" - repo: https://github.com/asottile/pyupgrade rev: v3.15.0 hooks: - id: pyupgrade args: - --py311-plus
currently i have a similar method:
from collections.abc import Awaitable class RedisPort: @abstractmethod - def srem(self, name: str, *values: bytes | str | float) -> Union[Awaitable[int], int]: + def srem(self, name: str, *values: bytes | str | float) -> Awaitable[int] | int: raise NotImplementedError
then pyupgrade try to change Union operator to | so the python raise TypeError exception:
(<class 'TypeError'>, unsupported operand type(s) for |: 'types.GenericAlias' and 'function', <traceback object at 0x7f2a3223f080>)
when you instruct pyupgrade to --py311-plus you're telling it "I only run python 3.11 or newer" -- your error message is from python 3.9
--py311-plus
currently i have a similar method:
then pyupgrade try to change Union operator to | so the python raise TypeError exception: