| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,12 +28,13 @@ repos: | |||
| 28 | 28 | rev: v2.31.0 | |
| 29 | 29 | hooks: | |
| 30 | 30 | - id: pyupgrade | |
| 31 | - args: [--py36-plus] | ||
| 31 | + args: [--py37-plus] | ||
| 32 | 32 | - repo: https://github.com/asottile/reorder_python_imports | |
| 33 | 33 | rev: v2.6.0 | |
| 34 | 34 | hooks: | |
| 35 | 35 | - id: reorder-python-imports | |
| 36 | - args: [--py3-plus] | ||
| 36 | + args: [--py37-plus, --add-import, 'from __future__ import annotations'] | ||
| 37 | + exclude: ^testing/resources/python3_hooks_repo/ | ||
| 37 | 38 | - repo: https://github.com/asottile/add-trailing-comma | |
| 38 | 39 | rev: v2.2.1 | |
| 39 | 40 | hooks: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,7 +50,7 @@ jobs: | |||
| 50 | 50 | displayName: install R | |
| 51 | 51 | - template: job--python-tox.yml@asottile | |
| 52 | 52 | parameters: | |
| 53 | - toxenvs: [pypy3, py36, py37, py38, py39] | ||
| 53 | + toxenvs: [py37, py38, py39] | ||
| 54 | 54 | os: linux | |
| 55 | 55 | pre_test: | |
| 56 | 56 | - task: UseRubyVersion@0 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,5 @@ | |||
| 1 | + from __future__ import annotations | ||
| 2 | + | ||
| 1 | 3 | from pre_commit.main import main | |
| 2 | 4 | ||
| 3 | 5 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,12 @@ | |||
| 1 | + from __future__ import annotations | ||
| 2 | + | ||
| 1 | 3 | import argparse | |
| 2 | 4 | import functools | |
| 3 | 5 | import logging | |
| 4 | 6 | import re | |
| 5 | 7 | import shlex | |
| 6 | 8 | import sys | |
| 7 | 9 | from typing import Any | |
| 8 | - from typing import Dict | ||
| 9 | - from typing import Optional | ||
| 10 | 10 | from typing import Sequence | |
| 11 | 11 | ||
| 12 | 12 | import cfgv | |
@@ -95,7 +95,7 @@ class InvalidManifestError(FatalError): | |||
| 95 | 95 | ) | |
| 96 | 96 | ||
| 97 | 97 | ||
| 98 | - def validate_manifest_main(argv: Optional[Sequence[str]] = None) -> int: | ||
| 98 | + def validate_manifest_main(argv: Sequence[str] | None = None) -> int: | ||
| 99 | 99 | parser = _make_argparser('Manifest filenames.') | |
| 100 | 100 | args = parser.parse_args(argv) | |
| 101 | 101 | ||
@@ -116,7 +116,7 @@ def validate_manifest_main(argv: Optional[Sequence[str]] = None) -> int: | |||
| 116 | 116 | ||
| 117 | 117 | # should inherit from cfgv.Conditional if sha support is dropped | |
| 118 | 118 | class WarnMutableRev(cfgv.ConditionalOptional): | |
| 119 | - def check(self, dct: Dict[str, Any]) -> None: | ||
| 119 | + def check(self, dct: dict[str, Any]) -> None: | ||
| 120 | 120 | super().check(dct) | |
| 121 | 121 | ||
| 122 | 122 | if self.key in dct: | |
@@ -135,7 +135,7 @@ def check(self, dct: Dict[str, Any]) -> None: | |||
| 135 | 135 | ||
| 136 | 136 | ||
| 137 | 137 | class OptionalSensibleRegexAtHook(cfgv.OptionalNoDefault): | |
| 138 | - def check(self, dct: Dict[str, Any]) -> None: | ||
| 138 | + def check(self, dct: dict[str, Any]) -> None: | ||
| 139 | 139 | super().check(dct) | |
| 140 | 140 | ||
| 141 | 141 | if '/*' in dct.get(self.key, ''): | |
@@ -154,7 +154,7 @@ def check(self, dct: Dict[str, Any]) -> None: | |||
| 154 | 154 | ||
| 155 | 155 | ||
| 156 | 156 | class OptionalSensibleRegexAtTop(cfgv.OptionalNoDefault): | |
| 157 | - def check(self, dct: Dict[str, Any]) -> None: | ||
| 157 | + def check(self, dct: dict[str, Any]) -> None: | ||
| 158 | 158 | super().check(dct) | |
| 159 | 159 | ||
| 160 | 160 | if '/*' in dct.get(self.key, ''): | |
@@ -183,7 +183,7 @@ def _cond(key: str) -> cfgv.Conditional: | |||
| 183 | 183 | ensure_absent=True, | |
| 184 | 184 | ) | |
| 185 | 185 | ||
| 186 | - def check(self, dct: Dict[str, Any]) -> None: | ||
| 186 | + def check(self, dct: dict[str, Any]) -> None: | ||
| 187 | 187 | if dct.get('repo') in {LOCAL, META}: | |
| 188 | 188 | self._cond('rev').check(dct) | |
| 189 | 189 | self._cond('sha').check(dct) | |
@@ -194,7 +194,7 @@ def check(self, dct: Dict[str, Any]) -> None: | |||
| 194 | 194 | else: | |
| 195 | 195 | self._cond('rev').check(dct) | |
| 196 | 196 | ||
| 197 | - def apply_default(self, dct: Dict[str, Any]) -> None: | ||
| 197 | + def apply_default(self, dct: dict[str, Any]) -> None: | ||
| 198 | 198 | if 'sha' in dct: | |
| 199 | 199 | dct['rev'] = dct.pop('sha') | |
| 200 | 200 | ||
@@ -212,15 +212,15 @@ def _entry(modname: str) -> str: | |||
| 212 | 212 | def warn_unknown_keys_root( | |
| 213 | 213 | extra: Sequence[str], | |
| 214 | 214 | orig_keys: Sequence[str], | |
| 215 | - dct: Dict[str, str], | ||
| 215 | + dct: dict[str, str], | ||
| 216 | 216 | ) -> None: | |
| 217 | 217 | logger.warning(f'Unexpected key(s) present at root: {", ".join(extra)}') | |
| 218 | 218 | ||
| 219 | 219 | ||
| 220 | 220 | def warn_unknown_keys_repo( | |
| 221 | 221 | extra: Sequence[str], | |
| 222 | 222 | orig_keys: Sequence[str], | |
| 223 | - dct: Dict[str, str], | ||
| 223 | + dct: dict[str, str], | ||
| 224 | 224 | ) -> None: | |
| 225 | 225 | logger.warning( | |
| 226 | 226 | f'Unexpected key(s) present on {dct["repo"]}: {", ".join(extra)}', | |
@@ -253,7 +253,7 @@ def warn_unknown_keys_repo( | |||
| 253 | 253 | ||
| 254 | 254 | ||
| 255 | 255 | class NotAllowed(cfgv.OptionalNoDefault): | |
| 256 | - def check(self, dct: Dict[str, Any]) -> None: | ||
| 256 | + def check(self, dct: dict[str, Any]) -> None: | ||
| 257 | 257 | if self.key in dct: | |
| 258 | 258 | raise cfgv.ValidationError(f'{self.key!r} cannot be overridden') | |
| 259 | 259 | ||
@@ -377,7 +377,7 @@ class InvalidConfigError(FatalError): | |||
| 377 | 377 | pass | |
| 378 | 378 | ||
| 379 | 379 | ||
| 380 | - def ordered_load_normalize_legacy_config(contents: str) -> Dict[str, Any]: | ||
| 380 | + def ordered_load_normalize_legacy_config(contents: str) -> dict[str, Any]: | ||
| 381 | 381 | data = yaml_load(contents) | |
| 382 | 382 | if isinstance(data, list): | |
| 383 | 383 | logger.warning( | |
@@ -398,7 +398,7 @@ def ordered_load_normalize_legacy_config(contents: str) -> Dict[str, Any]: | |||
| 398 | 398 | ) | |
| 399 | 399 | ||
| 400 | 400 | ||
| 401 | - def validate_config_main(argv: Optional[Sequence[str]] = None) -> int: | ||
| 401 | + def validate_config_main(argv: Sequence[str] | None = None) -> int: | ||
| 402 | 402 | parser = _make_argparser('Config filenames.') | |
| 403 | 403 | args = parser.parse_args(argv) | |
| 404 | 404 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,5 @@ | |||
| 1 | + from __future__ import annotations | ||
| 2 | + | ||
| 1 | 3 | import argparse | |
| 2 | 4 | import os | |
| 3 | 5 | import sys | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,10 @@ | |||
| 1 | + from __future__ import annotations | ||
| 2 | + | ||
| 1 | 3 | import os.path | |
| 2 | 4 | import re | |
| 3 | 5 | from typing import Any | |
| 4 | - from typing import Dict | ||
| 5 | - from typing import List | ||
| 6 | 6 | from typing import NamedTuple | |
| 7 | - from typing import Optional | ||
| 8 | 7 | from typing import Sequence | |
| 9 | - from typing import Tuple | ||
| 10 | 8 | ||
| 11 | 9 | import pre_commit.constants as C | |
| 12 | 10 | from pre_commit import git | |
@@ -29,13 +27,13 @@ | |||
| 29 | 27 | class RevInfo(NamedTuple): | |
| 30 | 28 | repo: str | |
| 31 | 29 | rev: str | |
| 32 | - frozen: Optional[str] | ||
| 30 | + frozen: str | None | ||
| 33 | 31 | ||
| 34 | 32 | @classmethod | |
| 35 | - def from_config(cls, config: Dict[str, Any]) -> 'RevInfo': | ||
| 33 | + def from_config(cls, config: dict[str, Any]) -> RevInfo: | ||
| 36 | 34 | return cls(config['repo'], config['rev'], None) | |
| 37 | 35 | ||
| 38 | - def update(self, tags_only: bool, freeze: bool) -> 'RevInfo': | ||
| 36 | + def update(self, tags_only: bool, freeze: bool) -> RevInfo: | ||
| 39 | 37 | git_cmd = ('git', *git.NO_FS_MONITOR) | |
| 40 | 38 | ||
| 41 | 39 | if tags_only: | |
@@ -76,7 +74,7 @@ class RepositoryCannotBeUpdatedError(RuntimeError): | |||
| 76 | 74 | ||
| 77 | 75 | ||
| 78 | 76 | def _check_hooks_still_exist_at_rev( | |
| 79 | - repo_config: Dict[str, Any], | ||
| 77 | + repo_config: dict[str, Any], | ||
| 80 | 78 | info: RevInfo, | |
| 81 | 79 | store: Store, | |
| 82 | 80 | ) -> None: | |
@@ -101,9 +99,9 @@ def _check_hooks_still_exist_at_rev( | |||
| 101 | 99 | ||
| 102 | 100 | def _original_lines( | |
| 103 | 101 | path: str, | |
| 104 | - rev_infos: List[Optional[RevInfo]], | ||
| 102 | + rev_infos: list[RevInfo | None], | ||
| 105 | 103 | retry: bool = False, | |
| 106 | - ) -> Tuple[List[str], List[int]]: | ||
| 104 | + ) -> tuple[list[str], list[int]]: | ||
| 107 | 105 | """detect `rev:` lines or reformat the file""" | |
| 108 | 106 | with open(path, newline='') as f: | |
| 109 | 107 | original = f.read() | |
@@ -120,7 +118,7 @@ def _original_lines( | |||
| 120 | 118 | return _original_lines(path, rev_infos, retry=True) | |
| 121 | 119 | ||
| 122 | 120 | ||
| 123 | - def _write_new_config(path: str, rev_infos: List[Optional[RevInfo]]) -> None: | ||
| 121 | + def _write_new_config(path: str, rev_infos: list[RevInfo | None]) -> None: | ||
| 124 | 122 | lines, idxs = _original_lines(path, rev_infos) | |
| 125 | 123 | ||
| 126 | 124 | for idx, rev_info in zip(idxs, rev_infos): | |
@@ -152,7 +150,7 @@ def autoupdate( | |||
| 152 | 150 | """Auto-update the pre-commit config to the latest versions of repos.""" | |
| 153 | 151 | migrate_config(config_file, quiet=True) | |
| 154 | 152 | retv = 0 | |
| 155 | - rev_infos: List[Optional[RevInfo]] = [] | ||
| 153 | + rev_infos: list[RevInfo | None] = [] | ||
| 156 | 154 | changed = False | |
| 157 | 155 | ||
| 158 | 156 | config = load_config(config_file) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,5 @@ | |||
| 1 | + from __future__ import annotations | ||
| 2 | + | ||
| 1 | 3 | import os.path | |
| 2 | 4 | ||
| 3 | 5 | from pre_commit import output | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,7 @@ | |||
| 1 | + from __future__ import annotations | ||
| 2 | + | ||
| 1 | 3 | import os.path | |
| 2 | 4 | from typing import Any | |
| 3 | - from typing import Dict | ||
| 4 | - from typing import Set | ||
| 5 | - from typing import Tuple | ||
| 6 | 5 | ||
| 7 | 6 | import pre_commit.constants as C | |
| 8 | 7 | from pre_commit import output | |
@@ -17,9 +16,9 @@ | |||
| 17 | 16 | ||
| 18 | 17 | def _mark_used_repos( | |
| 19 | 18 | store: Store, | |
| 20 | - all_repos: Dict[Tuple[str, str], str], | ||
| 21 | - unused_repos: Set[Tuple[str, str]], | ||
| 22 | - repo: Dict[str, Any], | ||
| 19 | + all_repos: dict[tuple[str, str], str], | ||
| 20 | + unused_repos: set[tuple[str, str]], | ||
| 21 | + repo: dict[str, Any], | ||
| 23 | 22 | ) -> None: | |
| 24 | 23 | if repo['repo'] == META: | |
| 25 | 24 | return | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,10 @@ | |||
| 1 | + from __future__ import annotations | ||
| 2 | + | ||
| 1 | 3 | import argparse | |
| 2 | 4 | import os.path | |
| 3 | 5 | import subprocess | |
| 4 | 6 | import sys | |
| 5 | - from typing import Optional | ||
| 6 | 7 | from typing import Sequence | |
| 7 | - from typing import Tuple | ||
| 8 | 8 | ||
| 9 | 9 | from pre_commit.commands.run import run | |
| 10 | 10 | from pre_commit.envcontext import envcontext | |
@@ -18,7 +18,7 @@ def _run_legacy( | |||
| 18 | 18 | hook_type: str, | |
| 19 | 19 | hook_dir: str, | |
| 20 | 20 | args: Sequence[str], | |
| 21 | - ) -> Tuple[int, bytes]: | ||
| 21 | + ) -> tuple[int, bytes]: | ||
| 22 | 22 | if os.environ.get('PRE_COMMIT_RUNNING_LEGACY'): | |
| 23 | 23 | raise SystemExit( | |
| 24 | 24 | f"bug: pre-commit's script is installed in migration mode\n" | |
@@ -69,16 +69,16 @@ def _ns( | |||
| 69 | 69 | color: bool, | |
| 70 | 70 | *, | |
| 71 | 71 | all_files: bool = False, | |
| 72 | - remote_branch: Optional[str] = None, | ||
| 73 | - local_branch: Optional[str] = None, | ||
| 74 | - from_ref: Optional[str] = None, | ||
| 75 | - to_ref: Optional[str] = None, | ||
| 76 | - remote_name: Optional[str] = None, | ||
| 77 | - remote_url: Optional[str] = None, | ||
| 78 | - commit_msg_filename: Optional[str] = None, | ||
| 79 | - checkout_type: Optional[str] = None, | ||
| 80 | - is_squash_merge: Optional[str] = None, | ||
| 81 | - rewrite_command: Optional[str] = None, | ||
| 72 | + remote_branch: str | None = None, | ||
| 73 | + local_branch: str | None = None, | ||
| 74 | + from_ref: str | None = None, | ||
| 75 | + to_ref: str | None = None, | ||
| 76 | + remote_name: str | None = None, | ||
| 77 | + remote_url: str | None = None, | ||
| 78 | + commit_msg_filename: str | None = None, | ||
| 79 | + checkout_type: str | None = None, | ||
| 80 | + is_squash_merge: str | None = None, | ||
| 81 | + rewrite_command: str | None = None, | ||
| 82 | 82 | ) -> argparse.Namespace: | |
| 83 | 83 | return argparse.Namespace( | |
| 84 | 84 | color=color, | |
@@ -109,7 +109,7 @@ def _pre_push_ns( | |||
| 109 | 109 | color: bool, | |
| 110 | 110 | args: Sequence[str], | |
| 111 | 111 | stdin: bytes, | |
| 112 | - ) -> Optional[argparse.Namespace]: | ||
| 112 | + ) -> argparse.Namespace | None: | ||
| 113 | 113 | remote_name = args[0] | |
| 114 | 114 | remote_url = args[1] | |
| 115 | 115 | ||
@@ -197,7 +197,7 @@ def _run_ns( | |||
| 197 | 197 | color: bool, | |
| 198 | 198 | args: Sequence[str], | |
| 199 | 199 | stdin: bytes, | |
| 200 | - ) -> Optional[argparse.Namespace]: | ||
| 200 | + ) -> argparse.Namespace | None: | ||
| 201 | 201 | _check_args_length(hook_type, args) | |
| 202 | 202 | if hook_type == 'pre-push': | |
| 203 | 203 | return _pre_push_ns(color, args, stdin) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,5 @@ | |||
| 1 | + from __future__ import annotations | ||
| 2 | + | ||
| 1 | 3 | import logging | |
| 2 | 4 | import os.path | |
| 3 | 5 | from typing import Sequence | |
| Back | FazBrowse Home | New Git URL |
0 commit comments