@@ -153,14 +153,7 @@ def visit_Subscript(
153
153
154
154
# don't rewrite forward annotations (unless we know they will be dequoted)
155
155
if 'annotations' not in state .from_imports ['__future__' ]:
156
- if (
157
- (sys .version_info >= (3 , 9 ) and _any_arg_is_str (node .slice )) or
158
- (
159
- sys .version_info < (3 , 9 ) and
160
- isinstance (node .slice , ast .Index ) and
161
- _any_arg_is_str (node .slice .value )
162
- )
163
- ):
156
+ if _any_arg_is_str (node .slice ):
164
157
return
165
158
166
159
if is_name_attr (
@@ -171,19 +164,12 @@ def visit_Subscript(
171
164
):
172
165
yield ast_to_offset (node ), _fix_optional
173
166
elif is_name_attr (node .value , state .from_imports , ('typing' ,), ('Union' ,)):
174
- if sys .version_info >= (3 , 9 ): # pragma: >=3.9 cover
175
- node_slice = node .slice
176
- elif isinstance (node .slice , ast .Index ): # pragma: <3.9 cover
177
- node_slice : ast .AST = node .slice .value
178
- else : # pragma: <3.9 cover
179
- node_slice = node .slice # unexpected slice type
180
-
181
- if isinstance (node_slice , ast .Slice ): # not a valid annotation
167
+ if isinstance (node .slice , ast .Slice ): # not a valid annotation
182
168
return
183
169
184
- if isinstance (node_slice , ast .Tuple ):
185
- if node_slice .elts :
186
- arg_count = len (node_slice .elts )
170
+ if isinstance (node . slice , ast .Tuple ):
171
+ if node . slice .elts :
172
+ arg_count = len (node . slice .elts )
187
173
else :
188
174
return # empty Union
189
175
else :
0 commit comments