---
source: crates/ruff_linter/src/rules/pyupgrade/mod.rs
---
UP036_0.py:3:4: UP036 [*] Version block is outdated for minimum Python version
  |
1 | import sys
2 | 
3 | if sys.version_info < (3,0):
  |    ^^^^^^^^^^^^^^^^^^^^^^^^ UP036
4 |     print("py2")
5 | else:
  |
  = help: Remove outdated version block

ℹ Unsafe fix
1 1 | import sys
2 2 | 
3   |-if sys.version_info < (3,0):
4   |-    print("py2")
5   |-else:
6   |-    print("py3")
  3 |+print("py3")
7 4 | 
8 5 | if sys.version_info < (3,0):
9 6 |     if True:

UP036_0.py:8:4: UP036 [*] Version block is outdated for minimum Python version
   |
 6 |     print("py3")
 7 | 
 8 | if sys.version_info < (3,0):
   |    ^^^^^^^^^^^^^^^^^^^^^^^^ UP036
 9 |     if True:
10 |         print("py2!")
   |
   = help: Remove outdated version block

ℹ Unsafe fix
5  5  | else:
6  6  |     print("py3")
7  7  | 
8     |-if sys.version_info < (3,0):
9     |-    if True:
10    |-        print("py2!")
11    |-    else:
12    |-        print("???")
13    |-else:
14    |-    print("py3")
   8  |+print("py3")
15 9  | 
16 10 | if sys.version_info < (3,0): print("PY2!")
17 11 | else: print("PY3!")

UP036_0.py:16:4: UP036 [*] Version block is outdated for minimum Python version
   |
14 |     print("py3")
15 | 
16 | if sys.version_info < (3,0): print("PY2!")
   |    ^^^^^^^^^^^^^^^^^^^^^^^^ UP036
17 | else: print("PY3!")
   |
   = help: Remove outdated version block

ℹ Unsafe fix
13 13 | else:
14 14 |     print("py3")
15 15 | 
16    |-if sys.version_info < (3,0): print("PY2!")
17    |-else: print("PY3!")
   16 |+print("PY3!")
18 17 | 
19 18 | if True:
20 19 |     if sys.version_info < (3,0):

UP036_0.py:20:8: UP036 [*] Version block is outdated for minimum Python version
   |
19 | if True:
20 |     if sys.version_info < (3,0):
   |        ^^^^^^^^^^^^^^^^^^^^^^^^ UP036
21 |         print("PY2")
22 |     else:
   |
   = help: Remove outdated version block

ℹ Unsafe fix
17 17 | else: print("PY3!")
18 18 | 
19 19 | if True:
20    |-    if sys.version_info < (3,0):
21    |-        print("PY2")
22    |-    else:
23    |-        print("PY3")
   20 |+    print("PY3")
24 21 | 
25 22 | if sys.version_info < (3,0): print(1 if True else 3)
26 23 | else:

UP036_0.py:25:4: UP036 [*] Version block is outdated for minimum Python version
   |
23 |         print("PY3")
24 | 
25 | if sys.version_info < (3,0): print(1 if True else 3)
   |    ^^^^^^^^^^^^^^^^^^^^^^^^ UP036
26 | else:
27 |     print("py3")
   |
   = help: Remove outdated version block

ℹ Unsafe fix
22 22 |     else:
23 23 |         print("PY3")
24 24 | 
25    |-if sys.version_info < (3,0): print(1 if True else 3)
26    |-else:
27    |-    print("py3")
   25 |+print("py3")
28 26 | 
29 27 | if sys.version_info < (3,0):
30 28 |     def f():

UP036_0.py:29:4: UP036 [*] Version block is outdated for minimum Python version
   |
27 |     print("py3")
28 | 
29 | if sys.version_info < (3,0):
   |    ^^^^^^^^^^^^^^^^^^^^^^^^ UP036
30 |     def f():
31 |         print("py2")
   |
   = help: Remove outdated version block

ℹ Unsafe fix
26 26 | else:
27 27 |     print("py3")
28 28 | 
29    |-if sys.version_info < (3,0):
30    |-    def f():
31    |-        print("py2")
32    |-else:
33    |-    def f():
34    |-        print("py3")
35    |-        print("This the next")
   29 |+def f():
   30 |+    print("py3")
   31 |+    print("This the next")
36 32 | 
37 33 | if sys.version_info > (3,0):
38 34 |     print("py3")

UP036_0.py:37:4: UP036 [*] Version block is outdated for minimum Python version
   |
35 |         print("This the next")
36 | 
37 | if sys.version_info > (3,0):
   |    ^^^^^^^^^^^^^^^^^^^^^^^^ UP036
