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

ℹ Suggested 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:1: UP036 [*] Version block is outdated for minimum Python version
   |
 8 |       print("py3")
 9 |   
10 | / if sys.version_info < (3,0):
11 | |     if True:
12 | |         print("py2!")
13 | |     else:
14 | |         print("???")
15 | | else:
16 | |     print("py3")
   | |________________^ UP036
17 |   
18 |   if sys.version_info < (3,0): print("PY2!")
   |
   = help: Remove outdated version block

ℹ Suggested 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:1: UP036 [*] Version block is outdated for minimum Python version
   |
16 |       print("py3")
17 |   
18 | / if sys.version_info < (3,0): print("PY2!")
19 | | else: print("PY3!")
   | |___________________^ UP036
20 |   
21 |   if True:
   |
   = help: Remove outdated version block

ℹ Suggested 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:5: UP036 [*] Version block is outdated for minimum Python version
   |
20 |   if True:
21 |       if sys.version_info < (3,0):
   |  _____^
22 | |         print("PY2")
23 | |     else:
24 | |         print("PY3")
   | |____________________^ UP036
25 |   
26 |   if sys.version_info < (3,0): print(1 if True else 3)
   |
   = help: Remove outdated version block

ℹ Suggested 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:1: UP036 [*] Version block is outdated for minimum Python version
   |
25 |           print("PY3")
26 |   
27 | / if sys.version_info < (3,0): print(1 if True else 3)
28 | | else:
29 | |     print("py3")
   | |________________^ UP036
30 |   
31 |   if sys.version_info < (3,0):
   |
   = help: Remove outdated version block

ℹ Suggested 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:1: UP036 [*] Version block is outdated for minimum Python version
   |
29 |       print("py3")
30 |   
31 | / if sys.version_info < (3,0):
32 | |     def f():
33 | |         print("py2")
34 | | else:
35 | |     def f():
36 | |         print("py3")
37 | |         print("This the next")
   | |______________________________^ UP036
38 |   
39 |   if sys.version_info > (3,0):
   |
   = help: Remove outdated version block

ℹ Suggested 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:1: UP036 [*] Version block is outdated for minimum Python version
   |
37 |           print("This the next")
38 |   
39 | / if sys.version_info > (3,0):
40 | |     print("py3")
41 | | else:
42 | |     print("py2")
   | |________________^ UP036
   |
   = help: Remove outdated version block

ℹ Suggested 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:1: UP036 [*] Version block is outdated for minimum Python version
   |
45 |   x = 1
46 |   
47 | / if sys.version_info > (3,0):
48 | |     print("py3")
49 | | else:
50 | |     print("py2")
   | |________________^ UP036
51 |       # ohai
   |
   = help: Remove outdated version block

ℹ Suggested 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:1: UP036 [*] Version block is outdated for minimum Python version
   |
53 |   x = 1
54 |   
55 | / if sys.version_info > (3,0): print("py3")
56 | | else: print("py2")
   | |__________________^ UP036
57 |   
58 |   if sys.version_info > (3,):
   |
   = help: Remove outdated version block

ℹ Suggested 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:1: UP036 [*] Version block is outdated for minimum Python version
   |
56 |   else: print("py2")
57 |   
58 | / if sys.version_info > (3,):
59 | |     print("py3")
60 | | else:
61 | |     print("py2")
   | |________________^ UP036
62 |   
63 |   if True:
   |
   = help: Remove outdated version block

ℹ Suggested 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:5: UP036 [*] Version block is outdated for minimum Python version
   |
62 |   if True:
63 |       if sys.version_info > (3,):
   |  _____^
64 | |         print("py3")
65 | |     else:
66 | |         print("py2")
   | |____________________^ UP036
67 |   
68 |   if sys.version_info < (3,):
   |
   = help: Remove outdated version block

ℹ Suggested 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:1: UP036 [*] Version block is outdated for minimum Python version
   |
67 |           print("py2")
68 |   
69 | / if sys.version_info < (3,):
70 | |     print("py2")
71 | | else:
72 | |     print("py3")
   | |________________^ UP036
73 |   
74 |   def f():
   |
   = help: Remove outdated version block

ℹ Suggested 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:5: UP036 [*] Version block is outdated for minimum Python version
   |
73 |   def f():
74 |       if sys.version_info < (3,0):
   |  _____^
75 | |         try:
76 | |             yield
77 | |         finally:
78 | |             pass
79 | |     else:
80 | |         yield
   | |_____________^ UP036
   |
   = help: Remove outdated version block

ℹ Suggested 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:5: UP036 [*] Version block is outdated for minimum Python version
   |
86 |           pass
87 |   
88 |       if sys.version_info < (3,0):
   |  _____^
89 | |         def f(py2):
90 | |             pass
91 | |     else:
92 | |         def f(py3):
93 | |             pass
   | |________________^ UP036
94 |   
95 |       def h():
   |
   = help: Remove outdated version block

