Skip to content

Commit

Permalink
Merge pull request #638 from JelleZijlstra/no311
Browse files Browse the repository at this point in the history
Do not remove quoted annotations on 3.11
  • Loading branch information
asottile committed May 5, 2022
2 parents cada1f2 + 632a9ee commit f77b9ad
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,6 @@ Availability:

Availability:
- File imports `from __future__ import annotations`
- `--py311-plus` is passed on the commandline.

```diff
-def f(x: 'queue.Queue[int]') -> C:
Expand Down
5 changes: 1 addition & 4 deletions pyupgrade/_plugins/typing_pep563.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@


def _supported_version(state: State) -> bool:
return (
state.settings.min_version >= (3, 11) or
'annotations' in state.from_imports['__future__']
)
return 'annotations' in state.from_imports['__future__']


def _dequote(i: int, tokens: list[Token], *, new: str) -> None:
Expand Down
7 changes: 1 addition & 6 deletions tests/features/typing_pep563_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'from typing import Literal\n'
'x: "str"\n',
(2, 7),
id='not python 3.11+',
id='missing __future__ import',
),
pytest.param(
'from __future__ import annotations\n'
Expand Down Expand Up @@ -354,11 +354,6 @@ def test_fix_typing_pep563(s, expected):
assert ret == expected


def test_replaced_for_minimum_version():
ret = _fix_plugins('x: "int"', settings=Settings(min_version=(3, 11)))
assert ret == 'x: int'


@pytest.mark.xfail(
sys.version_info < (3, 8),
reason='posonly args not available in Python3.7',
Expand Down

0 comments on commit f77b9ad

Please sign in to comment.