-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
implicit_flag_alias.py
47 lines (40 loc) · 1.19 KB
/
implicit_flag_alias.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""Test check for classes extending an Enum class."""
from enum import IntFlag, auto
class DisjointFlags(IntFlag):
"""Class with flags that do not overlap"""
X = 1
W = 2
R = 4
S = auto()
class ExplicitUnionFlags(IntFlag):
"""Class with flags that overlap using explicit union syntax"""
X = 1
W = 2
R = 4
RO = 4
RW = R | W
class SubclassUnionFlags(ExplicitUnionFlags): # [invalid-enum-extension]
"""Class with flags that overlap a superclass"""
RWX = 7
class ImplicitUnionFlags(IntFlag):
"""Class with flags that overlap implicitly"""
A = 1
DUPLICATE = 1
B = 2
C = 3 # [implicit-flag-alias]
D = 5 # [implicit-flag-alias]
E = 8
F = 17 # [implicit-flag-alias]
G = 17 # [implicit-flag-alias]
TRIPLICATE = 1
def irrelevant(self):
"""Irrelevant method definition"""
return
class ReverseOrderFlags(IntFlag):
"""Class with flags that overlap and are declared in descending order"""
A = 5 # [implicit-flag-alias]
B = 1
class SharedBitsWithoutDeclaration(IntFlag):
"""Class with flags that share a bit, but no value is defined using that bit"""
A = 3
B = 5 # [implicit-flag-alias]