File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
test/query-tests/Functions/general Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 32
32
not name = "__new__" and
33
33
not name = "__metaclass__" and
34
34
not name = "__init_subclass__" and
35
+ not name = "__class_getitem__" and
35
36
/* declared in scope */
36
37
f .getScope ( ) = cls .getScope ( )
37
38
) and
Original file line number Diff line number Diff line change @@ -120,15 +120,22 @@ def meth(arg):
120
120
121
121
122
122
123
- # The `__init_subclass__` method is a new method introduced into Python 3.6
124
- # which does not follow the normal conventions, and is in fact a class method
123
+ # The `__init_subclass__` (introduced in Python 3.6)
124
+ # and `__class_getitem__` (introduced in Python 3.7) methods are methods
125
+ # which do not follow the normal conventions, and are in fact class methods
125
126
# despite not being marked as such with other means. The name alone is what
126
127
# makes it such. As a consequence, the query `py/not-named-self` and other
127
128
# relevant queries need to account for this.
128
129
#
129
130
# This has come up in the wild via LGTM as a false positive. For example,
130
- # https://docs.python.org/3/reference/datamodel.html#customizing-class-creation
131
+ # `__init_subclass__`:
132
+ # https://docs.python.org/3/reference/datamodel.html#customizing-class-creation
133
+ # `__class_getitem__`:
134
+ # https://docs.python.org/3/reference/datamodel.html#emulating-generic-types
131
135
132
- class InitSubclass (object ):
136
+ class SpecialMethodNames (object ):
133
137
def __init_subclass__ (cls ):
134
138
pass
139
+
140
+ def __class_getitem__ (cls ):
141
+ pass
You can’t perform that action at this time.
0 commit comments