Skip to content

Commit a0f3964

Browse files
authored
Merge pull request #280 from asottile/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2 parents f8af4ed + a07ae32 commit a0f3964

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ repos:
3636
hooks:
3737
- id: flake8
3838
- repo: https://github.com/pre-commit/mirrors-mypy
39-
rev: v1.10.1
39+
rev: v1.11.0
4040
hooks:
4141
- id: mypy

add_trailing_comma/_ast_helpers.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import ast
44
import warnings
5+
from typing import Protocol
56

67
from tokenize_rt import Offset
78

@@ -12,5 +13,12 @@ def ast_parse(contents_text: str) -> ast.Module:
1213
return ast.parse(contents_text.encode())
1314

1415

15-
def ast_to_offset(node: ast.AST) -> Offset:
16+
class _HasOffsetInfo(Protocol):
17+
@property
18+
def lineno(self) -> int: ...
19+
@property
20+
def col_offset(self) -> int: ...
21+
22+
23+
def ast_to_offset(node: _HasOffsetInfo) -> Offset:
1624
return Offset(node.lineno, node.col_offset)

add_trailing_comma/_data.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class State(NamedTuple):
2323
TokenFunc = Callable[[int, list[Token]], None]
2424
ASTFunc = Callable[[State, AST_T], Iterable[tuple[Offset, TokenFunc]]]
2525

26-
FUNCS = collections.defaultdict(list)
26+
FUNCS: ASTCallbackMapping # python/mypy#17566
27+
FUNCS = collections.defaultdict(list) # type: ignore[assignment]
2728

2829

2930
def register(tp: type[AST_T]) -> Callable[[ASTFunc[AST_T]], ASTFunc[AST_T]]:

add_trailing_comma/_plugins/calls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def visit_Call(
3434
state: State,
3535
node: ast.Call,
3636
) -> Iterable[tuple[Offset, TokenFunc]]:
37-
argnodes = [*node.args, *node.keywords]
37+
argnodes: list[ast.expr | ast.keyword] = [*node.args, *node.keywords]
3838
arg_offsets = set()
3939
for argnode in argnodes:
4040
offset = ast_to_offset(argnode)

add_trailing_comma/_plugins/classes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def visit_ClassDef(
3737
# starargs are allowed in py3 class definitions, py35+ allows trailing
3838
# commas. py34 does not, but adding an option for this very obscure
3939
# case seems not worth it.
40-
args = [*node.bases, *node.keywords]
40+
args: list[ast.expr | ast.keyword] = [*node.bases, *node.keywords]
4141
arg_offsets = {ast_to_offset(arg) for arg in args}
4242

4343
if arg_offsets:

0 commit comments

Comments
 (0)