Allow to import 'Sequence' from 'typing' rather than from 'collections.abc' #3383
-
Hi, thanks for making I'm having some trouble with ruff modifying my imports and I can't figure out which rule I need to disable. I would like to import
Minimal exampleHere's what I would like to do: from typing import Sequence, Callable, Float, Union
FloatOrFloats = Union[Float, Sequence[Float]] but ruff re-formats this to: from collections.abc import Sequence
from typing import Float, Union
FloatOrFloats = Union[Float, Sequence[Float]] Any help on how I can prevent the imports from changing would be much appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Sorry I just realised that you can run ruff with a from typing import Sequence, Float, Union # noqa: UP035
FloatOrFloats = Union[Float, Sequence[Float]] |
Beta Was this translation helpful? Give feedback.
-
A more "sustainable" option might be to set your [tool.ruff]
target-version = "py38" That should avoid any rewrites that aren't compatible with Python 3.8! |
Beta Was this translation helpful? Give feedback.
A more "sustainable" option might be to set your
target-version
topy38
, like:That should avoid any rewrites that aren't compatible with Python 3.8!