Skip to content

Commit dd4ef75

Browse files
authored
Bump pep8-naming to 0.15.* (#13908)
1 parent a55309b commit dd4ef75

File tree

2 files changed

+63
-48
lines changed

2 files changed

+63
-48
lines changed

stubs/pep8-naming/METADATA.toml

+1-1
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

+62-47
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
5-
from collections.abc import Callable, Generator, Iterable, Sequence
6-
from typing import Final, Literal
6+
from collections.abc import Callable, Generator, Iterable, Iterator, Sequence
7+
from typing import Any, Final, Literal
78
from typing_extensions import Self
89

910
__version__: Final[str]
@@ -13,22 +14,30 @@ 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+
# Per convention, unknown kwargs are passed to the super-class. See there for the types.
21+
def __init_subclass__(cls, **kwargs: Any) -> None: ...
2422
def err(self, node: ast.AST, code: str, **kwargs: str) -> tuple[int, int, str, Self]: ...
2523

24+
class NameSet(frozenset[str]):
25+
def __new__(cls, iterable: Iterable[str]) -> Self: ...
26+
def __contains__(self, item: object, /) -> bool: ...
27+
28+
@enum.unique
29+
class FunctionType(enum.Enum):
30+
CLASSMETHOD = "classmethod"
31+
STATICMETHOD = "staticmethod"
32+
FUNCTION = "function"
33+
METHOD = "method"
34+
2635
class NamingChecker:
2736
name: str
2837
version: str
2938
visitors: Sequence[BaseASTCheck]
30-
decorator_to_type: dict[str, Literal["classmethod", "staticmethod"]]
31-
ignore_names: frozenset[str]
39+
decorator_to_type: dict[str, FunctionType]
40+
ignored: NameSet
3241
def __init__(self, tree: ast.AST, filename: str) -> None: ...
3342
@classmethod
3443
def add_options(cls, parser: optparse.OptionParser) -> None: ...
@@ -38,105 +47,105 @@ class NamingChecker:
3847
def visit_tree(self, node: ast.AST, parents: deque[ast.AST]) -> Generator[tuple[int, int, str, Self]]: ...
3948
def visit_node(self, node: ast.AST, parents: Sequence[ast.AST]) -> Generator[tuple[int, int, str, Self]]: ...
4049
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: ...
50+
def set_function_nodes_types(
51+
self, nodes: Iterator[ast.AST], ismetaclass: bool, late_decoration: dict[str, FunctionType]
52+
) -> None: ...
4253
@classmethod
4354
def find_decorator_name(cls, d: ast.Expr) -> str: ...
4455
@staticmethod
4556
def find_global_defs(func_def_node: ast.AST) -> None: ...
4657

4758
class ClassNameCheck(BaseASTCheck):
4859
codes: tuple[Literal["N801"], Literal["N818"]]
49-
N801: str
50-
N818: str
60+
N801: Final[str]
61+
N818: Final[str]
5162
@classmethod
5263
def get_classdef(cls, name: str, parents: Sequence[ast.AST]) -> ast.ClassDef | None: ...
5364
@classmethod
5465
def superclass_names(cls, name: str, parents: Sequence[ast.AST], _names: set[str] | None = None) -> set[str]: ...
5566
def visit_classdef(
56-
self, node: ast.ClassDef, parents: Sequence[ast.AST], ignore: Iterable[str] | None = None
67+
self, node: ast.ClassDef, parents: Sequence[ast.AST], ignored: NameSet
5768
) -> Generator[tuple[int, int, str, Self]]: ...
5869

5970
class FunctionNameCheck(BaseASTCheck):
6071
codes: tuple[Literal["N802"], Literal["N807"]]
61-
N802: str
62-
N807: str
72+
N802: Final[str]
73+
N807: Final[str]
6374
@staticmethod
6475
def has_override_decorator(node: ast.FunctionDef | ast.AsyncFunctionDef) -> bool: ...
6576
def visit_functiondef(
66-
self, node: ast.FunctionDef, parents: Sequence[ast.AST], ignore: Iterable[str] | None = None
77+
self, node: ast.FunctionDef, parents: Sequence[ast.AST], ignored: NameSet
6778
) -> Generator[tuple[int, int, str, Self]]: ...
6879
def visit_asyncfunctiondef(
69-
self, node: ast.AsyncFunctionDef, parents: Sequence[ast.AST], ignore: Iterable[str] | None = None
80+
self, node: ast.AsyncFunctionDef, parents: Sequence[ast.AST], ignored: NameSet
7081
) -> Generator[tuple[int, int, str, Self]]: ...
7182

7283
class FunctionArgNamesCheck(BaseASTCheck):
7384
codes: tuple[Literal["N803"], Literal["N804"], Literal["N805"]]
74-
N803: str
75-
N804: str
76-
N805: str
85+
N803: Final[str]
86+
N804: Final[str]
87+
N805: Final[str]
7788
def visit_functiondef(
78-
self, node: ast.FunctionDef, parents: Sequence[ast.AST], ignore: Iterable[str] | None = None
89+
self, node: ast.FunctionDef, parents: Sequence[ast.AST], ignored: NameSet
7990
) -> Generator[tuple[int, int, str, Self]]: ...
8091
def visit_asyncfunctiondef(
81-
self, node: ast.AsyncFunctionDef, parents: Sequence[ast.AST], ignore: Iterable[str] | None = None
92+
self, node: ast.AsyncFunctionDef, parents: Sequence[ast.AST], ignored: NameSet
8293
) -> Generator[tuple[int, int, str, Self]]: ...
8394

8495
class ImportAsCheck(BaseASTCheck):
8596
codes: tuple[Literal["N811"], Literal["N812"], Literal["N813"], Literal["N814"], Literal["N817"]]
86-
N811: str
87-
N812: str
88-
N813: str
89-
N814: str
90-
N817: str
97+
N811: Final[str]
98+
N812: Final[str]
99+
N813: Final[str]
100+
N814: Final[str]
101+
N817: Final[str]
91102
def visit_importfrom(
92-
self, node: ast.ImportFrom, parents: Sequence[ast.AST], ignore: Iterable[str] | None = None
103+
self, node: ast.ImportFrom, parents: Sequence[ast.AST], ignored: NameSet
93104
) -> Generator[tuple[int, int, str, Self]]: ...
94105
def visit_import(
95-
self, node: ast.Import, parents: Sequence[ast.AST], ignore: Iterable[str] | None = None
106+
self, node: ast.Import, parents: Sequence[ast.AST], ignored: NameSet
96107
) -> Generator[tuple[int, int, str, Self]]: ...
97108

98109
class VariablesCheck(BaseASTCheck):
99110
codes: tuple[Literal["N806"], Literal["N815"], Literal["N816"]]
100-
N806: str
101-
N815: str
102-
N816: str
111+
N806: Final[str]
112+
N815: Final[str]
113+
N816: Final[str]
103114
@staticmethod
104115
def is_namedtupe(node_value: ast.AST) -> bool: ...
105116
def visit_assign(
106-
self, node: ast.Assign, parents: Sequence[ast.AST], ignore: Iterable[str] | None = None
117+
self, node: ast.Assign, parents: Sequence[ast.AST], ignored: NameSet
107118
) -> Generator[tuple[int, int, str, Self]]: ...
108119
def visit_namedexpr(
109-
self, node: ast.NamedExpr, parents: Sequence[ast.AST], ignore: Iterable[str]
120+
self, node: ast.NamedExpr, parents: Sequence[ast.AST], ignored: NameSet
110121
) -> Generator[tuple[int, int, str, Self]]: ...
111122
def visit_annassign(
112-
self, node: ast.AnnAssign, parents: Sequence[ast.AST], ignore: Iterable[str]
123+
self, node: ast.AnnAssign, parents: Sequence[ast.AST], ignored: NameSet
113124
) -> Generator[tuple[int, int, str, Self]]: ...
114125
def visit_with(
115-
self, node: ast.With, parents: Sequence[ast.AST], ignore: Iterable[str]
126+
self, node: ast.With, parents: Sequence[ast.AST], ignored: NameSet
116127
) -> Generator[tuple[int, int, str, Self]]: ...
117128
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]
129+
self, node: ast.AsyncWith, parents: Sequence[ast.AST], ignored: NameSet
122130
) -> Generator[tuple[int, int, str, Self]]: ...
131+
def visit_for(self, node: ast.For, parents: Sequence[ast.AST], ignored: NameSet) -> Generator[tuple[int, int, str, Self]]: ...
123132
def visit_asyncfor(
124-
self, node: ast.AsyncFor, parents: Sequence[ast.AST], ignore: Iterable[str]
133+
self, node: ast.AsyncFor, parents: Sequence[ast.AST], ignored: NameSet
125134
) -> Generator[tuple[int, int, str, Self]]: ...
126135
def visit_excepthandler(
127-
self, node: ast.ExceptHandler, parents: Sequence[ast.AST], ignore: Iterable[str]
136+
self, node: ast.ExceptHandler, parents: Sequence[ast.AST], ignored: NameSet
128137
) -> Generator[tuple[int, int, str, Self]]: ...
129138
def visit_generatorexp(
130-
self, node: ast.GeneratorExp, parents: Sequence[ast.AST], ignore: Iterable[str]
139+
self, node: ast.GeneratorExp, parents: Sequence[ast.AST], ignored: NameSet
131140
) -> Generator[tuple[int, int, str, Self]]: ...
132141
def visit_listcomp(
133-
self, node: ast.ListComp, parents: Sequence[ast.AST], ignore: Iterable[str]
142+
self, node: ast.ListComp, parents: Sequence[ast.AST], ignored: NameSet
134143
) -> Generator[tuple[int, int, str, Self]]: ...
135144
def visit_dictcomp(
136-
self, node: ast.DictComp, parents: Sequence[ast.AST], ignore: Iterable[str]
145+
self, node: ast.DictComp, parents: Sequence[ast.AST], ignored: NameSet
137146
) -> Generator[tuple[int, int, str, Self]]: ...
138147
def visit_setcomp(
139-
self, node: ast.SetComp, parents: Sequence[ast.AST], ignore: Iterable[str]
148+
self, node: ast.SetComp, parents: Sequence[ast.AST], ignored: NameSet
140149
) -> Generator[tuple[int, int, str, Self]]: ...
141150
@staticmethod
142151
def global_variable_check(name: str) -> Literal["N816"] | None: ...
@@ -145,4 +154,10 @@ class VariablesCheck(BaseASTCheck):
145154
@staticmethod
146155
def function_variable_check(func: Callable[..., object], var_name: str) -> Literal["N806"] | None: ...
147156

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

0 commit comments

Comments
 (0)