38 |     print("py3")
39 | else:
   |
   = help: Remove outdated version block

ℹ Unsafe fix
34 34 |         print("py3")
35 35 |         print("This the next")
36 36 | 
37    |-if sys.version_info > (3,0):
38    |-    print("py3")
39    |-else:
40    |-    print("py2")
   37 |+print("py3")
41 38 | 
42 39 | 
43 40 | x = 1

UP036_0.py:45:4: UP036 [*] Version block is outdated for minimum Python version
   |
43 | x = 1
44 | 
45 | if sys.version_info > (3,0):
   |    ^^^^^^^^^^^^^^^^^^^^^^^^ UP036
46 |     print("py3")
47 | else:
   |
   = help: Remove outdated version block

ℹ Unsafe fix
42 42 | 
43 43 | x = 1
44 44 | 
45    |-if sys.version_info > (3,0):
46    |-    print("py3")
47    |-else:
48    |-    print("py2")
   45 |+print("py3")
49 46 |     # ohai
50 47 | 
51 48 | x = 1

UP036_0.py:53:4: UP036 [*] Version block is outdated for minimum Python version
   |
51 | x = 1
52 | 
53 | if sys.version_info > (3,0): print("py3")
   |    ^^^^^^^^^^^^^^^^^^^^^^^^ UP036
54 | else: print("py2")
   |
   = help: Remove outdated version block

ℹ Unsafe fix
50 50 | 
51 51 | x = 1
52 52 | 
53    |-if sys.version_info > (3,0): print("py3")
54    |-else: print("py2")
   53 |+print("py3")
55 54 | 
56 55 | if sys.version_info > (3,):
57 56 |     print("py3")

UP036_0.py:56:4: UP036 [*] Version block is outdated for minimum Python version
   |
54 | else: print("py2")
55 | 
56 | if sys.version_info > (3,):
   |    ^^^^^^^^^^^^^^^^^^^^^^^ UP036
57 |     print("py3")
58 | else:
   |
   = help: Remove outdated version block

ℹ Unsafe fix
53 53 | if sys.version_info > (3,0): print("py3")
54 54 | else: print("py2")
55 55 | 
56    |-if sys.version_info > (3,):
57    |-    print("py3")
58    |-else:
59    |-    print("py2")
   56 |+print("py3")
60 57 | 
61 58 | if True:
62 59 |     if sys.version_info > (3,):

UP036_0.py:62:8: UP036 [*] Version block is outdated for minimum Python version
   |
61 | if True:
62 |     if sys.version_info > (3,):
   |        ^^^^^^^^^^^^^^^^^^^^^^^ UP036
63 |         print("py3")
64 |     else:
   |
   = help: Remove outdated version block

ℹ Unsafe fix
59 59 |     print("py2")
60 60 | 
61 61 | if True:
62    |-    if sys.version_info > (3,):
63    |-        print("py3")
64    |-    else:
65    |-        print("py2")
   62 |+    print("py3")
66 63 | 
67 64 | if sys.version_info < (3,):
68 65 |     print("py2")

UP036_0.py:67:4: UP036 [*] Version block is outdated for minimum Python version
   |
65 |         print("py2")
66 | 
67 | if sys.version_info < (3,):
   |    ^^^^^^^^^^^^^^^^^^^^^^^ UP036
68 |     print("py2")
69 | else:
   |
   = help: Remove outdated version block

ℹ Unsafe fix
64 64 |     else:
65 65 |         print("py2")
66 66 | 
67    |-if sys.version_info < (3,):
68    |-    print("py2")
69    |-else:
70    |-    print("py3")
   67 |+print("py3")
71 68 | 
72 69 | def f():
73 70 |     if sys.version_info < (3,0):

UP036_0.py:73:8: UP036 [*] Version block is outdated for minimum Python version
   |
72 | def f():
73 |     if sys.version_info < (3,0):
   |        ^^^^^^^^^^^^^^^^^^^^^^^^ UP036
74 |         try:
75 |             yield
   |
   = help: Remove outdated version block

ℹ Unsafe fix
70 70 |     print("py3")
71 71 | 
72 72 | def f():
73    |-    if sys.version_info < (3,0):
74    |-        try:
75    |-            yield
76    |-        finally:
77    |-            pass
78    |-    else:
79    |-        yield
   73 |+    yield
80 74 | 
81 75 | 
82 76 | class C:

UP036_0.py:86:8: UP036 [*] Version block is outdated for minimum Python version
   |
84 |         pass
85 | 
86 |     if sys.version_info < (3,0):
   |        ^^^^^^^^^^^^^^^^^^^^^^^^ UP036
