-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
ruff 0.0.283 (error is new in this version)
Python 3.11.4
I get an error from ruff which proposes a solution, and applying that proposal causes an error.
I have the following file:
# example.py
#
# pip install requests_mock httpretty
import httpretty
import requests_mock
item: type[requests_mock.Mocker] | type[httpretty] = requests_mock.Mocker
python example.pyhas no outputruff --select=PYI --isolated example.pyshows:
example.py:42:7: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty]`.
The ruff documentation at https://beta.ruff.rs/docs/rules/unnecessary-type-union/ suggests that this change is purely cosmetic:
The type built-in function accepts unions, and it is clearer to explicitly specify them as a single type.
However, if I make the change suggested, and then run python example.py, I get a TypeError:
Traceback (most recent call last):
File "/Users/adam/Desktop/mypy-ruff-example/example.py", line 38, in <module>
item: type[requests_mock.Mocker | httpretty] = requests_mock.Mocker
~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
TypeError: unsupported operand type(s) for |: 'type' and 'module'
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working