11-- -
22source : crates / ruff_linter / src / rules / pyupgrade / mod .rs
33-- -
4- UP045 .py :5 :10 : UP007 [* ] Use ` X | Y ` for type annotations
4+ UP045 .py :5 :10 : UP045 [* ] Use ` X | None ` for type annotations
55 |
665 | def f (x : Optional [str ]) -> None :
7- | ^^^^^^^^^^^^^ UP007
7+ | ^^^^^^^^^^^^^ UP045
886 | ...
99 |
10- = help : Convert to `X | Y `
10+ = help : Convert to `X | None `
1111
1212ℹ Safe fix
13132 2 | from typing import Optional
@@ -19,13 +19,13 @@ UP045.py:5:10: UP007 [*] Use `X | Y` for type annotations
19197 7 |
20208 8 |
2121
22- UP045 .py :9 :10 : UP007 [* ] Use ` X | Y ` for type annotations
22+ UP045 .py :9 :10 : UP045 [* ] Use ` X | None ` for type annotations
2323 |
2424 9 | def f (x : typing .Optional [str ]) -> None :
25- | ^^^^^^^^^^^^^^^^^^^^ UP007
25+ | ^^^^^^^^^^^^^^^^^^^^ UP045
262610 | ...
2727 |
28- = help : Convert to `X | Y `
28+ = help : Convert to `X | None `
2929
3030ℹ Safe fix
31316 6 | ...
@@ -37,14 +37,14 @@ UP045.py:9:10: UP007 [*] Use `X | Y` for type annotations
373711 11 |
383812 12 |
3939
40- UP045 .py :14 :8 : UP007 [*] Use `X | Y ` for type annotations
40+ UP045 .py :14 :8 : UP045 [*] Use `X | None ` for type annotations
4141 |
424213 | def f () -> None :
434314 | x : Optional [str ]
44- | ^^^^^^^^^^^^^ UP007
44+ | ^^^^^^^^^^^^^ UP045
454515 | x = Optional [str ]
4646 |
47- = help : Convert to `X | Y `
47+ = help : Convert to `X | None `
4848
4949ℹ Safe fix
505011 11 |
@@ -56,22 +56,22 @@ UP045.py:14:8: UP007 [*] Use `X | Y` for type annotations
565616 16 |
575717 17 |
5858
59- UP045 .py :15 :9 : UP007 Use `X | Y ` for type annotations
59+ UP045 .py :15 :9 : UP045 Use `X | None ` for type annotations
6060 |
616113 | def f () -> None :
626214 | x : Optional [str ]
636315 | x = Optional [str ]
64- | ^^^^^^^^^^^^^ UP007
64+ | ^^^^^^^^^^^^^ UP045
6565 |
66- = help : Convert to `X | Y `
66+ = help : Convert to `X | None `
6767
68- UP045 .py :18 :15 : UP007 [*] Use `X | Y ` for type annotations
68+ UP045 .py :18 :15 : UP045 [*] Use `X | None ` for type annotations
6969 |
707018 | def f (x : list [Optional [int ]]) -> None :
71- | ^^^^^^^^^^^^^ UP007
71+ | ^^^^^^^^^^^^^ UP045
727219 | ...
7373 |
74- = help : Convert to `X | Y `
74+ = help : Convert to `X | None `
7575
7676ℹ Safe fix
777715 15 | x = Optional [str ]
@@ -83,31 +83,31 @@ UP045.py:18:15: UP007 [*] Use `X | Y` for type annotations
838320 20 |
848421 21 |
8585
86- UP045 .py :22 :10 : UP007 Use `X | Y ` for type annotations
86+ UP045 .py :22 :10 : UP045 Use `X | None ` for type annotations
8787 |
888822 | def f (x : Optional [int : float ]) -> None :
89- | ^^^^^^^^^^^^^^^^^^^^^ UP007
89+ | ^^^^^^^^^^^^^^^^^^^^^ UP045
909023 | ...
9191 |
92- = help : Convert to `X | Y `
92+ = help : Convert to `X | None `
9393
94- UP045 .py :26 :10 : UP007 Use `X | Y ` for type annotations
94+ UP045 .py :26 :10 : UP045 Use `X | None ` for type annotations
9595 |
969626 | def f (x : Optional [str , int : float ]) -> None :
97- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007
97+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP045
989827 | ...
9999 |
100- = help : Convert to `X | Y `
100+ = help : Convert to `X | None `
101101
102- UP045 .py :30 :10 : UP007 Use `X | Y ` for type annotations
102+ UP045 .py :30 :10 : UP045 Use `X | None ` for type annotations
103103 |
10410430 | def f (x : Optional [int , float ]) -> None :
105- | ^^^^^^^^^^^^^^^^^^^^ UP007
105+ | ^^^^^^^^^^^^^^^^^^^^ UP045
10610631 | ...
107107 |
108- = help : Convert to `X | Y `
108+ = help : Convert to `X | None `
109109
110- UP045 .py :36 :28 : UP007 [*] Use `X | Y ` for type annotations
110+ UP045 .py :36 :28 : UP045 [*] Use `X | None ` for type annotations
111111 |
11211234 | # Regression test for : https :// github.com/astral-sh/ruff/issues/7131
11311335 | class ServiceRefOrValue :
@@ -116,9 +116,9 @@ UP045.py:36:28: UP007 [*] Use `X | Y` for type annotations
11611637 | | list [ServiceSpecificationRef ]
11711738 | | | list [ServiceSpecification ]
11811839 | | ] = None
119- | |_____ ^ UP007
119+ | |_____ ^ UP045
120120 |
121- = help : Convert to `X | Y `
121+ = help : Convert to `X | None `
122122
123123ℹ Safe fix
12412433 33 |
@@ -133,14 +133,14 @@ UP045.py:36:28: UP007 [*] Use `X | Y` for type annotations
13313341 38 |
13413442 39 | # Regression test for : https :// github.com/astral-sh/ruff/issues/7201
135135
136- UP045 .py :44:28: UP007 [*] Use `X | Y ` for type annotations
136+ UP045 .py :44:28: UP045 [*] Use `X | None ` for type annotations
137137 |
13813842 | # Regression test for : https :// github.com/astral-sh/ruff/issues/7201
13913943 | class ServiceRefOrValue :
14014044 | service_specification : Optional [str ]is not True = None
141- | ^^^^^^^^^^^^^ UP007
141+ | ^^^^^^^^^^^^^ UP045
142142 |
143- = help : Convert to `X | Y `
143+ = help : Convert to `X | None `
144144
145145ℹ Safe fix
14614641 41 |
@@ -152,11 +152,11 @@ UP045.py:44:28: UP007 [*] Use `X | Y` for type annotations
15215246 46 |
15315347 47 | # Test for : https :// github.com/astral-sh/ruff/issues/18508
154154
155- UP045 .py :49:6: UP007 Use `X | Y ` for type annotations
155+ UP045 .py :49:6: UP045 Use `X | None ` for type annotations
156156 |
15715747 | # Test for : https :// github.com/astral-sh/ruff/issues/18508
15815848 | # Optional [None ] should not be offered a fix
15915949 | foo : Optional [None ] = None
160- | ^^^^^^^^^^^^^^ UP007
160+ | ^^^^^^^^^^^^^^ UP045
161161 |
162- = help : Convert to `X | Y `
162+ = help : Convert to `X | None `
0 commit comments