You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test-data/unit/check-enum.test
+65Lines changed: 65 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1883,6 +1883,71 @@ class SubWithOverload(WithOverload): # Should pass
1883
1883
pass
1884
1884
[builtins fixtures/tuple.pyi]
1885
1885
1886
+
[case testEnumBaseClassesOrder]
1887
+
import enum
1888
+
1889
+
# Base types:
1890
+
1891
+
class First:
1892
+
def __new__(cls, val):
1893
+
pass
1894
+
1895
+
class Second:
1896
+
def __new__(cls, val):
1897
+
pass
1898
+
1899
+
class Third:
1900
+
def __new__(cls, val):
1901
+
pass
1902
+
1903
+
class Mixin:
1904
+
pass
1905
+
1906
+
# Correct Enums:
1907
+
1908
+
class Correct1(Mixin, First, enum.Enum):
1909
+
pass
1910
+
1911
+
class Correct2(First, enum.Enum):
1912
+
pass
1913
+
1914
+
class Correct3(Mixin, enum.Enum):
1915
+
pass
1916
+
1917
+
class RegularClass(Mixin, First, Second):
1918
+
pass
1919
+
1920
+
# Wrong Enums:
1921
+
1922
+
class MixinAfterEnum1(enum.Enum, Mixin): # E: No base classes are allowed after "enum.Enum"
1923
+
pass
1924
+
1925
+
class MixinAfterEnum2(First, enum.Enum, Mixin): # E: No base classes are allowed after "enum.Enum"
1926
+
pass
1927
+
1928
+
class TwoDataTypes(First, Second, enum.Enum): # E: Only a single data type mixin is allowed for Enum subtypes, found extra "__main__.Second"
1929
+
pass
1930
+
1931
+
class TwoDataTypesAndIntEnumMixin(First, Second, enum.IntEnum, Mixin): # E: Only a single data type mixin is allowed for Enum subtypes, found extra "__main__.Second" \
1932
+
# E: No base classes are allowed after "enum.IntEnum"
1933
+
pass
1934
+
1935
+
class ThreeDataTypes(First, Second, Third, enum.Enum): # E: Only a single data type mixin is allowed for Enum subtypes, found extra "__main__.Second" \
1936
+
# E: # E: Only a single data type mixin is allowed for Enum subtypes, found extra "__main__.Third"
1937
+
pass
1938
+
1939
+
class ThreeDataTypesAndMixin(First, Second, Third, enum.Enum, Mixin): # E: Only a single data type mixin is allowed for Enum subtypes, found extra "__main__.Second" \
1940
+
# E: # E: Only a single data type mixin is allowed for Enum subtypes, found extra "__main__.Third" \
1941
+
# E: No base classes are allowed after "enum.Enum"
1942
+
pass
1943
+
1944
+
class FromEnumAndOther1(Correct2, Second, enum.Enum): # E: Only a single data type mixin is allowed for Enum subtypes, found extra "__main__.Second"
1945
+
pass
1946
+
1947
+
class FromEnumAndOther2(Correct2, Second): # E: Only a single data type mixin is allowed for Enum subtypes, found extra "__main__.Second"
0 commit comments