Enable/apply ruff's "flake6-simplify" rules
This commit is contained in:
parent
be68946dcb
commit
4561e317b8
@ -1,3 +1,4 @@
|
|||||||
|
import contextlib
|
||||||
import csv
|
import csv
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
@ -120,11 +121,8 @@ class DoorController:
|
|||||||
for ii in range(1, 8)
|
for ii in range(1, 8)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
try:
|
# don't care about failure to delete, they probably just didn't exist
|
||||||
self.doXMLRequest(delXML)
|
contextlib.suppress(self.doXMLRequest(delXML))
|
||||||
except RemoteError:
|
|
||||||
# don't care about failure to delete, they probably just didn't exist
|
|
||||||
pass
|
|
||||||
|
|
||||||
# load new schedules
|
# load new schedules
|
||||||
self.doXMLRequest(schedules)
|
self.doXMLRequest(schedules)
|
||||||
|
@ -138,9 +138,8 @@ class MembershipWorks:
|
|||||||
for element in box["box"]:
|
for element in box["box"]:
|
||||||
if not isinstance(element["dat"], str):
|
if not isinstance(element["dat"], str):
|
||||||
for field in element["dat"]:
|
for field in element["dat"]:
|
||||||
if "_id" in field:
|
if "_id" in field and field["_id"] not in fields:
|
||||||
if field["_id"] not in fields:
|
fields[field["_id"]] = field
|
||||||
fields[field["_id"]] = field
|
|
||||||
|
|
||||||
return fields
|
return fields
|
||||||
|
|
||||||
@ -218,7 +217,7 @@ class MembershipWorks:
|
|||||||
r = self._get_v1(
|
r = self._get_v1(
|
||||||
BASE_URL + "/v1/csv",
|
BASE_URL + "/v1/csv",
|
||||||
params={
|
params={
|
||||||
"crm": ",".join(str(k) for k in CRM.keys()),
|
"crm": ",".join(str(k) for k in CRM),
|
||||||
**({"txl": ""} if json else {}),
|
**({"txl": ""} if json else {}),
|
||||||
"sdp": start_date.strftime("%s"),
|
"sdp": start_date.strftime("%s"),
|
||||||
"edp": end_date.strftime("%s"),
|
"edp": end_date.strftime("%s"),
|
||||||
|
@ -55,9 +55,7 @@ def scrape_members(membershipworks: MembershipWorks):
|
|||||||
field.get("typ") == FieldType.CHECKBOX.value
|
field.get("typ") == FieldType.CHECKBOX.value
|
||||||
and field["lbl"] in csv_member
|
and field["lbl"] in csv_member
|
||||||
):
|
):
|
||||||
csv_member[field["lbl"]] = (
|
csv_member[field["lbl"]] = csv_member[field["lbl"]] == "Y"
|
||||||
True if csv_member[field["lbl"]] == "Y" else False
|
|
||||||
)
|
|
||||||
|
|
||||||
# create/update member
|
# create/update member
|
||||||
member = Member.from_api_dict(csv_member)
|
member = Member.from_api_dict(csv_member)
|
||||||
|
@ -43,7 +43,7 @@ admin_email = "cmsmanage.django_q2_admin_email_reporter:AdminEmailReporter"
|
|||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
line-length = 88
|
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]
|
[tool.ruff.lint.isort]
|
||||||
known-first-party = [
|
known-first-party = [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.decorators import login_required, permission_required
|
from django.contrib.auth.decorators import login_required, permission_required
|
||||||
from django.http import HttpResponseRedirect
|
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 django.urls import reverse
|
||||||
|
|
||||||
from .forms import LockerInfoForm
|
from .forms import LockerInfoForm
|
||||||
@ -31,10 +31,7 @@ def lockerIndex(request):
|
|||||||
@permission_required("rentals.change_lockerinfo", raise_exception=True)
|
@permission_required("rentals.change_lockerinfo", raise_exception=True)
|
||||||
def lockerUpdate(request, locker_id: int):
|
def lockerUpdate(request, locker_id: int):
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
try:
|
instance = get_object_or_404(LockerInfo, pk=locker_id)
|
||||||
instance = LockerInfo.objects.get(pk=locker_id)
|
|
||||||
except LockerInfo.DoesNotExist:
|
|
||||||
pass # TODO
|
|
||||||
|
|
||||||
form = LockerInfoForm(request.POST, instance=instance)
|
form = LockerInfoForm(request.POST, instance=instance)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
|
Loading…
Reference in New Issue
Block a user