Skip to content

Commit 29bc9b9

Browse files
authored
Merge pull request #61 from davidism/b902-mcs
allow 'mcs' for metaclass classmethod first arg
2 parents b99000a + 828148d commit 29bc9b9

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Diff for: README.rst

+6
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,12 @@ MIT
233233
Change Log
234234
----------
235235

236+
19.3.0
237+
~~~~~~
238+
239+
* For B902, the first argument for metaclass class methods can be
240+
"mcs", matching the name preferred by PyCharm.
241+
236242
18.2.0
237243
~~~~~~
238244

Diff for: bugbear.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def visit(self, node):
551551
B902.implicit_classmethods = {"__new__", "__init_subclass__"}
552552
B902.self = ["self"] # it's a list because the first is preferred
553553
B902.cls = ["cls", "klass"] # ditto.
554-
B902.metacls = ["metacls", "metaclass", "typ"] # ditto.
554+
B902.metacls = ["metacls", "metaclass", "typ", "mcs"] # ditto.
555555

556556
B903 = Error(
557557
message="B903 Data class should either be immutable or use __slots__ to "

Diff for: tests/b902.py

+5
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ def __init__(self, name, bases, d):
7272
def __prepare__(cls, name, bases):
7373
return {}
7474

75+
@classmethod
76+
def first_arg_mcs_allowed(mcs, value):
77+
...
78+
7579

7680
def type_factory():
7781
return object
@@ -85,3 +89,4 @@ def __init__(self):
8589
class RuntimeError("This is not a base"):
8690
def __init__(self):
8791
...
92+

0 commit comments

Comments
 (0)