Enable/apply ruff's "flake6-simplify" rules

This commit is contained in:
Adam Goldsmith 2024-01-19 15:16:47 -05:00
parent be68946dcb
commit 4561e317b8
5 changed files with 10 additions and 18 deletions

View File

@ -1,3 +1,4 @@
import contextlib
import csv
from datetime import datetime
from io import StringIO
@ -120,11 +121,8 @@ class DoorController:
for ii in range(1, 8)
]
)
try:
self.doXMLRequest(delXML)
except RemoteError:
# don't care about failure to delete, they probably just didn't exist
pass
# don't care about failure to delete, they probably just didn't exist
contextlib.suppress(self.doXMLRequest(delXML))
# load new schedules
self.doXMLRequest(schedules)

View File

@ -138,9 +138,8 @@ class MembershipWorks:
for element in box["box"]:
if not isinstance(element["dat"], str):
for field in element["dat"]:
if "_id" in field:
if field["_id"] not in fields:
fields[field["_id"]] = field
if "_id" in field and field["_id"] not in fields:
fields[field["_id"]] = field
return fields
@ -218,7 +217,7 @@ class MembershipWorks:
r = self._get_v1(
BASE_URL + "/v1/csv",
params={
"crm": ",".join(str(k) for k in CRM.keys()),
"crm": ",".join(str(k) for k in CRM),
**({"txl": ""} if json else {}),
"sdp": start_date.strftime("%s"),
"edp": end_date.strftime("%s"),

View File

@ -55,9 +55,7 @@ def scrape_members(membershipworks: MembershipWorks):
field.get("typ") == FieldType.CHECKBOX.value
and field["lbl"] in csv_member
):
csv_member[field["lbl"]] = (
True if csv_member[field["lbl"]] == "Y" else False
)
csv_member[field["lbl"]] = csv_member[field["lbl"]] == "Y"
# create/update member
member = Member.from_api_dict(csv_member)

View File

@ -43,7 +43,7 @@ admin_email = "cmsmanage.django_q2_admin_email_reporter:AdminEmailReporter"
[tool.ruff]
line-length = 88
select = ["E4", "E7", "E9", "F", "I", "C4", "UP", "PERF", "PL"]
select = ["E4", "E7", "E9", "F", "I", "C4", "UP", "PERF", "PL", "SIM"]
[tool.ruff.lint.isort]
known-first-party = [

View File

@ -1,7 +1,7 @@
from django.contrib import messages
from django.contrib.auth.decorators import login_required, permission_required
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.shortcuts import get_object_or_404, render
from django.urls import reverse
from .forms import LockerInfoForm
@ -31,10 +31,7 @@ def lockerIndex(request):
@permission_required("rentals.change_lockerinfo", raise_exception=True)
def lockerUpdate(request, locker_id: int):
if request.method == "POST":
try:
instance = LockerInfo.objects.get(pk=locker_id)
except LockerInfo.DoesNotExist:
pass # TODO
instance = get_object_or_404(LockerInfo, pk=locker_id)
form = LockerInfoForm(request.POST, instance=instance)
if form.is_valid():