Skip to content

Commit b88cf9f

Browse files
committed
Bump pep8-naming to 0.15.*
Closes: python#13906
1 parent 12ef43c commit b88cf9f

File tree

2 files changed

+46
-32
lines changed

2 files changed

+46
-32
lines changed

stubs/pep8-naming/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = "0.14.*"
1+
version = "0.15.*"
22
upstream_repository = "https://github.com/PyCQA/pep8-naming"

stubs/pep8-naming/pep8ext_naming.pyi

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import argparse
22
import ast
3+
import enum
34
import optparse
45
from collections import deque
56
from collections.abc import Callable, Generator, Iterable, Sequence
6-
from typing import Final, Literal
7+
from typing import Any, Final, Literal
78
from typing_extensions import Self
89

910
__version__: Final[str]
@@ -13,22 +14,29 @@ METACLASS_BASES: Final[frozenset[Literal["type", "ABCMeta"]]]
1314
METHOD_CONTAINER_NODES: Final[set[ast.AST]]
1415
FUNC_NODES: Final[tuple[type[ast.FunctionDef], type[ast.AsyncFunctionDef]]]
1516

16-
class _ASTCheckMeta(type):
17-
codes: tuple[str, ...]
17+
class BaseASTCheck:
1818
all: list[BaseASTCheck]
19-
def __init__(cls, class_name: str, bases: tuple[object, ...], namespace: Iterable[str]) -> None: ...
20-
21-
class BaseASTCheck(metaclass=_ASTCheckMeta):
2219
codes: tuple[str, ...]
23-
all: list[BaseASTCheck]
20+
def __init_subclass__(cls, **kwargs: Any) -> None: ...
2421
def err(self, node: ast.AST, code: str, **kwargs: str) -> tuple[int, int, str, Self]: ...
2522

23+
class NameSet(frozenset[str]):
24+
def __new__(cls, iterable: Iterable[str]) -> Self: ...
25+
def __contains__(self, item: object, /) -> bool: ...
26+
27+
@enum.unique
28+
class FunctionType(enum.Enum):
29+
CLASSMETHOD = "classmethod"
30+
STATICMETHOD = "staticmethod"
31+
FUNCTION = "function"
32+
METHOD = "method"
33+
2634
class NamingChecker:
2735
name: str
2836
version: str
2937
visitors: Sequence[BaseASTCheck]
30-
decorator_to_type: dict[str, Literal["classmethod", "staticmethod"]]
31-
ignore_names: frozenset[str]
38+
decorator_to_type: dict[str, Literal[FunctionType.CLASSMETHOD, FunctionType.STATICMETHOD]]
39+
ignored: NameSet
3240
def __init__(self, tree: ast.AST, filename: str) -> None: ...
3341
@classmethod
3442
def add_options(cls, parser: optparse.OptionParser) -> None: ...
@@ -38,7 +46,9 @@ class NamingChecker:
3846
def visit_tree(self, node: ast.AST, parents: deque[ast.AST]) -> Generator[tuple[int, int, str, Self]]: ...
3947
def visit_node(self, node: ast.AST, parents: Sequence[ast.AST]) -> Generator[tuple[int, int, str, Self]]: ...
4048
def tag_class_functions(self, cls_node: ast.ClassDef) -> None: ...
41-
def set_function_nodes_types(self, nodes: Iterable[ast.AST], ismetaclass: bool, late_decoration: dict[str, str]) -> None: ...
49+
def set_function_nodes_types(
50+
self, nodes: Iterable[ast.AST], ismetaclass: bool, late_decoration: dict[str, FunctionType]
51+
) -> None: ...
4252
@classmethod
4353
def find_decorator_name(cls, d: ast.Expr) -> str: ...
4454
@staticmethod
@@ -53,7 +63,7 @@ class ClassNameCheck(BaseASTCheck):
5363
@classmethod
5464
def superclass_names(cls, name: str, parents: Sequence[ast.AST], _names: set[str] | None = None) -> set[str]: ...
5565
def visit_classdef(
56-
self, node: ast.ClassDef, parents: Sequence[ast.AST], ignore: Iterable[str] | None = None
66+
self, node: ast.ClassDef, parents: Sequence[ast.AST], ignored: NameSet
5767
) -> Generator[tuple[int, int, str, Self]]: ...
5868

