From 27974e7de6c3fd1ef3cce634a351e0845bde72e5 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Thu, 18 Jan 2024 13:19:58 -0500 Subject: [PATCH] Enable/apply ruff's "pyupgrade" rules --- doorcontrol/views.py | 4 ++-- paperwork/admin.py | 6 +++--- paperwork/models.py | 6 +++--- pyproject.toml | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/doorcontrol/views.py b/doorcontrol/views.py index d02c6bc..918d055 100644 --- a/doorcontrol/views.py +++ b/doorcontrol/views.py @@ -213,7 +213,7 @@ class DeniedAccess(BaseAccessReport): "door name": event.door.name, "event type": HIDEvent.EventType(event.event_type).label, "name": " ".join( - (n for n in [event.forename, event.surname] if n is not None) + n for n in [event.forename, event.surname] if n is not None ), "raw card number": ( event.raw_card_number if event.raw_card_number is not None else "" @@ -242,7 +242,7 @@ class MostActiveMembers(BaseAccessReport): { "cardholder id": count["cardholder_id"], "name": " ".join( - (n for n in [count["forename"], count["surname"]] if n is not None) + n for n in [count["forename"], count["surname"]] if n is not None ), "access count": count["access_count"], } diff --git a/paperwork/admin.py b/paperwork/admin.py index 453eab4..5e8a324 100644 --- a/paperwork/admin.py +++ b/paperwork/admin.py @@ -1,4 +1,4 @@ -from typing import Any, Optional, Type, cast +from typing import Any, cast from django import forms from django.contrib import admin, messages @@ -38,8 +38,8 @@ class AbstractAuditInline(admin.TabularInline): form = AlwaysChangedModelForm def get_formset( - self, request: HttpRequest, obj: Optional[AbstractAudit] = None, **kwargs: Any - ) -> Type[ + self, request: HttpRequest, obj: AbstractAudit | None = None, **kwargs: Any + ) -> type[ "forms.models.BaseInlineFormSet[AbstractAudit, Any, forms.models.ModelForm[Any]]" ]: formset = super().get_formset(request, obj, **kwargs) diff --git a/paperwork/models.py b/paperwork/models.py index fec69bf..0038b21 100644 --- a/paperwork/models.py +++ b/paperwork/models.py @@ -1,6 +1,6 @@ import datetime import re -from typing import TYPE_CHECKING, Optional, TypedDict +from typing import TYPE_CHECKING, TypedDict from django.conf import settings from django.core.validators import RegexValidator @@ -106,14 +106,14 @@ class Department(models.Model): return self.name @property - def list_name(self) -> Optional[str]: + def list_name(self) -> str | None: if self.has_mailing_list: return self.name.replace(" ", "_") + "-info" else: return None @property - def list_address(self) -> Optional[str]: + def list_address(self) -> str | None: if self.list_name: return self.list_name + "@claremontmakerspace.org" else: diff --git a/pyproject.toml b/pyproject.toml index 8eae21c..a278fc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] +select = ["E4", "E7", "E9", "F", "I", "C4", "UP"] [tool.ruff.lint.isort] known-first-party = [