bitmask.py: formatting fixes
This commit is contained in:
parent
d4d81c14ca
commit
81055b0487
@ -50,7 +50,7 @@ class Bitmask:
|
||||
|
||||
self._value = 0
|
||||
# Placeholder, modified later in __mask_op()
|
||||
self._AllFlags = IntFlag('', '')
|
||||
self._AllFlags = IntFlag("", "")
|
||||
|
||||
for flag in flags:
|
||||
self.add(flag)
|
||||
@ -90,7 +90,7 @@ class Bitmask:
|
||||
types.append(type_name(self.AllFlags))
|
||||
|
||||
if len(types) > 1:
|
||||
return ', '.join(types[:-1]) + " or " + types[-1]
|
||||
return ", ".join(types[:-1]) + " or " + types[-1]
|
||||
else:
|
||||
return types[0]
|
||||
|
||||
@ -113,13 +113,10 @@ class Bitmask:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
elif issubclass(type(item), self.AllFlags) \
|
||||
or not self.defined:
|
||||
elif issubclass(type(item), self.AllFlags) or not self.defined:
|
||||
return bool(self.value & item)
|
||||
else:
|
||||
raise TypeError(
|
||||
f"item must be {self.__format_types()}"
|
||||
)
|
||||
raise TypeError(f"item must be {self.__format_types()}")
|
||||
|
||||
def __iter__(self):
|
||||
"""Return list of enabled flags."""
|
||||
|
@ -146,9 +146,9 @@ def test_and_operator():
|
||||
assert Bitmask() & Desc.ROUND == Bitmask()
|
||||
|
||||
# AND of bitmasks
|
||||
assert Bitmask(Desc.FUNKY, Desc.SONAR) & Bitmask(
|
||||
Desc.FUNKY, Desc.ROUND
|
||||
) == Bitmask(Desc.FUNKY)
|
||||
assert Bitmask(Desc.FUNKY, Desc.SONAR) & Bitmask(Desc.FUNKY, Desc.ROUND) == Bitmask(
|
||||
Desc.FUNKY
|
||||
)
|
||||
assert Bitmask(Desc.FUNKY, Desc.ROUND) & Bitmask(Desc.SMALL) == Bitmask()
|
||||
assert Bitmask() & Bitmask() == Bitmask()
|
||||
|
||||
@ -207,8 +207,7 @@ def test_subtract():
|
||||
Desc.SMALL, Desc.ROUND
|
||||
) == Bitmask(Desc.FUNKY)
|
||||
assert (
|
||||
Bitmask(Desc.FUNKY, Desc.SMALL) - Bitmask(Desc.SMALL, Desc.FUNKY)
|
||||
== Bitmask()
|
||||
Bitmask(Desc.FUNKY, Desc.SMALL) - Bitmask(Desc.SMALL, Desc.FUNKY) == Bitmask()
|
||||
)
|
||||
|
||||
|
||||
@ -233,8 +232,7 @@ def test_xor_operator():
|
||||
Desc.SMALL, Desc.FUNKY, Desc.ROUND
|
||||
)
|
||||
assert (
|
||||
Bitmask(Desc.FUNKY, Desc.ROUND) ^ Bitmask(Desc.FUNKY, Desc.ROUND)
|
||||
== Bitmask()
|
||||
Bitmask(Desc.FUNKY, Desc.ROUND) ^ Bitmask(Desc.FUNKY, Desc.ROUND) == Bitmask()
|
||||
)
|
||||
assert Bitmask() ^ Bitmask() == Bitmask()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user