5969
class FunctionNameCheck(BaseASTCheck):
@@ -63,10 +73,10 @@ class FunctionNameCheck(BaseASTCheck):
6373
@staticmethod
6474
def has_override_decorator(node: ast.FunctionDef | ast.AsyncFunctionDef) -> bool: ...
6575
def visit_functiondef(
66-
self, node: ast.FunctionDef, parents: Sequence[ast.AST], ignore: Iterable[str] | None = None
76+
self, node: ast.FunctionDef, parents: Sequence[ast.AST], ignored: NameSet
6777
) -> Generator[tuple[int, int, str, Self]]: ...
6878
def visit_asyncfunctiondef(
69-
self, node: ast.AsyncFunctionDef, parents: Sequence[ast.AST], ignore: Iterable[str] | None = None
79+
self, node: ast.AsyncFunctionDef, parents: Sequence[ast.AST], ignored: NameSet
7080
) -> Generator[tuple[int, int, str, Self]]: ...
7181

7282
class FunctionArgNamesCheck(BaseASTCheck):
@@ -75,10 +85,10 @@ class FunctionArgNamesCheck(BaseASTCheck):
7585
N804: str
7686
N805: str
7787
def visit_functiondef(
78-
self, node: ast.FunctionDef, parents: Sequence[ast.AST], ignore: Iterable[str] | None = None
88+
self, node: ast.FunctionDef, parents: Sequence[ast.AST], ignored: NameSet
7989
) -> Generator[tuple[int, int, str, Self]]: ...
8090
def visit_asyncfunctiondef(
81-
self, node: ast.AsyncFunctionDef, parents: Sequence[ast.AST], ignore: Iterable[str] | None = None
91+
self, node: ast.AsyncFunctionDef, parents: Sequence[ast.AST], ignored: NameSet
8292
) -> Generator[tuple[int, int, str, Self]]: ...
8393

8494
class ImportAsCheck(BaseASTCheck):
@@ -89,10 +99,10 @@ class ImportAsCheck(BaseASTCheck):
8999
N814: str
90100
N817: str
91101
def visit_importfrom(
92-
self, node: ast.ImportFrom, parents: Sequence[ast.AST], ignore: Iterable[str] | None = None
102+
self, node: ast.ImportFrom, parents: Sequence[ast.AST], ignored: NameSet
93103
) -> Generator[tuple[int, int, str, Self]]: ...
94104
def visit_import(
95-
self, node: ast.Import, parents: Sequence[ast.AST], ignore: Iterable[str] | None = None
105+
self, node: ast.Import, parents: Sequence[ast.AST], ignored: NameSet
96106
) -> Generator[tuple[int, int, str, Self]]: ...
97107

