Skip to content

Commit 3f9f2cd

Browse files
committed
policyrep.pyi: Update enum annotations.
Update Enum member annotation to address mypy issues like the following: setools/policyrep.pyi:57: error: Detected enum "setools.policyrep.PolicyEnum" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type` [misc] class PolicyEnum(enum.Enum): ^ setools/policyrep.pyi:57: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members setools/policyrep.pyi:117: error: Enum members must be left unannotated [misc] typebounds: int = ... ^ Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
1 parent 6352feb commit 3f9f2cd

1 file changed

Lines changed: 44 additions & 44 deletions

File tree

setools/policyrep.pyi

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class PolicySymbol(PolicyObject):
5454
def __contains__(self, other) -> bool: ...
5555
def expand(self) -> Iterable["PolicySymbol"]: ...
5656

57-
class PolicyEnum(enum.Enum):
57+
class PolicyEnum(enum.Enum): # type: ignore[misc]
5858
@classmethod
5959
def lookup(cls, value) -> Any: ...
6060

@@ -114,7 +114,7 @@ class Bounds(PolicyObject):
114114
ruletype: "BoundsRuletype" = ...
115115

116116
class BoundsRuletype(PolicyEnum):
117-
typebounds: int = ...
117+
typebounds = ...
118118

119119
class Category(PolicySymbol):
120120
def aliases(self, *args, **kwargs) -> Iterable[str]: ...
@@ -157,10 +157,10 @@ class ConstraintExpression(PolicyObject):
157157
def __iter__(self) -> Iterator[frozenset["Role"] | frozenset["Type"] | frozenset["User"] | str]: ...
158158

159159
class ConstraintRuletype(PolicyEnum):
160-
constrain: int = ...
161-
mlsconstrain: int = ...
162-
mlsvalidatetrans: int = ...
163-
validatetrans: int = ...
160+
constrain = ...
161+
mlsconstrain = ...
162+
mlsvalidatetrans = ...
163+
validatetrans = ...
164164

165165
class Context(PolicyObject):
166166
range_: "Range" = ...
@@ -177,22 +177,22 @@ class DefaultRange(Default):
177177
default_range: "DefaultRangeValue" = ...
178178

179179
class DefaultRangeValue(PolicyEnum):
180-
high: int = ...
181-
low: int = ...
182-
low_high: int = ...
180+
high = ...
181+
low = ...
182+
low_high = ...
183183
@classmethod
184184
def from_default_range(cls, range: int | None) -> "DefaultRangeValue" | None: ...
185185

186186
class DefaultRuletype(PolicyEnum):
187-
default_range: int = ...
188-
default_role: int = ...
189-
default_type: int = ...
190-
default_user: int = ...
187+
default_range = ...
188+
default_role = ...
189+
default_type = ...
190+
default_user = ...
191191

192192
class DefaultValue(PolicyEnum):
193-
glblub: int = ...
194-
source: int = ...
195-
target: int = ...
193+
glblub = ...
194+
source = ...
195+
target = ...
196196
@classmethod
197197
def from_default_range(cls, *args, **kwargs) -> "DefaultValue": ...
198198

@@ -204,9 +204,9 @@ class FSUse(Ocontext):
204204
ruletype: "FSUseRuletype" = ...
205205

206206
class FSUseRuletype(PolicyEnum):
207-
fs_use_task: int = ...
208-
fs_use_trans: int = ...
209-
fs_use_xattr: int = ...
207+
fs_use_task = ...
208+
fs_use_trans = ...
209+
fs_use_xattr = ...
210210

211211
class FileNameTERule(BaseTERule):
212212
default: "Type" = ...
@@ -227,9 +227,9 @@ class Genfscon(Ocontext):
227227
tclass: "ObjClass" = ...
228228

229229
class HandleUnknown(PolicyEnum):
230-
allow: int = ...
231-
deny: int = ...
232-
reject: int = ...
230+
allow = ...
231+
deny = ...
232+
reject = ...
233233

234234
class Ibendportcon(Ocontext):
235235
name: str = ...
@@ -284,7 +284,7 @@ class MLSRule(PolicyRule):
284284
def expand(self) -> Iterable["MLSRule"]: ...
285285

286286
class MLSRuletype(PolicyEnum):
287-
range_transition: int = ...
287+
range_transition = ...
288288

289289
class Netifcon(Ocontext):
290290
netif: str = ...
@@ -295,8 +295,8 @@ class Nodecon(Ocontext):
295295
network: ipaddress.IPv4Network | ipaddress.IPv6Network = ...
296296

297297
class NodeconIPVersion(PolicyEnum):
298-
ipv4: int = ...
299-
ipv6: int = ...
298+
ipv4 = ...
299+
ipv6 = ...
300300

301301
class ObjClass(PolicySymbol):
302302
common: "Common" = ...
@@ -314,27 +314,27 @@ class Pirqcon(Ocontext):
314314
class PolicyCapability(PolicySymbol): ...
315315

316316
class PolicyTarget(PolicyEnum):
317-
selinux: int = ...
318-
xen: int = ...
317+
selinux = ...
318+
xen = ...
319319

320320
class Portcon(Ocontext):
321321
ports: "PortconRange" = ...
322322
protocol: "PortconProtocol" = ...
323323

324324
class PortconProtocol(PolicyEnum):
325-
dccp: int = ...
326-
sctp: int = ...
327-
tcp: int = ...
328-
udp: int = ...
325+
dccp = ...
326+
sctp = ...
327+
tcp = ...
328+
udp = ...
329329

330330
@dataclass(eq=True, order=True, frozen=True)
331331
class PortconRange:
332332
high: int = ...
333333
low: int = ...
334334

335335
class RBACRuletype(PolicyEnum):
336-
allow: int = ...
337-
role_transition: int = ...
336+
allow = ...
337+
role_transition = ...
338338

339339
class Range(PolicyObject):
340340
high: Level = ...
@@ -472,17 +472,17 @@ class TERule(BaseTERule):
472472
def expand(self) -> Iterable["TERule"]: ...
473473

474474
class TERuletype(PolicyEnum):
475-
allow: int = ...
476-
allowxperm: int = ...
477-
auditallow: int = ...
478-
auditallowxperm: int = ...
479-
dontaudit: int = ...
480-
dontauditxperm: int = ...
481-
neverallow: int = ...
482-
neverallowxperm: int = ...
483-
type_change: int = ...
484-
type_member: int = ...
485-
type_transition: int = ...
475+
allow = ...
476+
allowxperm = ...
477+
auditallow = ...
478+
auditallowxperm = ...
479+
dontaudit = ...
480+
dontauditxperm = ...
481+
neverallow = ...
482+
neverallowxperm = ...
483+
type_change = ...
484+
type_member = ...
485+
type_transition = ...
486486

487487
@dataclass
488488
class TruthTableRow:

0 commit comments

Comments
 (0)