-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expand scope of quoted-annotation rule
- Loading branch information
1 parent
81b88dc
commit 0dc782c
Showing
7 changed files
with
695 additions
and
2 deletions.
There are no files selected for viewing
File renamed without changes.
106 changes: 106 additions & 0 deletions
106
crates/ruff/resources/test/fixtures/pyupgrade/UP037_1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
from typing import ( | ||
Annotated, | ||
Callable, | ||
List, | ||
Literal, | ||
NamedTuple, | ||
Tuple, | ||
TypeVar, | ||
TypedDict, | ||
cast, | ||
) | ||
|
||
from mypy_extensions import Arg, DefaultArg, DefaultNamedArg, NamedArg, VarArg | ||
|
||
|
||
def foo(var: "MyClass") -> "MyClass": | ||
x: "MyClass" | ||
|
||
|
||
def foo(*, inplace: "bool"): | ||
pass | ||
|
||
|
||
def foo(*args: "str", **kwargs: "int"): | ||
pass | ||
|
||
|
||
x: Tuple["MyClass"] | ||
|
||
x: Callable[["MyClass"], None] | ||
|
||
|
||
class Foo(NamedTuple): | ||
x: "MyClass" | ||
|
||
|
||
class D(TypedDict): | ||
E: TypedDict("E", foo="int", total=False) | ||
|
||
|
||
class D(TypedDict): | ||
E: TypedDict("E", {"foo": "int"}) | ||
|
||
|
||
x: Annotated["str", "metadata"] | ||
|
||
x: Arg("str", "name") | ||
|
||
x: DefaultArg("str", "name") | ||
|
||
x: NamedArg("str", "name") | ||
|
||
x: DefaultNamedArg("str", "name") | ||
|
||
x: DefaultNamedArg("str", name="name") | ||
|
||
x: VarArg("str") | ||
|
||
x: List[List[List["MyClass"]]] | ||
|
||
x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) | ||
|
||
x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) | ||
|
||
x: NamedTuple(typename="X", fields=[("foo", "int")]) | ||
|
||
X: MyCallable("X") | ||
|
||
|
||
# OK | ||
class D(TypedDict): | ||
E: TypedDict("E") | ||
|
||
|
||
x: Annotated[()] | ||
|
||
x: DefaultNamedArg(name="name", quox="str") | ||
|
||
x: DefaultNamedArg(name="name") | ||
|
||
x: NamedTuple("X", [("foo",), ("bar",)]) | ||
|
||
x: NamedTuple("X", ["foo", "bar"]) | ||
|
||
x: NamedTuple() | ||
|
||
x: Literal["foo", "bar"] | ||
|
||
x = cast(x, "str") | ||
|
||
|
||
def foo(x, *args, **kwargs): | ||
... | ||
|
||
|
||
def foo(*, inplace): | ||
... | ||
|
||
|
||
x: Annotated[1:2] = ... | ||
|
||
x = TypeVar("x", "str", "int") | ||
|
||
x = cast("str", x) | ||
|
||
X = List["MyClass"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.