diff options
| author | Dmitry Shachnev <mitya57@users.noreply.github.com> | 2021-11-21 19:24:08 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-21 17:24:08 +0100 |
| commit | ce5cbce5ba11cdc2f8139ade66feea1e181a7944 (patch) | |
| tree | 7a455f71ca44af7672e8219075a2857e8bb6d867 /astroid | |
| parent | 935ff12e0d65899d3d48d1c7be9cbeeb1d9e6089 (diff) | |
| download | astroid-git-ce5cbce5ba11cdc2f8139ade66feea1e181a7944.tar.gz | |
Always treat __class_getitem__ as a classmethod (#1266)
* Always treat __class_getitem__ as a classmethod
Consider this code:
class Foo:
def __class_getitem__(cls, *args, **kwargs):
return cls
Without this change, astroid would treat cls as an instance of Foo,
and thus it will think of Foo[bar] also as an instance, while really
it is the same as Foo.
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Diffstat (limited to 'astroid')
| -rw-r--r-- | astroid/nodes/scoped_nodes.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py index f8c60131..cfc14d72 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -1570,6 +1570,8 @@ class FunctionDef(mixins.MultiLineBlockMixin, node_classes.Statement, Lambda): return "classmethod" if self.name == "__init_subclass__": return "classmethod" + if self.name == "__class_getitem__": + return "classmethod" type_name = "method" |
