Skip to content

Commit 995da1d

Browse files
authored
Merge pull request #58 from rooterkyberian/more_implicit_cls_methods
add __class_getitem__ as implicit class method
2 parents 9f7c082 + c045a45 commit 995da1d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Diff for: bugbear.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ def visit(self, node):
560560
message="B902 Invalid first argument {} used for {} method. Use the "
561561
"canonical first argument name in methods, i.e. {}."
562562
)
563-
B902.implicit_classmethods = {"__new__", "__init_subclass__"}
563+
B902.implicit_classmethods = {"__new__", "__init_subclass__", "__class_getitem__"}
564564
B902.self = ["self"] # it's a list because the first is preferred
565565
B902.cls = ["cls", "klass"] # ditto.
566566
B902.metacls = ["metacls", "metaclass", "typ", "mcs"] # ditto.

Diff for: tests/b902.py

+10
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,13 @@ class RuntimeError("This is not a base"):
9090
def __init__(self):
9191
...
9292

93+
94+
class ImplicitClassMethods:
95+
def __new__(cls, *args, **kwargs):
96+
...
97+
98+
def __init_subclass__(cls, *args, **kwargs):
99+
...
100+
101+
def __class_getitem__(cls, key):
102+
...

0 commit comments

Comments
 (0)