diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap index 627d1a33c5b673..0e1e489f55deaf 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap @@ -395,7 +395,7 @@ PYI016.py:57:5: PYI016 [*] Duplicate union member `set[int]` | = help: Remove duplicate union member `set[int]` -ℹ Safe fix +ℹ Unsafe fix 50 50 | field17: dict[int, int] # OK 51 51 | 52 52 | # Should emit in cases with newlines @@ -407,7 +407,7 @@ PYI016.py:57:5: PYI016 [*] Duplicate union member `set[int]` 58 |- int # bar 59 |- ], 60 |-] # Error, newline and comment will not be emitted in message - 53 |+field18: typing.Union[set[int]] # Error, newline and comment will not be emitted in message + 53 |+field18: set[int] # Error, newline and comment will not be emitted in message 61 54 | 62 55 | # Should emit in cases with `typing.Union` instead of `|` 63 56 | field19: typing.Union[int, int] # Error @@ -427,7 +427,7 @@ PYI016.py:63:28: PYI016 [*] Duplicate union member `int` 61 61 | 62 62 | # Should emit in cases with `typing.Union` instead of `|` 63 |-field19: typing.Union[int, int] # Error - 63 |+field19: typing.Union[int] # Error + 63 |+field19: int # Error 64 64 | 65 65 | # Should emit in cases with nested `typing.Union` 66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error @@ -487,7 +487,7 @@ PYI016.py:72:41: PYI016 [*] Duplicate union member `int` 70 70 | 71 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 |-field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - 72 |+field22: typing.Union[int] # Error + 72 |+field22: int # Error 73 73 | 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo @@ -507,7 +507,7 @@ PYI016.py:72:59: PYI016 [*] Duplicate union member `int` 70 70 | 71 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 |-field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - 72 |+field22: typing.Union[int] # Error + 72 |+field22: int # Error 73 73 | 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo @@ -527,7 +527,7 @@ PYI016.py:72:64: PYI016 [*] Duplicate union member `int` 70 70 | 71 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 |-field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - 72 |+field22: typing.Union[int] # Error + 72 |+field22: int # Error 73 73 | 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo @@ -569,7 +569,7 @@ PYI016.py:81:41: PYI016 [*] Duplicate union member `int` 79 79 | # duplicates of the outer `int`), but not three times (which would indicate that 80 80 | # we incorrectly re-checked the nested union). 81 |-field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` - 81 |+field24: typing.Union[int] # PYI016: Duplicate union member `int` + 81 |+field24: int # PYI016: Duplicate union member `int` 82 82 | 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are 84 84 | # duplicates of the outer `int`), but not three times (which would indicate that @@ -590,7 +590,7 @@ PYI016.py:81:46: PYI016 [*] Duplicate union member `int` 79 79 | # duplicates of the outer `int`), but not three times (which would indicate that 80 80 | # we incorrectly re-checked the nested union). 81 |-field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` - 81 |+field24: typing.Union[int] # PYI016: Duplicate union member `int` + 81 |+field24: int # PYI016: Duplicate union member `int` 82 82 | 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are 84 84 | # duplicates of the outer `int`), but not three times (which would indicate that diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap index 9cb761a504385e..95768ab6d1cb5b 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap @@ -395,7 +395,7 @@ PYI016.pyi:57:5: PYI016 [*] Duplicate union member `set[int]` | = help: Remove duplicate union member `set[int]` -ℹ Safe fix +ℹ Unsafe fix 50 50 | field17: dict[int, int] # OK 51 51 | 52 52 | # Should emit in cases with newlines @@ -407,7 +407,7 @@ PYI016.pyi:57:5: PYI016 [*] Duplicate union member `set[int]` 58 |- int # bar 59 |- ], 60 |-] # Error, newline and comment will not be emitted in message - 53 |+field18: typing.Union[set[int]] # Error, newline and comment will not be emitted in message + 53 |+field18: set[int] # Error, newline and comment will not be emitted in message 61 54 | 62 55 | # Should emit in cases with `typing.Union` instead of `|` 63 56 | field19: typing.Union[int, int] # Error @@ -427,7 +427,7 @@ PYI016.pyi:63:28: PYI016 [*] Duplicate union member `int` 61 61 | 62 62 | # Should emit in cases with `typing.Union` instead of `|` 63 |-field19: typing.Union[int, int] # Error - 63 |+field19: typing.Union[int] # Error + 63 |+field19: int # Error 64 64 | 65 65 | # Should emit in cases with nested `typing.Union` 66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error @@ -487,7 +487,7 @@ PYI016.pyi:72:41: PYI016 [*] Duplicate union member `int` 70 70 | 71 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 |-field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - 72 |+field22: typing.Union[int] # Error + 72 |+field22: int # Error 73 73 | 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo @@ -507,7 +507,7 @@ PYI016.pyi:72:59: PYI016 [*] Duplicate union member `int` 70 70 | 71 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 |-field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - 72 |+field22: typing.Union[int] # Error + 72 |+field22: int # Error 73 73 | 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo @@ -527,7 +527,7 @@ PYI016.pyi:72:64: PYI016 [*] Duplicate union member `int` 70 70 | 71 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 |-field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - 72 |+field22: typing.Union[int] # Error + 72 |+field22: int # Error 73 73 | 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo @@ -569,7 +569,7 @@ PYI016.pyi:81:41: PYI016 [*] Duplicate union member `int` 79 79 | # duplicates of the outer `int`), but not three times (which would indicate that 80 80 | # we incorrectly re-checked the nested union). 81 |-field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` - 81 |+field24: typing.Union[int] # PYI016: Duplicate union member `int` + 81 |+field24: int # PYI016: Duplicate union member `int` 82 82 | 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are 84 84 | # duplicates of the outer `int`), but not three times (which would indicate that @@ -590,7 +590,7 @@ PYI016.pyi:81:46: PYI016 [*] Duplicate union member `int` 79 79 | # duplicates of the outer `int`), but not three times (which would indicate that 80 80 | # we incorrectly re-checked the nested union). 81 |-field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` - 81 |+field24: typing.Union[int] # PYI016: Duplicate union member `int` + 81 |+field24: int # PYI016: Duplicate union member `int` 82 82 | 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are 84 84 | # duplicates of the outer `int`), but not three times (which would indicate that @@ -652,7 +652,7 @@ PYI016.pyi:89:41: PYI016 [*] Duplicate union member `int` 87 87 | 88 88 | # Should emit in cases with nested `typing.Union` 89 |-field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` - 89 |+field26: typing.Union[int] # PYI016: Duplicate union member `int` + 89 |+field26: int # PYI016: Duplicate union member `int` 90 90 | 91 91 | # Should emit in cases with nested `typing.Union` 92 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]] # PYI016: Duplicate union member `int` @@ -672,7 +672,7 @@ PYI016.pyi:92:54: PYI016 [*] Duplicate union member `int` 90 90 | 91 91 | # Should emit in cases with nested `typing.Union` 92 |-field27: typing.Union[typing.Union[typing.Union[int, int]]] # PYI016: Duplicate union member `int` - 92 |+field27: typing.Union[int] # PYI016: Duplicate union member `int` + 92 |+field27: int # PYI016: Duplicate union member `int` 93 93 | 94 94 | # Should emit in cases with mixed `typing.Union` and `|` 95 95 | field28: typing.Union[int | int] # Error @@ -712,7 +712,7 @@ PYI016.pyi:98:54: PYI016 [*] Duplicate union member `int` 96 96 | 97 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 |-field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error - 98 |+field29: typing.Union[int] # Error + 98 |+field29: int # Error 99 99 | 100 100 | # Should emit once in cases with multiple nested `typing.Union` 101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error @@ -732,7 +732,7 @@ PYI016.pyi:98:59: PYI016 [*] Duplicate union member `int` 96 96 | 97 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 |-field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error - 98 |+field29: typing.Union[int] # Error + 98 |+field29: int # Error 99 99 | 100 100 | # Should emit once in cases with multiple nested `typing.Union` 101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041.pyi.snap index a0a40536b1ea59..ce7dba5a3a99eb 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041.pyi.snap @@ -152,103 +152,151 @@ PYI041.pyi:45:26: PYI041 [*] Use `float` instead of `int | float` 45 |+def f7(arg1: int, *args: float) -> None: ... # PYI041 46 46 | 47 47 | -48 48 | class Foo: +48 48 | def f8( -PYI041.pyi:51:24: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041.pyi:49:10: PYI041 [*] Use `complex` instead of `int | float | complex` | -49 | def good(self, arg: int) -> None: ... -50 | -51 | def bad(self, arg: int | float | complex) -> None: ... # PYI041 +48 | def f8( +49 | arg: Union[ # comment + | __________^ +50 | | float, # another +51 | | complex, int] + | |_____________________^ PYI041 +52 | ) -> None: ... # PYI041 + | + = help: Remove duplicates + +ℹ Safe fix +46 46 | +47 47 | +48 48 | def f8( +49 |- arg: Union[ # comment +50 |- float, # another +51 |- complex, int] + 49 |+ arg: complex +52 50 | ) -> None: ... # PYI041 +53 51 | +54 52 | def f9( + +PYI041.pyi:56:9: PYI041 [*] Use `complex` instead of `int | float | complex` + | +54 | def f9( +55 | arg: ( +56 | int | # comment + | _________^ +57 | | float | # another +58 | | complex + | |_______________^ PYI041 +59 | ) +60 | ) -> None: ... # PYI041 + | + = help: Remove duplicates + +ℹ Safe fix +53 53 | +54 54 | def f9( +55 55 | arg: ( +56 |- int | # comment +57 |- float | # another +58 56 | complex +59 57 | ) +60 58 | ) -> None: ... # PYI041 + +PYI041.pyi:65:24: PYI041 [*] Use `complex` instead of `int | float | complex` + | +63 | def good(self, arg: int) -> None: ... +64 | +65 | def bad(self, arg: int | float | complex) -> None: ... # PYI041 | ^^^^^^^^^^^^^^^^^^^^^ PYI041 -52 | -53 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 +66 | +67 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 | = help: Remove duplicates ℹ Safe fix -48 48 | class Foo: -49 49 | def good(self, arg: int) -> None: ... -50 50 | -51 |- def bad(self, arg: int | float | complex) -> None: ... # PYI041 - 51 |+ def bad(self, arg: complex) -> None: ... # PYI041 -52 52 | -53 53 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 -54 54 | +62 62 | class Foo: +63 63 | def good(self, arg: int) -> None: ... +64 64 | +65 |- def bad(self, arg: int | float | complex) -> None: ... # PYI041 + 65 |+ def bad(self, arg: complex) -> None: ... # PYI041 +66 66 | +67 67 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 +68 68 | -PYI041.pyi:53:25: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041.pyi:67:25: PYI041 [*] Use `complex` instead of `int | float | complex` | -51 | def bad(self, arg: int | float | complex) -> None: ... # PYI041 -52 | -53 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 +65 | def bad(self, arg: int | float | complex) -> None: ... # PYI041 +66 | +67 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 -54 | -55 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 +68 | +69 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 | = help: Remove duplicates ℹ Safe fix -50 50 | -51 51 | def bad(self, arg: int | float | complex) -> None: ... # PYI041 -52 52 | -53 |- def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 - 53 |+ def bad2(self, arg: complex) -> None: ... # PYI041 -54 54 | -55 55 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 -56 56 | +64 64 | +65 65 | def bad(self, arg: int | float | complex) -> None: ... # PYI041 +66 66 | +67 |- def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 + 67 |+ def bad2(self, arg: complex) -> None: ... # PYI041 +68 68 | +69 69 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 +70 70 | -PYI041.pyi:55:25: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041.pyi:69:25: PYI041 [*] Use `complex` instead of `int | float | complex` | -53 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 -54 | -55 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 +67 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 +68 | +69 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 -56 | -57 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 +70 | +71 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 | = help: Remove duplicates ℹ Safe fix -52 52 | -53 53 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 -54 54 | -55 |- def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 - 55 |+ def bad3(self, arg: complex) -> None: ... # PYI041 -56 56 | -57 57 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 -58 58 | +66 66 | +67 67 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 +68 68 | +69 |- def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 + 69 |+ def bad3(self, arg: complex) -> None: ... # PYI041 +70 70 | +71 71 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 +72 72 | -PYI041.pyi:57:25: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041.pyi:71:25: PYI041 [*] Use `complex` instead of `int | float | complex` | -55 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 -56 | -57 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 +69 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 +70 | +71 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 -58 | -59 | def bad5(self, arg: int | (float | complex)) -> None: ... # PYI041 +72 | +73 | def bad5(self, arg: int | (float | complex)) -> None: ... # PYI041 | = help: Remove duplicates ℹ Safe fix -54 54 | -55 55 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 -56 56 | -57 |- def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 - 57 |+ def bad4(self, arg: complex) -> None: ... # PYI041 -58 58 | -59 59 | def bad5(self, arg: int | (float | complex)) -> None: ... # PYI041 +68 68 | +69 69 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 +70 70 | +71 |- def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 + 71 |+ def bad4(self, arg: complex) -> None: ... # PYI041 +72 72 | +73 73 | def bad5(self, arg: int | (float | complex)) -> None: ... # PYI041 -PYI041.pyi:59:25: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041.pyi:73:25: PYI041 [*] Use `complex` instead of `int | float | complex` | -57 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 -58 | -59 | def bad5(self, arg: int | (float | complex)) -> None: ... # PYI041 +71 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 +72 | +73 | def bad5(self, arg: int | (float | complex)) -> None: ... # PYI041 | ^^^^^^^^^^^^^^^^^^^^^^^ PYI041 | = help: Remove duplicates ℹ Safe fix -56 56 | -57 57 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 -58 58 | -59 |- def bad5(self, arg: int | (float | complex)) -> None: ... # PYI041 - 59 |+ def bad5(self, arg: complex) -> None: ... # PYI041 +70 70 | +71 71 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 +72 72 | +73 |- def bad5(self, arg: int | (float | complex)) -> None: ... # PYI041 + 73 |+ def bad5(self, arg: complex) -> None: ... # PYI041 diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.pyi.snap index 0a96dea0cec1e8..af19856e37f57d 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.pyi.snap @@ -207,7 +207,7 @@ PYI062.pyi:14:32: PYI062 [*] Duplicate literal member `2` 14 |+Literal[1, 2] # once 15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once 16 16 | typing_extensions.Literal[1, 1, 1] # twice -17 17 | +17 17 | Literal[ PYI062.pyi:15:37: PYI062 [*] Duplicate literal member `1` | @@ -216,6 +216,7 @@ PYI062.pyi:15:37: PYI062 [*] Duplicate literal member `1` 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once | ^ PYI062 16 | typing_extensions.Literal[1, 1, 1] # twice +17 | Literal[ | = help: Remove duplicates @@ -226,8 +227,8 @@ PYI062.pyi:15:37: PYI062 [*] Duplicate literal member `1` 15 |-t.Literal[1, t.Literal[2, t.Literal[1]]] # once 15 |+t.Literal[1, 2] # once 16 16 | typing_extensions.Literal[1, 1, 1] # twice -17 17 | -18 18 | # Ensure issue is only raised once, even on nested literals +17 17 | Literal[ +18 18 | 1, # comment PYI062.pyi:16:30: PYI062 [*] Duplicate literal member `1` | @@ -235,8 +236,8 @@ PYI062.pyi:16:30: PYI062 [*] Duplicate literal member `1` 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once 16 | typing_extensions.Literal[1, 1, 1] # twice | ^ PYI062 -17 | -18 | # Ensure issue is only raised once, even on nested literals +17 | Literal[ +18 | 1, # comment | = help: Remove duplicates @@ -246,9 +247,9 @@ PYI062.pyi:16:30: PYI062 [*] Duplicate literal member `1` 15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once 16 |-typing_extensions.Literal[1, 1, 1] # twice 16 |+typing_extensions.Literal[1] # twice -17 17 | -18 18 | # Ensure issue is only raised once, even on nested literals -19 19 | MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062 +17 17 | Literal[ +18 18 | 1, # comment +19 19 | Literal[ # another comment PYI062.pyi:16:33: PYI062 [*] Duplicate literal member `1` | @@ -256,8 +257,8 @@ PYI062.pyi:16:33: PYI062 [*] Duplicate literal member `1` 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once 16 | typing_extensions.Literal[1, 1, 1] # twice | ^ PYI062 -17 | -18 | # Ensure issue is only raised once, even on nested literals +17 | Literal[ +18 | 1, # comment | = help: Remove duplicates @@ -267,25 +268,104 @@ PYI062.pyi:16:33: PYI062 [*] Duplicate literal member `1` 15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once 16 |-typing_extensions.Literal[1, 1, 1] # twice 16 |+typing_extensions.Literal[1] # twice -17 17 | -18 18 | # Ensure issue is only raised once, even on nested literals -19 19 | MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062 +17 17 | Literal[ +18 18 | 1, # comment +19 19 | Literal[ # another comment -PYI062.pyi:19:46: PYI062 [*] Duplicate literal member `True` +PYI062.pyi:20:9: PYI062 [*] Duplicate literal member `1` | -18 | # Ensure issue is only raised once, even on nested literals -19 | MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062 +18 | 1, # comment +19 | Literal[ # another comment +20 | 1 + | ^ PYI062 +21 | ] +22 | ] # once + | + = help: Remove duplicates + +ℹ Unsafe fix +14 14 | Literal[1, Literal[2], Literal[2]] # once +15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once +16 16 | typing_extensions.Literal[1, 1, 1] # twice +17 |-Literal[ +18 |- 1, # comment +19 |- Literal[ # another comment +20 |- 1 +21 |- ] +22 |-] # once + 17 |+Literal[1] # once +23 18 | +24 19 | # Ensure issue is only raised once, even on nested literals +25 20 | MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062 + +PYI062.pyi:25:46: PYI062 [*] Duplicate literal member `True` + | +24 | # Ensure issue is only raised once, even on nested literals +25 | MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062 | ^^^^ PYI062 -20 | -21 | n: Literal["No", "duplicates", "here", 1, "1"] +26 | +27 | n: Literal["No", "duplicates", "here", 1, "1"] | = help: Remove duplicates ℹ Safe fix -16 16 | typing_extensions.Literal[1, 1, 1] # twice -17 17 | -18 18 | # Ensure issue is only raised once, even on nested literals -19 |-MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062 - 19 |+MyType = Literal["foo", True, False, "bar"] # PYI062 -20 20 | -21 21 | n: Literal["No", "duplicates", "here", 1, "1"] +22 22 | ] # once +23 23 | +24 24 | # Ensure issue is only raised once, even on nested literals +25 |-MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062 + 25 |+MyType = Literal["foo", True, False, "bar"] # PYI062 +26 26 | +27 27 | n: Literal["No", "duplicates", "here", 1, "1"] +28 28 | + +PYI062.pyi:32:37: PYI062 [*] Duplicate literal member `1` + | +30 | # nested literals, all equivalent to `Literal[1]` +31 | Literal[Literal[1]] # no duplicate +32 | Literal[Literal[Literal[1], Literal[1]]] # once + | ^ PYI062 +33 | Literal[Literal[1], Literal[Literal[Literal[1]]]] # once + | + = help: Remove duplicates + +ℹ Safe fix +29 29 | +30 30 | # nested literals, all equivalent to `Literal[1]` +31 31 | Literal[Literal[1]] # no duplicate +32 |-Literal[Literal[Literal[1], Literal[1]]] # once + 32 |+Literal[Literal[1]] # once +33 33 | Literal[Literal[1], Literal[Literal[Literal[1]]]] # once + +PYI062.pyi:32:37: PYI062 [*] Duplicate literal member `1` + | +30 | # nested literals, all equivalent to `Literal[1]` +31 | Literal[Literal[1]] # no duplicate +32 | Literal[Literal[Literal[1], Literal[1]]] # once + | ^ PYI062 +33 | Literal[Literal[1], Literal[Literal[Literal[1]]]] # once + | + = help: Remove duplicates + +ℹ Safe fix +29 29 | +30 30 | # nested literals, all equivalent to `Literal[1]` +31 31 | Literal[Literal[1]] # no duplicate +32 |-Literal[Literal[Literal[1], Literal[1]]] # once + 32 |+Literal[1] # once +33 33 | Literal[Literal[1], Literal[Literal[Literal[1]]]] # once + +PYI062.pyi:33:45: PYI062 [*] Duplicate literal member `1` + | +31 | Literal[Literal[1]] # no duplicate +32 | Literal[Literal[Literal[1], Literal[1]]] # once +33 | Literal[Literal[1], Literal[Literal[Literal[1]]]] # once + | ^ PYI062 + | + = help: Remove duplicates + +ℹ Safe fix +30 30 | # nested literals, all equivalent to `Literal[1]` +31 31 | Literal[Literal[1]] # no duplicate +32 32 | Literal[Literal[Literal[1], Literal[1]]] # once +33 |-Literal[Literal[1], Literal[Literal[Literal[1]]]] # once + 33 |+Literal[1] # once