Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py39+ #973

Merged
merged 1 commit into from
Oct 12, 2024
Merged

py39+ #973

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
rev: v3.13.0
hooks:
- id: reorder-python-imports
args: [--py38-plus, --add-import, 'from __future__ import annotations']
args: [--py39-plus, --add-import, 'from __future__ import annotations']
- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
hooks:
Expand All @@ -26,7 +26,7 @@ repos:
rev: v3.18.0
hooks:
- id: pyupgrade
args: [--py38-plus]
args: [--py39-plus]
- repo: https://github.com/hhatto/autopep8
rev: v2.3.1
hooks:
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_ast_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import warnings
from typing import Container
from collections.abc import Container

from tokenize_rt import Offset

Expand Down
10 changes: 4 additions & 6 deletions pyupgrade/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
import ast
import collections
import pkgutil
from collections.abc import Iterable
from typing import Callable
from typing import Iterable
from typing import List
from typing import NamedTuple
from typing import Protocol
from typing import Tuple
from typing import TypeVar

from tokenize_rt import Offset
from tokenize_rt import Token

from pyupgrade import _plugins

Version = Tuple[int, ...]
Version = tuple[int, ...]


class Settings(NamedTuple):
Expand All @@ -33,8 +31,8 @@ class State(NamedTuple):


AST_T = TypeVar('AST_T', bound=ast.AST)
TokenFunc = Callable[[int, List[Token]], None]
ASTFunc = Callable[[State, AST_T, ast.AST], Iterable[Tuple[Offset, TokenFunc]]]
TokenFunc = Callable[[int, list[Token]], None]
ASTFunc = Callable[[State, AST_T, ast.AST], Iterable[tuple[Offset, TokenFunc]]]

RECORD_FROM_IMPORTS = frozenset((
'__future__',
Expand Down
4 changes: 2 additions & 2 deletions pyupgrade/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import re
import sys
import tokenize
from typing import Match
from typing import Sequence
from collections.abc import Sequence
from re import Match

from tokenize_rt import NON_CODING_TOKENS
from tokenize_rt import parse_string_literal
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/collections_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import functools
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset

Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/constant_fold.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import ast
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset

Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/datetime_utc_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import functools
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset

Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/defauldict_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import functools
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset
from tokenize_rt import Token
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/default_encoding.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import ast
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset
from tokenize_rt import Token
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/dict_literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import functools
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset
from tokenize_rt import Token
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import functools
from typing import Iterable
from collections.abc import Iterable
from typing import NamedTuple

from tokenize_rt import Offset
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/format_locals.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import ast
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset
from tokenize_rt import rfind_string_parts
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/fstrings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import ast
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset
from tokenize_rt import parse_string_literal
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/identity_equality.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import functools
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset
from tokenize_rt import Token
Expand Down
6 changes: 3 additions & 3 deletions pyupgrade/_plugins/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import bisect
import collections
import functools
from typing import Iterable
from typing import Mapping
from collections.abc import Iterable
from collections.abc import Mapping
from typing import NamedTuple

from tokenize_rt import Offset
Expand Down Expand Up @@ -298,7 +298,7 @@
# END GENERATED


@functools.lru_cache(maxsize=None)
@functools.cache
def _for_version(
version: tuple[int, ...],
*,
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/io_open.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import ast
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset
from tokenize_rt import Token
Expand Down
4 changes: 2 additions & 2 deletions pyupgrade/_plugins/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import collections
import contextlib
import functools
from collections.abc import Generator
from collections.abc import Iterable
from typing import Any
from typing import Generator
from typing import Iterable

from tokenize_rt import Offset
from tokenize_rt import Token
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/lru_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import functools
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset
from tokenize_rt import Token
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/metaclass_type.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import ast
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset
from tokenize_rt import Token
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/mock.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import ast
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset
from tokenize_rt import Token
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/native_literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import functools
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset
from tokenize_rt import Token
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/new_style_classes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import ast
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset

Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/open_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ast
import functools
import itertools
from typing import Iterable
from collections.abc import Iterable
from typing import NamedTuple

from tokenize_rt import Offset
Expand Down
13 changes: 6 additions & 7 deletions pyupgrade/_plugins/percent_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import ast
import functools
import re
from typing import Generator
from typing import Iterable
from typing import Match
from collections.abc import Generator
from collections.abc import Iterable
from re import Match
from re import Pattern
from typing import Optional
from typing import Pattern
from typing import Tuple

from tokenize_rt import Offset
from tokenize_rt import Token
Expand All @@ -23,14 +22,14 @@
from pyupgrade._token_helpers import remove_brace
from pyupgrade._token_helpers import victims

PercentFormatPart = Tuple[
PercentFormatPart = tuple[
Optional[str],
Optional[str],
Optional[str],
Optional[str],
str,
]
PercentFormat = Tuple[str, Optional[PercentFormatPart]]
PercentFormat = tuple[str, Optional[PercentFormatPart]]

MAPPING_KEY_RE = re.compile(r'\(([^()]*)\)')
CONVERSION_FLAG_RE = re.compile('[#0+ -]*')
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/set_literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import functools
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset
from tokenize_rt import Token
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/shlex_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import functools
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import NON_CODING_TOKENS
from tokenize_rt import Offset
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/six_base_classes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import ast
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset

Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/six_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import functools
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset
from tokenize_rt import Token
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/six_metaclasses.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import ast
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import NON_CODING_TOKENS
from tokenize_rt import Offset
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/six_remove_decorators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import ast
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset

Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/six_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import functools
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset

Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/subprocess_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import functools
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset
from tokenize_rt import Token
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/type_of_primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import functools
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset
from tokenize_rt import Token
Expand Down
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/typing_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import functools
from typing import Iterable
from collections.abc import Iterable

from tokenize_rt import Offset
from tokenize_rt import Token
Expand Down
4 changes: 2 additions & 2 deletions pyupgrade/_plugins/typing_pep563.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import ast
import functools
import sys
from typing import Iterable
from typing import Sequence
from collections.abc import Iterable
from collections.abc import Sequence

from tokenize_rt import Offset

Expand Down
Loading
Loading