1
1
-- -
2
2
source : crates / ruff_linter / src / rules / pyupgrade / mod .rs
3
- snapshot_kind : text
4
3
-- -
5
- UP045 .py :5 :10 : UP007 [* ] Use ` X | Y ` for type annotations
4
+ UP045 .py :5 :10 : UP045 [* ] Use ` X | None ` for type annotations
6
5
|
7
6
5 | def f (x : Optional [str ]) -> None :
8
- | ^^^^^^^^^^^^^ UP007
7
+ | ^^^^^^^^^^^^^ UP045
9
8
6 | ...
10
9
|
11
- = help : Convert to `X | Y `
10
+ = help : Convert to `X | None `
12
11
13
12
ℹ Safe fix
14
13
2 2 | from typing import Optional
@@ -20,13 +19,13 @@ UP045.py:5:10: UP007 [*] Use `X | Y` for type annotations
20
19
7 7 |
21
20
8 8 |
22
21
23
- UP045 .py :9 :10 : UP007 [* ] Use ` X | Y ` for type annotations
22
+ UP045 .py :9 :10 : UP045 [* ] Use ` X | None ` for type annotations
24
23
|
25
24
9 | def f (x : typing .Optional [str ]) -> None :
26
- | ^^^^^^^^^^^^^^^^^^^^ UP007
25
+ | ^^^^^^^^^^^^^^^^^^^^ UP045
27
26
10 | ...
28
27
|
29
- = help : Convert to `X | Y `
28
+ = help : Convert to `X | None `
30
29
31
30
ℹ Safe fix
32
31
6 6 | ...
@@ -38,14 +37,14 @@ UP045.py:9:10: UP007 [*] Use `X | Y` for type annotations
38
37
11 11 |
39
38
12 12 |
40
39
41
- UP045 .py :14 :8 : UP007 [*] Use `X | Y ` for type annotations
40
+ UP045 .py :14 :8 : UP045 [*] Use `X | None ` for type annotations
42
41
|
43
42
13 | def f () -> None :
44
43
14 | x : Optional [str ]
45
- | ^^^^^^^^^^^^^ UP007
44
+ | ^^^^^^^^^^^^^ UP045
46
45
15 | x = Optional [str ]
47
46
|
48
- = help : Convert to `X | Y `
47
+ = help : Convert to `X | None `
49
48
50
49
ℹ Safe fix
51
50
11 11 |
@@ -57,22 +56,22 @@ UP045.py:14:8: UP007 [*] Use `X | Y` for type annotations
57
56
16 16 |
58
57
17 17 |
59
58
60
- UP045 .py :15 :9 : UP007 Use `X | Y ` for type annotations
59
+ UP045 .py :15 :9 : UP045 Use `X | None ` for type annotations
61
60
|
62
61
13 | def f () -> None :
63
62
14 | x : Optional [str ]
64
63
15 | x = Optional [str ]
65
- | ^^^^^^^^^^^^^ UP007
64
+ | ^^^^^^^^^^^^^ UP045
66
65
|
67
- = help : Convert to `X | Y `
66
+ = help : Convert to `X | None `
68
67
69
- UP045 .py :18 :15 : UP007 [*] Use `X | Y ` for type annotations
68
+ UP045 .py :18 :15 : UP045 [*] Use `X | None ` for type annotations
70
69
|
71
70
18 | def f (x : list [Optional [int ]]) -> None :
72
- | ^^^^^^^^^^^^^ UP007
71
+ | ^^^^^^^^^^^^^ UP045
73
72
19 | ...
74
73
|
75
- = help : Convert to `X | Y `
74
+ = help : Convert to `X | None `
76
75
77
76
ℹ Safe fix
78
77
15 15 | x = Optional [str ]
@@ -84,31 +83,31 @@ UP045.py:18:15: UP007 [*] Use `X | Y` for type annotations
84
83
20 20 |
85
84
21 21 |
86
85
87
- UP045 .py :22 :10 : UP007 Use `X | Y ` for type annotations
86
+ UP045 .py :22 :10 : UP045 Use `X | None ` for type annotations
88
87
|
89
88
22 | def f (x : Optional [int : float ]) -> None :
90
- | ^^^^^^^^^^^^^^^^^^^^^ UP007
89
+ | ^^^^^^^^^^^^^^^^^^^^^ UP045
91
90
23 | ...
92
91
|
93
- = help : Convert to `X | Y `
92
+ = help : Convert to `X | None `
94
93
95
- UP045 .py :26 :10 : UP007 Use `X | Y ` for type annotations
94
+ UP045 .py :26 :10 : UP045 Use `X | None ` for type annotations
96
95
|
97
96
26 | def f (x : Optional [str , int : float ]) -> None :
98
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007
97
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP045
99
98
27 | ...
100
99
|
101
- = help : Convert to `X | Y `
100
+ = help : Convert to `X | None `
102
101
103
- UP045 .py :30 :10 : UP007 Use `X | Y ` for type annotations
102
+ UP045 .py :30 :10 : UP045 Use `X | None ` for type annotations
104
103
|
105
104
30 | def f (x : Optional [int , float ]) -> None :
106
- | ^^^^^^^^^^^^^^^^^^^^ UP007
105
+ | ^^^^^^^^^^^^^^^^^^^^ UP045
107
106
31 | ...
108
107
|
109
- = help : Convert to `X | Y `
108
+ = help : Convert to `X | None `
110
109
111
- UP045 .py :36 :28 : UP007 [*] Use `X | Y ` for type annotations
110
+ UP045 .py :36 :28 : UP045 [*] Use `X | None ` for type annotations
112
111
|
113
112
34 | # Regression test for : https :// github.com/astral-sh/ruff/issues/7131
114
113
35 | class ServiceRefOrValue :
@@ -117,9 +116,9 @@ UP045.py:36:28: UP007 [*] Use `X | Y` for type annotations
117
116
37 | | list [ServiceSpecificationRef ]
118
117
38 | | | list [ServiceSpecification ]
119
118
39 | | ] = None
120
- | |_____ ^ UP007
119
+ | |_____ ^ UP045
121
120
|
122
- = help : Convert to `X | Y `
121
+ = help : Convert to `X | None `
123
122
124
123
ℹ Safe fix
125
124
33 33 |
@@ -134,14 +133,14 @@ UP045.py:36:28: UP007 [*] Use `X | Y` for type annotations
134
133
41 38 |
135
134
42 39 | # Regression test for : https :// github.com/astral-sh/ruff/issues/7201
136
135
137
- UP045 .py :44:28: UP007 [*] Use `X | Y ` for type annotations
136
+ UP045 .py :44:28: UP045 [*] Use `X | None ` for type annotations
138
137
|
139
138
42 | # Regression test for : https :// github.com/astral-sh/ruff/issues/7201
140
139
43 | class ServiceRefOrValue :
141
140
44 | service_specification : Optional [str ]is not True = None
142
- | ^^^^^^^^^^^^^ UP007
141
+ | ^^^^^^^^^^^^^ UP045
143
142
|
144
- = help : Convert to `X | Y `
143
+ = help : Convert to `X | None `
145
144
146
145
ℹ Safe fix
147
146
41 41 |
0 commit comments