98108
class VariablesCheck(BaseASTCheck):
@@ -103,40 +113,38 @@ class VariablesCheck(BaseASTCheck):
103113
@staticmethod
104114
def is_namedtupe(node_value: ast.AST) -> bool: ...
105115
def visit_assign(
106-
self, node: ast.Assign, parents: Sequence[ast.AST], ignore: Iterable[str] | None = None
116+
self, node: ast.Assign, parents: Sequence[ast.AST], ignored: NameSet
107117
) -> Generator[tuple[int, int, str, Self]]: ...
108118
def visit_namedexpr(
109-
self, node: ast.NamedExpr, parents: Sequence[ast.AST], ignore: Iterable[str]
119+
self, node: ast.NamedExpr, parents: Sequence[ast.AST], ignored: NameSet
110120
) -> Generator[tuple[int, int, str, Self]]: ...
111121
def visit_annassign(
112-
self, node: ast.AnnAssign, parents: Sequence[ast.AST], ignore: Iterable[str]
122+
self, node: ast.AnnAssign, parents: Sequence[ast.AST], ignored: NameSet
113123
) -> Generator[tuple[int, int, str, Self]]: ...
114124
def visit_with(
115-
self, node: ast.With, parents: Sequence[ast.AST], ignore: Iterable[str]
125+
self, node: ast.With, parents: Sequence[ast.AST], ignored: NameSet
116126
) -> Generator[tuple[int, int, str, Self]]: ...
117127
def visit_asyncwith(
118-
self, node: ast.AsyncWith, parents: Sequence[ast.AST], ignore: Iterable[str]
119-
) -> Generator[tuple[int, int, str, Self]]: ...
120-
def visit_for(
121-
self, node: ast.For, parents: Sequence[ast.AST], ignore: Iterable[str]
128+
self, node: ast.AsyncWith, parents: Sequence[ast.AST], ignored: NameSet
122129
) -> Generator[tuple[int, int, str, Self]]: ...
130+
def visit_for(self, node: ast.For, parents: Sequence[ast.AST], ignored: NameSet) -> Generator[tuple[int, int, str, Self]]: ...
123131
def visit_asyncfor(
124-
self, node: ast.AsyncFor, parents: Sequence[ast.AST], ignore: Iterable[str]
132+
self, node: ast.AsyncFor, parents: Sequence[ast.AST], ignored: NameSet
125133
) -> Generator[tuple[int, int, str, Self]]: ...
126134
def visit_excepthandler(
127-
self, node: ast.ExceptHandler, parents: Sequence[ast.AST], ignore: Iterable[str]
135+
self, node: ast.ExceptHandler, parents: Sequence[ast.AST], ignored: NameSet
128136
) -> Generator[tuple[int, int, str, Self]]: ...
129137
def visit_generatorexp(
130-
self, node: ast.GeneratorExp, parents: Sequence[ast.AST], ignore: Iterable[str]
138+
self, node: ast.GeneratorExp, parents: Sequence[ast.AST], ignored: NameSet
131139
) -> Generator[tuple[int, int, str, Self]]: ...
132140
def visit_listcomp(
133-
self, node: ast.ListComp, parents: Sequence[ast.AST], ignore: Iterable[str]
141+
self, node: ast.ListComp, parents: Sequence[ast.AST], ignored: NameSet
134142
) -> Generator[tuple[int, int, str, Self]]: ...
135143
def visit_dictcomp(
136-
self, node: ast.DictComp, parents: Sequence[ast.AST], ignore: Iterable[str]
144+
self, node: ast.DictComp, parents: Sequence[ast.AST], ignored: NameSet
137145
) -> Generator[tuple[int, int, str, Self]]: ...
138146
def visit_setcomp(
139-
self, node: ast.SetComp, parents: Sequence[ast.AST], ignore: Iterable[str]
147+
self, node: ast.SetComp, parents: Sequence[ast.AST], ignored: NameSet
140148
) -> Generator[tuple[int, int, str, Self]]: ...
141149
@staticmethod
142150
def global_variable_check(name: str) -> Literal["N816"] | None: ...
@@ -145,4 +153,10 @@ class VariablesCheck(BaseASTCheck):
145153
@staticmethod
146154
def function_variable_check(func: Callable[..., object], var_name: str) -> Literal["N806"] | None: ...
147155

156+
class TypeVarNameCheck(BaseASTCheck):
157+
N808: str
158+
def visit_module(
159+
self, node: ast.Module, parents: Sequence[ast.AST], ignored: NameSet
160+
) -> Generator[tuple[int, int, str, Self]]: ...
161+
148162
def is_mixed_case(name: str) -> bool: ...

0 commit comments

Comments
 (0)