ℹ Suggested 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:5: UP036 [*] Version block is outdated for minimum Python version
    |
 97 |   if True:
 98 |       if sys.version_info < (3,0):
    |  _____^
 99 | |         2
100 | |     else:
101 | |         3
    | |_________^ UP036
102 |   
103 |       # comment
    |
    = help: Remove outdated version block

ℹ Suggested 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:1: UP036 [*] Version block is outdated for minimum Python version
    |
104 |       # comment
105 |   
106 | / if sys.version_info < (3,0):
107 | |     def f():
108 | |         print("py2")
109 | |     def g():
110 | |         print("py2")
111 | | else:
112 | |     def f():
113 | |         print("py3")
114 | |     def g():
115 | |         print("py3")
    | |____________________^ UP036
116 |   
117 |   if True:
    |
    = help: Remove outdated version block

ℹ Suggested 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:5: UP036 [*] Version block is outdated for minimum Python version
    |
116 |   if True:
117 |       if sys.version_info > (3,):
    |  _____^
118 | |         print(3)
    | |________________^ UP036
119 |       # comment
120 |       print(2+3)
    |
    = help: Remove outdated version block

ℹ Suggested 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:5: UP036 [*] Version block is outdated for minimum Python version
    |
122 | if True:
123 |     if sys.version_info > (3,): print(3)
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036
124 | 
125 | if True:
    |
    = help: Remove outdated version block

ℹ Suggested 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:5: UP036 [*] Version block is outdated for minimum Python version
    |
125 |   if True:
126 |       if sys.version_info > (3,):
    |  _____^
127 | |         print(3)
    | |________________^ UP036
    |
    = help: Remove outdated version block

ℹ Suggested 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:5: UP036 [*] Version block is outdated for minimum Python version
    |
130 |   if True:
131 |       if sys.version_info <= (3, 0):
    |  _____^
132 | |         expected_error = []
133 | |     else:
134 | |         expected_error = [
135 | | "<stdin>:1:5: Generator expression must be parenthesized",
136 | | "max(1 for i in range(10), key=lambda x: x+1)",
137 | | "    ^",
138 | |         ]
    | |_________^ UP036
    |
    = help: Remove outdated version block

ℹ Suggested 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:1: UP036 [*] Version block is outdated for minimum Python version
    |
140 | / if sys.version_info <= (3, 0):
141 | |     expected_error = []
142 | | else:
143 | |     expected_error = [
144 | | "<stdin>:1:5: Generator expression must be parenthesized",
145 | | "max(1 for i in range(10), key=lambda x: x+1)",
146 | | "    ^",
147 | |     ]
    | |_____^ UP036
    |
    = help: Remove outdated version block

ℹ Suggested 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:1: UP036 [*] Version block is outdated for minimum Python version
    |
150 | / if sys.version_info > (3,0):
151 | |     """this
152 | | is valid"""
153 | | 
154 | |     """the indentation on
155 | |     this line is significant"""
156 | | 
157 | |     "this is" \
158 | |     "allowed too"
159 | | 
160 | |     ("so is"
161 | |      "this for some reason")
    | |____________________________^ UP036
162 |   
163 |   if sys.version_info > (3, 0): expected_error = \
    |
    = help: Remove outdated version block

ℹ Suggested 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:1: UP036 [*] Version block is outdated for minimum Python version
    |
163 |        "this for some reason")
164 |   
165 | / if sys.version_info > (3, 0): expected_error = \
166 | |     []
    | |______^ UP036
167 |   
168 |   if sys.version_info > (3, 0): expected_error = []
    |
    = help: Remove outdated version block

ℹ Suggested 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:1: UP036 [*] Version block is outdated for minimum Python version
    |
166 |     []
167 | 
168 | if sys.version_info > (3, 0): expected_error = []
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036
169 | 
170 | if sys.version_info > (3, 0): \
    |
    = help: Remove outdated version block

ℹ Suggested 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:1: UP036 [*] Version block is outdated for minimum Python version
    |
168 |   if sys.version_info > (3, 0): expected_error = []
169 |   
170 | / if sys.version_info > (3, 0): \
171 | |     expected_error = []
    | |_______________________^ UP036
172 |   
173 |   if True:
    |
    = help: Remove outdated version block

ℹ Suggested 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:5: UP036 [*] Version block is outdated for minimum Python version
    |
172 |   if True:
173 |       if sys.version_info > (3, 0): expected_error = \
    |  _____^
174 | |     []
    | |______^ UP036
175 |   
176 |   if True:
    |
    = help: Remove outdated version block

ℹ Suggested 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:5: UP036 [*] Version block is outdated for minimum Python version
    |
176 | if True:
177 |     if sys.version_info > (3, 0): expected_error = []
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036
178 | 
179 | if True:
    |
    = help: Remove outdated version block

ℹ Suggested 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:5: UP036 [*] Version block is outdated for minimum Python version
    |
179 |   if True:
180 |       if sys.version_info > (3, 0): \
    |  _____^
181 | |     expected_error = []
    | |_______________________^ UP036
    |
    = help: Remove outdated version block

ℹ Suggested 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 = []


