Skip to content

Commit

Permalink
Mark some deprecated-import fixes as unsafe.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjkuson committed Nov 26, 2023
1 parent 9b17724 commit ac3f43e
Show file tree
Hide file tree
Showing 22 changed files with 3,959 additions and 20 deletions.
29 changes: 29 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/pyupgrade/UP035_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Things that were moved from `collections` to `collections.abc`."""

from collections import (
AsyncGenerator,
AsyncIterable,
AsyncIterator,
Awaitable,
ByteString,
Callable,
Collection,
Container,
Coroutine,
Generator,
Hashable,
ItemsView,
Iterable,
Iterator,
KeysView,
Mapping,
MappingView,
MutableMapping,
MutableSequence,
MutableSet,
Reversible,
Sequence,
Set,
Sized,
ValuesView,
)
98 changes: 98 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/pyupgrade/UP035_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
"""Things that were moved from `typing_extensions` to `typing`."""
from typing_extensions import AbstractSet
from typing_extensions import AnyStr
from typing_extensions import AsyncIterable
from typing_extensions import AsyncIterator
from typing_extensions import Awaitable
from typing_extensions import BinaryIO
from typing_extensions import Callable
from typing_extensions import ClassVar
from typing_extensions import Collection
from typing_extensions import Container
from typing_extensions import ContextManager
from typing_extensions import Coroutine
from typing_extensions import DefaultDict
from typing_extensions import Dict
from typing_extensions import FrozenSet
from typing_extensions import Generator
from typing_extensions import Generic
from typing_extensions import Hashable
from typing_extensions import IO
from typing_extensions import ItemsView
from typing_extensions import Iterable
from typing_extensions import KeysView
from typing_extensions import List
from typing_extensions import Mapping
from typing_extensions import MappingView
from typing_extensions import Match
from typing_extensions import MutableMapping
from typing_extensions import MutableSequence
from typing_extensions import MutableSet
from typing_extensions import Optional
from typing_extensions import Pattern
from typing_extensions import Reversible
from typing_extensions import Sequence
from typing_extensions import Set
from typing_extensions import Sized
from typing_extensions import TYPE_CHECKING
from typing_extensions import Text
from typing_extensions import TextIO
from typing_extensions import Tuple
from typing_extensions import Type
from typing_extensions import Union
from typing_extensions import ValuesView
from typing_extensions import cast
from typing_extensions import no_type_check
from typing_extensions import no_type_check_decorator

from typing_extensions import AsyncContextManager
from typing_extensions import AsyncGenerator
from typing_extensions import ChainMap
from typing_extensions import Counter
from typing_extensions import Deque
from typing_extensions import ForwardRef
from typing_extensions import NoReturn

from typing_extensions import Final
from typing_extensions import OrderedDict
from typing_extensions import runtime_checkable

from typing_extensions import Annotated
from typing_extensions import get_type_hints

from typing_extensions import Concatenate
from typing_extensions import Literal
from typing_extensions import NewType
from typing_extensions import ParamSpecArgs
from typing_extensions import ParamSpecKwargs
from typing_extensions import TypeAlias
from typing_extensions import TypeGuard
from typing_extensions import get_args
from typing_extensions import get_origin
from typing_extensions import is_typeddict

from typing_extensions import Any
from typing_extensions import LiteralString
from typing_extensions import Never
from typing_extensions import NotRequired
from typing_extensions import Required
from typing_extensions import Self
from typing_extensions import assert_never
from typing_extensions import assert_type
from typing_extensions import clear_overloads
from typing_extensions import final
from typing_extensions import get_overloads
from typing_extensions import overload
from typing_extensions import reveal_type

from typing_extensions import Protocol
from typing_extensions import SupportsAbs
from typing_extensions import SupportsBytes
from typing_extensions import SupportsComplex
from typing_extensions import SupportsFloat
from typing_extensions import SupportsInt
from typing_extensions import SupportsRound
from typing_extensions import Unpack
from typing_extensions import dataclass_transform
from typing_extensions import NamedTuple
from typing_extensions import TypedDict
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"""Things moved from `pipes` to `shlex`."""
from pipes import quote
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Things moved from `mypy_extensions` to `typing`."""
from mypy_extensions import NoReturn

from mypy_extensions import TypedDict
26 changes: 26 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/pyupgrade/UP035_5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Members of `typing` that were moved to `collections.abc`."""
from typing import AsyncGenerator
from typing import AsyncIterable
from typing import AsyncIterator
from typing import Awaitable
from typing import ByteString
from typing import Collection
from typing import Container
from typing import Coroutine
from typing import Generator
from typing import Hashable
from typing import ItemsView
from typing import Iterable
from typing import Iterator
from typing import KeysView
from typing import Mapping
from typing import MappingView
from typing import MutableMapping
from typing import MutableSequence
from typing import MutableSet
from typing import Reversible
from typing import Sequence
from typing import Sized
from typing import ValuesView

from typing import Callable
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Members of `typing` that were moved to `collections`."""
from typing import ChainMap
from typing import Counter
from typing import OrderedDict
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Members of `typing` that were moved to `typing.re`."""
from typing import Match
from typing import Pattern
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Members of `typing.re` that were moved to `re`."""
from typing.re import Match
from typing.re import Pattern
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"""Members of `backports.strenum` that were moved to `enum`."""
from backports.strenum import StrEnum
11 changes: 10 additions & 1 deletion crates/ruff_linter/src/rules/pyupgrade/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ mod tests {
#[test_case(Rule::ConvertNamedTupleFunctionalToClass, Path::new("UP014.py"))]
#[test_case(Rule::ConvertTypedDictFunctionalToClass, Path::new("UP013.py"))]
#[test_case(Rule::DeprecatedCElementTree, Path::new("UP023.py"))]
#[test_case(Rule::DeprecatedImport, Path::new("UP035.py"))]
#[test_case(Rule::DeprecatedImport, Path::new("UP035_0.py"))]
#[test_case(Rule::DeprecatedImport, Path::new("UP035_1.py"))]
#[test_case(Rule::DeprecatedImport, Path::new("UP035_2.py"))]
#[test_case(Rule::DeprecatedImport, Path::new("UP035_3.py"))]
#[test_case(Rule::DeprecatedImport, Path::new("UP035_4.py"))]
#[test_case(Rule::DeprecatedImport, Path::new("UP035_5.py"))]
#[test_case(Rule::DeprecatedImport, Path::new("UP035_6.py"))]
#[test_case(Rule::DeprecatedImport, Path::new("UP035_7.py"))]
#[test_case(Rule::DeprecatedImport, Path::new("UP035_8.py"))]
#[test_case(Rule::DeprecatedImport, Path::new("UP035_9.py"))]
#[test_case(Rule::DeprecatedMockImport, Path::new("UP026.py"))]
#[test_case(Rule::DeprecatedUnittestAlias, Path::new("UP005.py"))]
#[test_case(Rule::ExtraneousParentheses, Path::new("UP034.py"))]
Expand Down
Loading

0 comments on commit ac3f43e

Please sign in to comment.