87 |         def f(py2):
88 |             pass
   |
   = help: Remove outdated version block

ℹ Unsafe fix
83 83 |     def g():
84 84 |         pass
85 85 | 
86    |-    if sys.version_info < (3,0):
87    |-        def f(py2):
88    |-            pass
89    |-    else:
90    |-        def f(py3):
91    |-            pass
   86 |+    def f(py3):
   87 |+        pass
92 88 | 
93 89 |     def h():
94 90 |         pass

UP036_0.py:97:8: UP036 [*] Version block is outdated for minimum Python version
   |
96 | if True:
97 |     if sys.version_info < (3,0):
   |        ^^^^^^^^^^^^^^^^^^^^^^^^ UP036
98 |         2
99 |     else:
   |
   = help: Remove outdated version block

ℹ Unsafe fix
94  94  |         pass
95  95  | 
96  96  | if True:
97      |-    if sys.version_info < (3,0):
98      |-        2
99      |-    else:
100     |-        3
    97  |+    3
101 98  | 
102 99  |     # comment
103 100 | 

UP036_0.py:104:4: UP036 [*] Version block is outdated for minimum Python version
    |
102 |     # comment
103 | 
104 | if sys.version_info < (3,0):
    |    ^^^^^^^^^^^^^^^^^^^^^^^^ UP036
105 |     def f():
106 |         print("py2")
    |
    = help: Remove outdated version block

ℹ Unsafe fix
101 101 | 
102 102 |     # comment
103 103 | 
104     |-if sys.version_info < (3,0):
105     |-    def f():
106     |-        print("py2")
107     |-    def g():
108     |-        print("py2")
109     |-else:
110     |-    def f():
111     |-        print("py3")
112     |-    def g():
113     |-        print("py3")
    104 |+def f():
    105 |+    print("py3")
    106 |+def g():
    107 |+    print("py3")
114 108 | 
115 109 | if True:
116 110 |     if sys.version_info > (3,):

UP036_0.py:116:8: UP036 [*] Version block is outdated for minimum Python version
    |
115 | if True:
116 |     if sys.version_info > (3,):
    |        ^^^^^^^^^^^^^^^^^^^^^^^ UP036
117 |         print(3)
118 |     # comment
    |
    = help: Remove outdated version block

ℹ Unsafe fix
113 113 |         print("py3")
114 114 | 
115 115 | if True:
116     |-    if sys.version_info > (3,):
117     |-        print(3)
    116 |+    print(3)
118 117 |     # comment
119 118 |     print(2+3)
120 119 | 

UP036_0.py:122:8: UP036 [*] Version block is outdated for minimum Python version
    |
121 | if True:
122 |     if sys.version_info > (3,): print(3)
    |        ^^^^^^^^^^^^^^^^^^^^^^^ UP036
123 | 
124 | if True:
    |
    = help: Remove outdated version block

ℹ Unsafe fix
119 119 |     print(2+3)
120 120 | 
121 121 | if True:
122     |-    if sys.version_info > (3,): print(3)
    122 |+    print(3)
123 123 | 
124 124 | if True:
125 125 |     if sys.version_info > (3,):

UP036_0.py:125:8: UP036 [*] Version block is outdated for minimum Python version
    |
124 | if True:
125 |     if sys.version_info > (3,):
    |        ^^^^^^^^^^^^^^^^^^^^^^^ UP036
126 |         print(3)
    |
    = help: Remove outdated version block

ℹ Unsafe fix
122 122 |     if sys.version_info > (3,): print(3)
123 123 | 
124 124 | if True:
125     |-    if sys.version_info > (3,):
126     |-        print(3)
    125 |+    print(3)
127 126 | 
128 127 | 
129 128 | if True:

UP036_0.py:130:8: UP036 [*] Version block is outdated for minimum Python version
    |
129 | if True:
130 |     if sys.version_info <= (3, 0):
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036
131 |         expected_error = []
132 |     else:
    |
    = help: Remove outdated version block

ℹ Unsafe fix
127 127 | 
128 128 | 
129 129 | if True:
130     |-    if sys.version_info <= (3, 0):
131     |-        expected_error = []
132     |-    else:
133     |-        expected_error = [
    130 |+    expected_error = [
134 131 | "<stdin>:1:5: Generator expression must be parenthesized",
135 132 | "max(1 for i in range(10), key=lambda x: x+1)",
136 133 | "    ^",
137     |-        ]
    134 |+    ]
138 135 | 
139 136 | 
140 137 | if sys.version_info <= (3, 0):

