summaryrefslogtreecommitdiff
path: root/tests/functional
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional')
-rw-r--r--tests/functional/i/inherit_non_class.py23
-rw-r--r--tests/functional/i/inherit_non_class.txt2
2 files changed, 25 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
diff --git a/tests/functional/i/inherit_non_class.txt b/tests/functional/i/inherit_non_class.txt
index 9252c2fbf..e8a9b0b6f 100644
--- a/tests/functional/i/inherit_non_class.txt
+++ b/tests/functional/i/inherit_non_class.txt
@@ -7,3 +7,5 @@ inherit-non-class:68:0:NotInheritableBool:Inheriting 'bool', which is not a clas
inherit-non-class:72:0:NotInheritableRange:Inheriting 'range', which is not a class.
inherit-non-class:76:0:NotInheritableSlice:Inheriting 'slice', which is not a class.
inherit-non-class:80:0:NotInheritableMemoryView:Inheriting 'memoryview', which is not a class.
+inherit-non-class:99:0:Child2:Inheriting 'ParentBad[int]', which is not a class.:HIGH
+unsubscriptable-object:103:13:Child3:Value 'Empty' is unsubscriptable:HIGH