Skip to content

Commit

Permalink
reverse check order
Browse files Browse the repository at this point in the history
  • Loading branch information
mhils committed Nov 9, 2022
1 parent e3402cb commit c00e24a
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions pyupgrade/_plugins/typing_pep604.py
Expand Up @@ -144,20 +144,18 @@ def visit_Subscript(
if not _supported_version(state):
return

# prevent rewriting forward annotations (unless they will be dequoted)
has_forward_annotation = (
(sys.version_info >= (3, 9) and _any_arg_is_str(node.slice)) or
(
sys.version_info < (3, 9) and
isinstance(node.slice, ast.Index) and
_any_arg_is_str(node.slice.value)
# don't rewrite forward annotations (unless we know they will be dequoted)
if 'annotations' not in state.from_imports['__future__']:
has_forward_annotation = (
(sys.version_info >= (3, 9) and _any_arg_is_str(node.slice)) or
(
sys.version_info < (3, 9) and
isinstance(node.slice, ast.Index) and
_any_arg_is_str(node.slice.value)
)
)
)
if (
has_forward_annotation
and 'annotations' not in state.from_imports['__future__']
):
return
if has_forward_annotation:
return

if is_name_attr(
node.value,
Expand Down

0 comments on commit c00e24a

Please sign in to comment.