UP036_0.py:140:4: UP036 [*] Version block is outdated for minimum Python version
    |
140 | if sys.version_info <= (3, 0):
    |    ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036
141 |     expected_error = []
142 | else:
    |
    = help: Remove outdated version block

ℹ Unsafe fix
137 137 |         ]
138 138 | 
139 139 | 
140     |-if sys.version_info <= (3, 0):
141     |-    expected_error = []
142     |-else:
143     |-    expected_error = [
    140 |+expected_error = [
144 141 | "<stdin>:1:5: Generator expression must be parenthesized",
145 142 | "max(1 for i in range(10), key=lambda x: x+1)",
146 143 | "    ^",
147     |-    ]
    144 |+]
148 145 | 
149 146 | 
150 147 | if sys.version_info > (3,0):

UP036_0.py:150:4: UP036 [*] Version block is outdated for minimum Python version
    |
150 | if sys.version_info > (3,0):
    |    ^^^^^^^^^^^^^^^^^^^^^^^^ UP036
151 |     """this
152 | is valid"""
    |
    = help: Remove outdated version block

ℹ Unsafe fix
147 147 |     ]
148 148 | 
149 149 | 
150     |-if sys.version_info > (3,0):
151     |-    """this
    150 |+"""this
152 151 | is valid"""
153 152 | 
154     |-    """the indentation on
    153 |+"""the indentation on
155 154 |     this line is significant"""
156 155 | 
157     |-    "this is" \
    156 |+"this is" \
158 157 |     "allowed too"
159 158 | 
160     |-    ("so is"
161     |-     "this for some reason")
    159 |+("so is"
    160 |+ "this for some reason")
162 161 | 
163 162 | if sys.version_info > (3, 0): expected_error = \
164 163 |     []

UP036_0.py:163:4: UP036 [*] Version block is outdated for minimum Python version
    |
161 |      "this for some reason")
162 | 
163 | if sys.version_info > (3, 0): expected_error = \
    |    ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036
164 |     []
    |
    = help: Remove outdated version block

ℹ Unsafe fix
160 160 |     ("so is"
161 161 |      "this for some reason")
162 162 | 
163     |-if sys.version_info > (3, 0): expected_error = \
    163 |+expected_error = \
164 164 |     []
165 165 | 
166 166 | if sys.version_info > (3, 0): expected_error = []

UP036_0.py:166:4: UP036 [*] Version block is outdated for minimum Python version
    |
164 |     []
165 | 
166 | if sys.version_info > (3, 0): expected_error = []
    |    ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036
167 | 
168 | if sys.version_info > (3, 0): \
    |
    = help: Remove outdated version block

ℹ Unsafe fix
163 163 | if sys.version_info > (3, 0): expected_error = \
164 164 |     []
165 165 | 
166     |-if sys.version_info > (3, 0): expected_error = []
    166 |+expected_error = []
167 167 | 
168 168 | if sys.version_info > (3, 0): \
169 169 |     expected_error = []

UP036_0.py:168:4: UP036 [*] Version block is outdated for minimum Python version
    |
166 | if sys.version_info > (3, 0): expected_error = []
167 | 
168 | if sys.version_info > (3, 0): \
    |    ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036
169 |     expected_error = []
    |
    = help: Remove outdated version block

ℹ Unsafe fix
165 165 | 
166 166 | if sys.version_info > (3, 0): expected_error = []
167 167 | 
168     |-if sys.version_info > (3, 0): \
169     |-    expected_error = []
    168 |+expected_error = []
170 169 | 
171 170 | if True:
172 171 |     if sys.version_info > (3, 0): expected_error = \

UP036_0.py:172:8: UP036 [*] Version block is outdated for minimum Python version
    |
171 | if True:
172 |     if sys.version_info > (3, 0): expected_error = \
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036
173 |     []
    |
    = help: Remove outdated version block

ℹ Unsafe fix
169 169 |     expected_error = []
170 170 | 
171 171 | if True:
172     |-    if sys.version_info > (3, 0): expected_error = \
    172 |+    expected_error = \
173 173 |     []
174 174 | 
175 175 | if True:

UP036_0.py:176:8: UP036 [*] Version block is outdated for minimum Python version
    |
175 | if True:
176 |     if sys.version_info > (3, 0): expected_error = []
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036
177 | 
178 | if True:
    |
    = help: Remove outdated version block

ℹ Unsafe fix
173 173 |     []
174 174 | 
175 175 | if True:
176     |-    if sys.version_info > (3, 0): expected_error = []
    176 |+    expected_error = []
177 177 | 
178 178 | if True:
179 179 |     if sys.version_info > (3, 0): \

