11-- -
22source : crates / ruff_linter / src / rules / pyupgrade / mod .rs
3- snapshot_kind : text
43-- -
5- UP045 .py :5 :10 : UP007 [* ] Use ` X | Y ` for type annotations
4+ UP045 .py :5 :10 : UP045 [* ] Use ` X | None ` for type annotations
65 |
765 | def f (x : Optional [str ]) -> None :
8- | ^^^^^^^^^^^^^ UP007
7+ | ^^^^^^^^^^^^^ UP045
986 | ...
109 |
11- = help : Convert to `X | Y `
10+ = help : Convert to `X | None `
1211
1312ℹ Safe fix
14132 2 | from typing import Optional
@@ -20,13 +19,13 @@ UP045.py:5:10: UP007 [*] Use `X | Y` for type annotations
20197 7 |
21208 8 |
2221
23- UP045 .py :9 :10 : UP007 [* ] Use ` X | Y ` for type annotations
22+ UP045 .py :9 :10 : UP045 [* ] Use ` X | None ` for type annotations
2423 |
2524 9 | def f (x : typing .Optional [str ]) -> None :
26- | ^^^^^^^^^^^^^^^^^^^^ UP007
25+ | ^^^^^^^^^^^^^^^^^^^^ UP045
272610 | ...
2827 |
29- = help : Convert to `X | Y `
28+ = help : Convert to `X | None `
3029
3130ℹ Safe fix
32316 6 | ...
@@ -38,14 +37,14 @@ UP045.py:9:10: UP007 [*] Use `X | Y` for type annotations
383711 11 |
393812 12 |
4039
41- UP045 .py :14 :8 : UP007 [*] Use `X | Y ` for type annotations
40+ UP045 .py :14 :8 : UP045 [*] Use `X | None ` for type annotations
4241 |
434213 | def f () -> None :
444314 | x : Optional [str ]
45- | ^^^^^^^^^^^^^ UP007
44+ | ^^^^^^^^^^^^^ UP045
464515 | x = Optional [str ]
4746 |
48- = help : Convert to `X | Y `
47+ = help : Convert to `X | None `
4948
5049ℹ Safe fix
515011 11 |
@@ -57,22 +56,22 @@ UP045.py:14:8: UP007 [*] Use `X | Y` for type annotations
575616 16 |
585717 17 |
5958
60- UP045 .py :15 :9 : UP007 Use `X | Y ` for type annotations
59+ UP045 .py :15 :9 : UP045 Use `X | None ` for type annotations
6160 |
626113 | def f () -> None :
636214 | x : Optional [str ]
646315 | x = Optional [str ]
65- | ^^^^^^^^^^^^^ UP007
64+ | ^^^^^^^^^^^^^ UP045
6665 |
67- = help : Convert to `X | Y `
66+ = help : Convert to `X | None `
6867
69- UP045 .py :18 :15 : UP007 [*] Use `X | Y ` for type annotations
68+ UP045 .py :18 :15 : UP045 [*] Use `X | None ` for type annotations
7069 |
717018 | def f (x : list [Optional [int ]]) -> None :
72- | ^^^^^^^^^^^^^ UP007
71+ | ^^^^^^^^^^^^^ UP045
737219 | ...
7473 |
75- = help : Convert to `X | Y `
74+ = help : Convert to `X | None `
7675
7776ℹ Safe fix
787715 15 | x = Optional [str ]
@@ -84,31 +83,31 @@ UP045.py:18:15: UP007 [*] Use `X | Y` for type annotations
848320 20 |
858421 21 |
8685
87- UP045 .py :22 :10 : UP007 Use `X | Y ` for type annotations
86+ UP045 .py :22 :10 : UP045 Use `X | None ` for type annotations
8887 |
898822 | def f (x : Optional [int : float ]) -> None :
90- | ^^^^^^^^^^^^^^^^^^^^^ UP007
89+ | ^^^^^^^^^^^^^^^^^^^^^ UP045
919023 | ...
9291 |
93- = help : Convert to `X | Y `
92+ = help : Convert to `X | None `
9493
95- UP045 .py :26 :10 : UP007 Use `X | Y ` for type annotations
94+ UP045 .py :26 :10 : UP045 Use `X | None ` for type annotations
9695 |
979626 | def f (x : Optional [str , int : float ]) -> None :
98- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007
97+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP045
999827 | ...
10099 |
101- = help : Convert to `X | Y `
100+ = help : Convert to `X | None `
102101
103- UP045 .py :30 :10 : UP007 Use `X | Y ` for type annotations
102+ UP045 .py :30 :10 : UP045 Use `X | None ` for type annotations
104103 |
10510430 | def f (x : Optional [int , float ]) -> None :
106- | ^^^^^^^^^^^^^^^^^^^^ UP007
105+ | ^^^^^^^^^^^^^^^^^^^^ UP045
10710631 | ...
108107 |
109- = help : Convert to `X | Y `
108+ = help : Convert to `X | None `
110109
111- UP045 .py :36 :28 : UP007 [*] Use `X | Y ` for type annotations
110+ UP045 .py :36 :28 : UP045 [*] Use `X | None ` for type annotations
112111 |
11311234 | # Regression test for : https :// github.com/astral-sh/ruff/issues/7131
11411335 | class ServiceRefOrValue :
@@ -117,9 +116,9 @@ UP045.py:36:28: UP007 [*] Use `X | Y` for type annotations
11711637 | | list [ServiceSpecificationRef ]
11811738 | | | list [ServiceSpecification ]
11911839 | | ] = None
120- | |_____ ^ UP007
119+ | |_____ ^ UP045
121120 |
122- = help : Convert to `X | Y `
121+ = help : Convert to `X | None `
123122
124123ℹ Safe fix
12512433 33 |
@@ -134,14 +133,14 @@ UP045.py:36:28: UP007 [*] Use `X | Y` for type annotations
13413341 38 |
13513442 39 | # Regression test for : https :// github.com/astral-sh/ruff/issues/7201
136135
137- UP045 .py :44:28: UP007 [*] Use `X | Y ` for type annotations
136+ UP045 .py :44:28: UP045 [*] Use `X | None ` for type annotations
138137 |
13913842 | # Regression test for : https :// github.com/astral-sh/ruff/issues/7201
14013943 | class ServiceRefOrValue :
14114044 | service_specification : Optional [str ]is not True = None
142- | ^^^^^^^^^^^^^ UP007
141+ | ^^^^^^^^^^^^^ UP045
143142 |
144- = help : Convert to `X | Y `
143+ = help : Convert to `X | None `
145144
146145ℹ Safe fix
14714641 41 |
0 commit comments