diff options
author | Marc Mueller <30130371+cdce8p@users.noreply.github.com> | 2021-11-21 20:42:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-21 20:42:32 +0100 |
commit | 2904ae04a2cf6bc341873e6b902883a777452953 (patch) | |
tree | 9eb7dfc8382206a3061e0749ee6d14091f499454 /tests/functional/i/inherit_non_class.py | |
parent | 079805b0f9d0324d1731595c0c6f8f36e5a999f4 (diff) | |
download | pylint-git-2904ae04a2cf6bc341873e6b902883a777452953.tar.gz |
Add tests `inherit-non-class` with subscriptable class (#5354)
* Add tests inherit-non-class with subscriptable class
Diffstat (limited to 'tests/functional/i/inherit_non_class.py')
-rw-r--r-- | tests/functional/i/inherit_non_class.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/functional/i/inherit_non_class.py b/tests/functional/i/inherit_non_class.py index bbee6bd9a..7454744d9 100644 --- a/tests/functional/i/inherit_non_class.py +++ b/tests/functional/i/inherit_non_class.py @@ -79,3 +79,26 @@ class NotInheritableSlice(slice): # [inherit-non-class] class NotInheritableMemoryView(memoryview): # [inherit-non-class]
pass
+
+
+# Subscription of parent class that implements __class_getitem__
+# and returns cls should be allowed.
+class ParentGood:
+ def __class_getitem__(cls, item): # pylint: disable=unused-argument
+ return cls
+
+class ParentBad:
+ def __class_getitem__(cls, item): # pylint: disable=unused-argument
+ return 42
+
+# pylint: disable-next=fixme
+# TODO This should emit 'unsubscriptable-object' for Python 3.6
+class Child1(ParentGood[int]):
+ pass
+
+class Child2(ParentBad[int]): # [inherit-non-class]
+ pass
+
+# Classes that don't implement '__class_getitem__' are marked as unsubscriptable
+class Child3(Empty[int]): # [unsubscriptable-object]
+ pass
|