Apply Ruff's flake8-builtins (A) rules
This commit is contained in:
parent
8fccb3c7fb
commit
ab25da0aa1
@ -5,10 +5,10 @@ import bitstring
|
||||
|
||||
|
||||
class Credential:
|
||||
def __init__(self, code=None, hex=None):
|
||||
if code is None and hex is None:
|
||||
def __init__(self, code=None, hex_code=None):
|
||||
if code is None and hex_code is None:
|
||||
raise TypeError("Must set either code or hex for a Credential")
|
||||
elif code is not None and hex is not None:
|
||||
elif code is not None and hex_code is not None:
|
||||
raise TypeError("Cannot set both code and hex for a Credential")
|
||||
elif code is not None:
|
||||
self.bits = bitstring.pack(
|
||||
@ -18,8 +18,8 @@ class Credential:
|
||||
)
|
||||
self.bits[6] = self.bits[7:19].count(1) % 2 # even parity
|
||||
self.bits[31] = not (self.bits[19:31].count(1) % 2) # odd parity
|
||||
elif hex is not None:
|
||||
self.bits = bitstring.Bits(hex=hex)
|
||||
elif hex_code is not None:
|
||||
self.bits = bitstring.Bits(hex=hex_code)
|
||||
|
||||
def __repr__(self):
|
||||
return f"Credential({self.code})"
|
||||
|
@ -242,11 +242,11 @@ class HIDEvent(models.Model):
|
||||
field.column: field.attname for field in HIDEvent._meta.get_fields()
|
||||
}
|
||||
|
||||
def attr_to_bool(str):
|
||||
if str is None:
|
||||
def attr_to_bool(attr):
|
||||
if attr is None:
|
||||
return None
|
||||
else:
|
||||
return str == "true"
|
||||
return attr == "true"
|
||||
|
||||
return cls(
|
||||
**{
|
||||
|
@ -108,7 +108,7 @@ class DoorMember:
|
||||
},
|
||||
cardholderID=data.attrib["cardholderID"],
|
||||
credentials={
|
||||
Credential(hex=(c.attrib["rawCardNumber"]))
|
||||
Credential(hex_code=(c.attrib["rawCardNumber"]))
|
||||
for c in data.findall("{*}Credential")
|
||||
},
|
||||
schedules={r.attrib["scheduleName"] for r in data.findall("{*}Role")},
|
||||
@ -222,7 +222,7 @@ def update_door(door: Door, dry_run: bool = False):
|
||||
}
|
||||
|
||||
existing_door_credentials = {
|
||||
Credential(hex=c.attrib["rawCardNumber"])
|
||||
Credential(hex_code=c.attrib["rawCardNumber"])
|
||||
for c in door.controller.get_credentials()
|
||||
}
|
||||
|
||||
|
@ -381,8 +381,8 @@ class EventCategory(models.Model):
|
||||
return self.title
|
||||
|
||||
@classmethod
|
||||
def from_api_dict(cls, id: int, data):
|
||||
return cls(id=id, title=data["ttl"])
|
||||
def from_api_dict(cls, id_: int, data):
|
||||
return cls(id=id_, title=data["ttl"])
|
||||
|
||||
|
||||
class Event(BaseModel):
|
||||
|
@ -33,8 +33,8 @@ def flags_for_member(csv_member, all_flags, folders):
|
||||
|
||||
def update_flags(mw_flags) -> Iterable[Flag]:
|
||||
for typ, flags_of_type in mw_flags.items():
|
||||
for name, id in flags_of_type.items():
|
||||
flag = Flag(id=id, name=name, type=typ[:-1])
|
||||
for name, flag_id in flags_of_type.items():
|
||||
flag = Flag(id=flag_id, name=name, type=typ[:-1])
|
||||
flag.save()
|
||||
yield flag
|
||||
|
||||
|
@ -39,7 +39,7 @@ class DepartmentViewSet(viewsets.ModelViewSet):
|
||||
serializer_class = DepartmentSerializer
|
||||
|
||||
@action(detail=False, methods=["get"])
|
||||
def mailing_lists(self, request, format=None):
|
||||
def mailing_lists(self, request, format=None): # noqa: A002
|
||||
"""
|
||||
Generate a mailing list for each department, containing all
|
||||
certified users for tools in that department or child departments
|
||||
|
@ -60,7 +60,7 @@ admin_email = "cmsmanage.django_q2_admin_email_reporter:AdminEmailReporter"
|
||||
line-length = 88
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["E4", "E7", "E9", "F", "I", "C4", "UP", "PERF", "PL", "SIM", "FIX003", "DJ012"]
|
||||
select = ["E4", "E7", "E9", "F", "I", "C4", "UP", "PERF", "PL", "SIM", "FIX003", "DJ012", "A"]
|
||||
|
||||
[tool.ruff.lint.isort]
|
||||
known-first-party = [
|
||||
|
Loading…
Reference in New Issue
Block a user