UP036_0.py:179:8: UP036 [*] Version block is outdated for minimum Python version
    |
178 | if True:
179 |     if sys.version_info > (3, 0): \
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036
180 |     expected_error = []
    |
    = help: Remove outdated version block

ℹ Unsafe fix
176 176 |     if sys.version_info > (3, 0): expected_error = []
177 177 | 
178 178 | if True:
179     |-    if sys.version_info > (3, 0): \
180 179 |     expected_error = []
181 180 | 
182 181 | if sys.version_info < (3,12):

UP036_0.py:182:4: UP036 [*] Version block is outdated for minimum Python version
    |
180 |     expected_error = []
181 | 
182 | if sys.version_info < (3,12):
    |    ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036
183 |     print("py3")
    |
    = help: Remove outdated version block

ℹ Unsafe fix
179 179 |     if sys.version_info > (3, 0): \
180 180 |     expected_error = []
181 181 | 
182     |-if sys.version_info < (3,12):
183     |-    print("py3")
184 182 | 
185 183 | if sys.version_info <= (3,12):
186 184 |     print("py3")

UP036_0.py:191:24: UP036 Version specifier is invalid
    |
189 |     print("py3")
190 | 
191 | if sys.version_info == 10000000:
    |                        ^^^^^^^^ UP036
192 |     print("py3")
    |

UP036_0.py:194:23: UP036 Version specifier is invalid
    |
192 |     print("py3")
193 | 
194 | if sys.version_info < (3,10000000):
    |                       ^^^^^^^^^^^^ UP036
195 |     print("py3")
    |

UP036_0.py:197:24: UP036 Version specifier is invalid
    |
195 |     print("py3")
196 | 
197 | if sys.version_info <= (3,10000000):
    |                        ^^^^^^^^^^^^ UP036
198 |     print("py3")
    |

UP036_0.py:203:4: UP036 [*] Version block is outdated for minimum Python version
    |
201 |     print("py3")
202 | 
203 | if sys.version_info >= (3,12):
    |    ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036
204 |     print("py3")
    |
    = help: Remove outdated version block

ℹ Unsafe fix
200 200 | if sys.version_info > (3,12):
201 201 |     print("py3")
202 202 | 
203     |-if sys.version_info >= (3,12):
204     |-    print("py3")
    203 |+print("py3")
205 204 | 
206 205 | # Slices on `sys.version_info` should be treated equivalently.
207 206 | if sys.version_info[:2] >= (3,0):

UP036_0.py:207:4: UP036 [*] Version block is outdated for minimum Python version
    |
206 | # Slices on `sys.version_info` should be treated equivalently.
207 | if sys.version_info[:2] >= (3,0):
    |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036
208 |     print("py3")
    |
    = help: Remove outdated version block

ℹ Unsafe fix
204 204 |     print("py3")
205 205 | 
206 206 | # Slices on `sys.version_info` should be treated equivalently.
207     |-if sys.version_info[:2] >= (3,0):
208     |-    print("py3")
    207 |+print("py3")
209 208 | 
210 209 | if sys.version_info[:3] >= (3,0):
211 210 |     print("py3")

UP036_0.py:210:4: UP036 [*] Version block is outdated for minimum Python version
    |
208 |     print("py3")
209 | 
210 | if sys.version_info[:3] >= (3,0):
    |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036
211 |     print("py3")
    |
    = help: Remove outdated version block

ℹ Unsafe fix
207 207 | if sys.version_info[:2] >= (3,0):
208 208 |     print("py3")
209 209 | 
210     |-if sys.version_info[:3] >= (3,0):
211     |-    print("py3")
    210 |+print("py3")
212 211 | 
213 212 | if sys.version_info[:2] > (3,13):
214 213 |     print("py3")

UP036_0.py:219:4: UP036 [*] Version block is outdated for minimum Python version
    |
217 |     print("py3")
218 | 
219 | if sys.version_info > (3,0):
    |    ^^^^^^^^^^^^^^^^^^^^^^^^ UP036
220 |     f"this is\
221 |     allowed too"
    |
    = help: Remove outdated version block

ℹ Unsafe fix
216 216 | if sys.version_info[:3] > (3,13):
217 217 |     print("py3")
218 218 | 
219     |-if sys.version_info > (3,0):
220     |-    f"this is\
    219 |+f"this is\
221 220 |     allowed too"
222 221 | 
223     |-    f"""the indentation on
    222 |+f"""the indentation on
224 223 |     this line is significant"""
225 224 | 
226     |-    "this is\
    225 |+"this is\
227 226 |     allowed too"


