From 02777265b0d6d7e60034a1f9660385d6610d1766 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Wed, 17 Jan 2024 21:17:24 -0500 Subject: [PATCH] Switch from Black to Ruff for formatting, add linting/import sorting --- .pre-commit-config.yaml | 13 ++-- cmsmanage/django_q2_admin_email_reporter.py | 2 +- cmsmanage/settings/dev.sample.py | 2 +- cmsmanage/settings/dev_base.py | 8 +-- cmsmanage/settings/prod_base.py | 4 +- cmsmanage/urls.py | 9 ++- dashboard/tests.py | 2 - doorcontrol/dashboard.py | 1 + ...door_remove_hidevent_door_name_and_more.py | 2 +- doorcontrol/tests.py | 2 - doorcontrol/views.py | 12 ++-- membershipworks/__init__.py | 1 - membershipworks/admin.py | 10 +-- membershipworks/api.py | 2 +- membershipworks/apps.py | 2 +- membershipworks/dashboard.py | 2 +- membershipworks/membershipworks_api.py | 4 +- ...member_accepted_covid19_policy_and_more.py | 1 - membershipworks/models.py | 2 +- membershipworks/tasks/scrape.py | 12 ++-- membershipworks/tasks/ucsAccounts.py | 7 ++- membershipworks/tests.py | 2 - membershipworks/urls.py | 2 +- membershipworks/views.py | 5 +- paperwork/admin.py | 16 ++--- paperwork/api.py | 6 +- paperwork/autocomplete_views.py | 5 +- paperwork/certification_emails.py | 4 +- paperwork/dashboard.py | 1 + paperwork/forms.py | 6 +- paperwork/migrations/0001_initial.py | 2 +- .../0002_add_certification_version_model.py | 2 +- ...lter_certificationdefinition_department.py | 2 +- ...t_list_moderator_flag_to_shop_lead_flag.py | 2 +- ...0_switch_certificationversion_to_semver.py | 1 - .../0012_waiveraudit_certificationaudit.py | 3 +- ...ertificationdefinition_options_and_more.py | 2 +- paperwork/models.py | 14 +++-- paperwork/tests.py | 2 - paperwork/urls.py | 3 +- paperwork/views.py | 1 + pdm.lock | 62 ++++++++----------- pyproject.toml | 20 +++++- rentals/admin.py | 5 +- rentals/migrations/0001_initial.py | 2 +- rentals/models.py | 3 +- rentals/tests.py | 2 - rentals/views.py | 5 +- tasks/admin.py | 3 +- tasks/forms.py | 1 + .../management/commands/sendNotifications.py | 6 +- tasks/migrations/0001_initial.py | 3 +- tasks/migrations/0003_task_recurrence.py | 1 + tasks/models.py | 1 + tasks/templates/tasks/taskDetail.dj.html | 4 +- tasks/tests.py | 2 - tasks/views.py | 3 +- templates/base.dj.html | 29 +++++++-- 58 files changed, 173 insertions(+), 160 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index db1e4dc..2563599 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,12 +7,13 @@ repos: - id: check-yaml - id: check-added-large-files - - repo: https://github.com/psf/black - rev: 23.11.0 - hooks: - - id: black - - repo: https://github.com/Riverside-Healthcare/djLint - rev: v1.34.0 + rev: v1.34.1 hooks: - id: djlint-django + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.13 + hooks: + - id: ruff + - id: ruff-format diff --git a/cmsmanage/django_q2_admin_email_reporter.py b/cmsmanage/django_q2_admin_email_reporter.py index 4589101..9b6073f 100644 --- a/cmsmanage/django_q2_admin_email_reporter.py +++ b/cmsmanage/django_q2_admin_email_reporter.py @@ -1,8 +1,8 @@ import sys import traceback -from django.views.debug import ExceptionReporter from django.core import mail +from django.views.debug import ExceptionReporter class AdminEmailReporter: diff --git a/cmsmanage/settings/dev.sample.py b/cmsmanage/settings/dev.sample.py index 19e1eb1..f5222aa 100644 --- a/cmsmanage/settings/dev.sample.py +++ b/cmsmanage/settings/dev.sample.py @@ -1,4 +1,4 @@ -from .dev_base import * +from .dev_base import * # noqa: F403 # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ diff --git a/cmsmanage/settings/dev_base.py b/cmsmanage/settings/dev_base.py index eaca17b..b22a088 100644 --- a/cmsmanage/settings/dev_base.py +++ b/cmsmanage/settings/dev_base.py @@ -1,4 +1,4 @@ -from .base import * +from .base import * # noqa: F403 # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ @@ -9,7 +9,7 @@ DEBUG = True INTERNAL_IPS = ["127.0.0.1"] -INSTALLED_APPS.append("debug_toolbar") -INSTALLED_APPS.append("django_extensions") +INSTALLED_APPS.append("debug_toolbar") # noqa: F405 +INSTALLED_APPS.append("django_extensions") # noqa: F405 -MIDDLEWARE.insert(0, "debug_toolbar.middleware.DebugToolbarMiddleware") +MIDDLEWARE.insert(0, "debug_toolbar.middleware.DebugToolbarMiddleware") # noqa: F405 diff --git a/cmsmanage/settings/prod_base.py b/cmsmanage/settings/prod_base.py index 4ec1673..5809b48 100644 --- a/cmsmanage/settings/prod_base.py +++ b/cmsmanage/settings/prod_base.py @@ -1,7 +1,7 @@ import ldap -from django_auth_ldap.config import LDAPSearch, PosixGroupType, LDAPGroupQuery +from django_auth_ldap.config import LDAPGroupQuery, LDAPSearch, PosixGroupType -from .base import * +from .base import * # noqa: F403 DEBUG = False diff --git a/cmsmanage/urls.py b/cmsmanage/urls.py index 4ab64dc..f792b75 100644 --- a/cmsmanage/urls.py +++ b/cmsmanage/urls.py @@ -13,16 +13,15 @@ Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -from django.contrib import admin -from django.shortcuts import redirect -from django.urls import include, path -from django.contrib.auth.views import LoginView, LogoutView from django.conf import settings +from django.contrib import admin +from django.contrib.auth.views import LoginView, LogoutView +from django.urls import include, path from rest_framework import routers -from paperwork.api import router as paperwork_router from membershipworks.api import router as membershipworks_router +from paperwork.api import router as paperwork_router router = routers.DefaultRouter() router.registry.extend(paperwork_router.registry) diff --git a/dashboard/tests.py b/dashboard/tests.py index 7ce503c..a39b155 100644 --- a/dashboard/tests.py +++ b/dashboard/tests.py @@ -1,3 +1 @@ -from django.test import TestCase - # Create your tests here. diff --git a/doorcontrol/dashboard.py b/doorcontrol/dashboard.py index 7db8e52..baf7d2b 100644 --- a/doorcontrol/dashboard.py +++ b/doorcontrol/dashboard.py @@ -1,6 +1,7 @@ from typing import Any import dashboard + from .views import REPORTS diff --git a/doorcontrol/migrations/0002_door_remove_hidevent_door_name_and_more.py b/doorcontrol/migrations/0002_door_remove_hidevent_door_name_and_more.py index db9fba2..3d8116a 100644 --- a/doorcontrol/migrations/0002_door_remove_hidevent_door_name_and_more.py +++ b/doorcontrol/migrations/0002_door_remove_hidevent_door_name_and_more.py @@ -1,7 +1,7 @@ # Generated by Django 4.2.5 on 2023-09-19 04:20 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models def link_events_to_doors(apps, schema_editor): diff --git a/doorcontrol/tests.py b/doorcontrol/tests.py index 7ce503c..a39b155 100644 --- a/doorcontrol/tests.py +++ b/doorcontrol/tests.py @@ -1,3 +1 @@ -from django.test import TestCase - # Create your tests here. diff --git a/doorcontrol/views.py b/doorcontrol/views.py index b7293ba..d02c6bc 100644 --- a/doorcontrol/views.py +++ b/doorcontrol/views.py @@ -2,23 +2,19 @@ import calendar import datetime from django.contrib.auth.mixins import PermissionRequiredMixin -from django.core.paginator import Page from django.core.exceptions import BadRequest -from django.db.models import Count -from django.db.models.functions import Trunc -from django.urls import reverse_lazy, path +from django.core.paginator import Page +from django.db.models import Count, F, FloatField, Window +from django.db.models.functions import Lead, Trunc +from django.urls import path, reverse_lazy from django.utils import dateparse from django.utils.formats import date_format from django.utils.text import slugify from django.utils.timezone import localtime from django.views.generic.list import ListView -from django.db.models import Window, F, FloatField -from django.db.models.functions import Lead - from .models import HIDEvent - REPORTS = [] diff --git a/membershipworks/__init__.py b/membershipworks/__init__.py index c609103..e69de29 100644 --- a/membershipworks/__init__.py +++ b/membershipworks/__init__.py @@ -1 +0,0 @@ -from .membershipworks_api import MembershipWorks, MembershipWorksRemoteError diff --git a/membershipworks/admin.py b/membershipworks/admin.py index a2477dd..11fe82f 100644 --- a/membershipworks/admin.py +++ b/membershipworks/admin.py @@ -3,17 +3,17 @@ from django.contrib.humanize.templatetags.humanize import naturaltime from django.utils.html import format_html from django_object_actions import DjangoObjectActions, action -from django_q.tasks import async_task from django_q.models import Task +from django_q.tasks import async_task from .models import ( - Member, - Flag, - Transaction, Event, EventExt, - EventMeetingTime, EventInstructor, + EventMeetingTime, + Flag, + Member, + Transaction, ) from .tasks.scrape import scrape_membershipworks diff --git a/membershipworks/api.py b/membershipworks/api.py index b47defa..b938735 100644 --- a/membershipworks/api.py +++ b/membershipworks/api.py @@ -1,6 +1,6 @@ from rest_framework import routers, serializers, viewsets -from .models import Member, Flag +from .models import Flag, Member class MemberSerializer(serializers.HyperlinkedModelSerializer): diff --git a/membershipworks/apps.py b/membershipworks/apps.py index eca425a..167b4e2 100644 --- a/membershipworks/apps.py +++ b/membershipworks/apps.py @@ -7,7 +7,7 @@ def post_migrate_callback(sender, **kwargs): from cmsmanage.django_q2_helper import ensure_scheduled - from .tasks.scrape import scrape_membershipworks, scrape_events + from .tasks.scrape import scrape_events, scrape_membershipworks from .tasks.ucsAccounts import sync_accounts ensure_scheduled( diff --git a/membershipworks/dashboard.py b/membershipworks/dashboard.py index d2bdb45..2520088 100644 --- a/membershipworks/dashboard.py +++ b/membershipworks/dashboard.py @@ -1,5 +1,5 @@ -from typing import Any from datetime import datetime +from typing import Any from django.urls import reverse diff --git a/membershipworks/membershipworks_api.py b/membershipworks/membershipworks_api.py index 538830e..0244336 100644 --- a/membershipworks/membershipworks_api.py +++ b/membershipworks/membershipworks_api.py @@ -1,8 +1,8 @@ import csv +import datetime from io import StringIO import requests -import datetime BASE_URL = "https://api.membershipworks.com" @@ -133,7 +133,7 @@ class MembershipWorks: for screen_type in ["anm", "acc", "adm"]: for box in self.org_info["tpl"][screen_type]: for element in box["box"]: - if type(element["dat"]) != str: + if not isinstance(element["dat"], str): for field in element["dat"]: if "_id" in field: if field["_id"] not in fields: diff --git a/membershipworks/migrations/0002_remove_member_accepted_covid19_policy_and_more.py b/membershipworks/migrations/0002_remove_member_accepted_covid19_policy_and_more.py index 4c6db48..08d9597 100644 --- a/membershipworks/migrations/0002_remove_member_accepted_covid19_policy_and_more.py +++ b/membershipworks/migrations/0002_remove_member_accepted_covid19_policy_and_more.py @@ -4,7 +4,6 @@ from django.db import migrations class Migration(migrations.Migration): - dependencies = [ ("membershipworks", "0001_initial"), ] diff --git a/membershipworks/models.py b/membershipworks/models.py index 180ed1b..1a65dda 100644 --- a/membershipworks/models.py +++ b/membershipworks/models.py @@ -1,5 +1,5 @@ -from typing import Optional from datetime import datetime +from typing import Optional import django.core.mail.message from django.conf import settings diff --git a/membershipworks/tasks/scrape.py b/membershipworks/tasks/scrape.py index e10338c..bb01295 100644 --- a/membershipworks/tasks/scrape.py +++ b/membershipworks/tasks/scrape.py @@ -1,18 +1,18 @@ -from datetime import datetime, timedelta import logging +from datetime import datetime, timedelta from django.conf import settings from django.db import transaction +from membershipworks.membershipworks_api import MembershipWorks from membershipworks.models import ( - Member, - Flag, - Transaction, Event, - EventExt, EventCategory, + EventExt, + Flag, + Member, + Transaction, ) -from membershipworks import MembershipWorks logger = logging.getLogger(__name__) diff --git a/membershipworks/tasks/ucsAccounts.py b/membershipworks/tasks/ucsAccounts.py index 2e1f788..83689b1 100644 --- a/membershipworks/tasks/ucsAccounts.py +++ b/membershipworks/tasks/ucsAccounts.py @@ -4,10 +4,11 @@ import re import string from django.conf import settings -from udm_rest_client.udm import UDM -from udm_rest_client.exceptions import NoObject, UdmError -from membershipworks.models import Member, Flag +from udm_rest_client.exceptions import NoObject, UdmError +from udm_rest_client.udm import UDM + +from membershipworks.models import Flag, Member USER_BASE = "cn=users,dc=sawtooth,dc=claremontmakerspace,dc=org" GROUP_BASE = "cn=groups,dc=sawtooth,dc=claremontmakerspace,dc=org" diff --git a/membershipworks/tests.py b/membershipworks/tests.py index 7ce503c..a39b155 100644 --- a/membershipworks/tests.py +++ b/membershipworks/tests.py @@ -1,3 +1 @@ -from django.test import TestCase - # Create your tests here. diff --git a/membershipworks/urls.py b/membershipworks/urls.py index ba1e97f..48084c5 100644 --- a/membershipworks/urls.py +++ b/membershipworks/urls.py @@ -1,6 +1,6 @@ from django.urls import path -from .views import MemberAutocomplete, upcoming_events, EventMonthReport +from .views import EventMonthReport, MemberAutocomplete, upcoming_events app_name = "membershipworks" diff --git a/membershipworks/views.py b/membershipworks/views.py index 229e3de..af137b7 100644 --- a/membershipworks/views.py +++ b/membershipworks/views.py @@ -9,8 +9,9 @@ from django.views.generic.dates import MonthArchiveView from dal import autocomplete -from .models import Member, EventExt -from membershipworks import MembershipWorks +from membershipworks.membershipworks_api import MembershipWorks + +from .models import EventExt, Member class MemberAutocomplete(autocomplete.Select2QuerySetView): diff --git a/paperwork/admin.py b/paperwork/admin.py index 1d8862b..453eab4 100644 --- a/paperwork/admin.py +++ b/paperwork/admin.py @@ -1,29 +1,29 @@ -from typing import Optional, Any, Type, cast +from typing import Any, Optional, Type, cast from django import forms -from django.core import mail from django.contrib import admin, messages +from django.core import mail from django.db.models import Value +from django.db.models.functions import Concat, LPad, Now from django.db.models.query import QuerySet -from django.db.models.functions import Now, Concat, LPad from django.http import HttpRequest +from .certification_emails import all_certification_emails +from .forms import CertificationForm from .models import ( AbstractAudit, - CmsRedRiverVeteransScholarship, - Department, - CertificationDefinition, Certification, CertificationAudit, + CertificationDefinition, CertificationVersion, CertificationVersionAnnotated, + CmsRedRiverVeteransScholarship, + Department, InstructorOrVendor, SpecialProgram, Waiver, WaiverAudit, ) -from .forms import CertificationForm -from .certification_emails import all_certification_emails class AlwaysChangedModelForm(forms.models.ModelForm): diff --git a/paperwork/api.py b/paperwork/api.py index c346fd8..5a1bebe 100644 --- a/paperwork/api.py +++ b/paperwork/api.py @@ -1,14 +1,16 @@ -from rest_framework import routers, serializers, viewsets from django.db.models import Prefetch, Q + +from rest_framework import routers, serializers, viewsets from rest_framework.decorators import action from rest_framework.response import Response from membershipworks.models import Member + from .models import ( - Department, Certification, CertificationDefinition, CertificationVersion, + Department, ) diff --git a/paperwork/autocomplete_views.py b/paperwork/autocomplete_views.py index f35d15b..afe59a0 100644 --- a/paperwork/autocomplete_views.py +++ b/paperwork/autocomplete_views.py @@ -1,6 +1,7 @@ -from dal import autocomplete +from django.db.models import CharField, Q, Value from django.db.models.functions import Concat -from django.db.models import Q, Value, CharField + +from dal import autocomplete from .models import CertificationVersion diff --git a/paperwork/certification_emails.py b/paperwork/certification_emails.py index a5ade51..33ae9a8 100644 --- a/paperwork/certification_emails.py +++ b/paperwork/certification_emails.py @@ -1,12 +1,12 @@ from itertools import groupby +from django.contrib.auth import get_user_model from django.core import mail from django.core.mail.message import sanitize_address -from django.contrib.auth import get_user_model from django.template import loader -from markdownify import markdownify import mdformat +from markdownify import markdownify def make_multipart_email(subject, html_body, to): diff --git a/paperwork/dashboard.py b/paperwork/dashboard.py index c0e442b..50eb864 100644 --- a/paperwork/dashboard.py +++ b/paperwork/dashboard.py @@ -4,6 +4,7 @@ from django.urls import reverse import dashboard from membershipworks.models import Member + from .models import Department diff --git a/paperwork/forms.py b/paperwork/forms.py index 21bacac..955f7cb 100644 --- a/paperwork/forms.py +++ b/paperwork/forms.py @@ -1,9 +1,9 @@ -from dal import autocomplete - from django import forms from django.core.exceptions import ValidationError -from .models import CertificationDefinition, Certification +from dal import autocomplete + +from .models import Certification, CertificationDefinition class CertificationForm(forms.ModelForm): diff --git a/paperwork/migrations/0001_initial.py b/paperwork/migrations/0001_initial.py index 94c3a7d..0547c3f 100644 --- a/paperwork/migrations/0001_initial.py +++ b/paperwork/migrations/0001_initial.py @@ -1,7 +1,7 @@ # Generated by Django 4.0.2 on 2022-02-03 21:12 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/paperwork/migrations/0002_add_certification_version_model.py b/paperwork/migrations/0002_add_certification_version_model.py index 563955a..88776e4 100644 --- a/paperwork/migrations/0002_add_certification_version_model.py +++ b/paperwork/migrations/0002_add_certification_version_model.py @@ -1,7 +1,7 @@ # (Partially) Generated by Django 4.0.2 on 2022-02-04 18:01 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models def migrate_certification_version_forward(apps, schema_editor): diff --git a/paperwork/migrations/0006_department_alter_certificationdefinition_department.py b/paperwork/migrations/0006_department_alter_certificationdefinition_department.py index a8f3ede..89bf629 100644 --- a/paperwork/migrations/0006_department_alter_certificationdefinition_department.py +++ b/paperwork/migrations/0006_department_alter_certificationdefinition_department.py @@ -1,8 +1,8 @@ # Generated by Django 4.1.3 on 2023-01-18 03:31 import django.core.validators -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models def link_departments(apps, schema_editor): diff --git a/paperwork/migrations/0009_rename_department_list_moderator_flag_to_shop_lead_flag.py b/paperwork/migrations/0009_rename_department_list_moderator_flag_to_shop_lead_flag.py index 2e8870f..53a54e9 100644 --- a/paperwork/migrations/0009_rename_department_list_moderator_flag_to_shop_lead_flag.py +++ b/paperwork/migrations/0009_rename_department_list_moderator_flag_to_shop_lead_flag.py @@ -1,7 +1,7 @@ # Generated by Django 4.1.3 on 2023-01-24 02:02 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/paperwork/migrations/0010_switch_certificationversion_to_semver.py b/paperwork/migrations/0010_switch_certificationversion_to_semver.py index 2b1cfbe..066296c 100644 --- a/paperwork/migrations/0010_switch_certificationversion_to_semver.py +++ b/paperwork/migrations/0010_switch_certificationversion_to_semver.py @@ -3,7 +3,6 @@ from datetime import date from django.db import migrations, models -import django.db.models.deletion from semver import VersionInfo diff --git a/paperwork/migrations/0012_waiveraudit_certificationaudit.py b/paperwork/migrations/0012_waiveraudit_certificationaudit.py index 18151af..48ddeca 100644 --- a/paperwork/migrations/0012_waiveraudit_certificationaudit.py +++ b/paperwork/migrations/0012_waiveraudit_certificationaudit.py @@ -1,9 +1,10 @@ # Generated by Django 4.2 on 2023-04-10 05:34 import datetime + +import django.db.models.deletion from django.conf import settings from django.db import migrations, models -import django.db.models.deletion class Migration(migrations.Migration): diff --git a/paperwork/migrations/0014_alter_certificationdefinition_options_and_more.py b/paperwork/migrations/0014_alter_certificationdefinition_options_and_more.py index dd6d205..1d9767b 100644 --- a/paperwork/migrations/0014_alter_certificationdefinition_options_and_more.py +++ b/paperwork/migrations/0014_alter_certificationdefinition_options_and_more.py @@ -1,7 +1,7 @@ # Generated by Django 4.2 on 2023-04-10 18:37 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/paperwork/models.py b/paperwork/models.py index 7d6c3ba..fec69bf 100644 --- a/paperwork/models.py +++ b/paperwork/models.py @@ -1,16 +1,18 @@ import datetime import re -from typing import TypedDict, TYPE_CHECKING, Optional +from typing import TYPE_CHECKING, Optional, TypedDict -from semver import VersionInfo +from django.conf import settings +from django.core.validators import RegexValidator from django.db import models from django.db.models import Q, Window from django.db.models.functions import FirstValue -from django.conf import settings -from django.core.validators import RegexValidator -from django_stubs_ext import WithAnnotations -from membershipworks.models import Member, Flag as MembershipWorksFlag +from django_stubs_ext import WithAnnotations +from semver import VersionInfo + +from membershipworks.models import Flag as MembershipWorksFlag +from membershipworks.models import Member class AbstractAudit(models.Model): diff --git a/paperwork/tests.py b/paperwork/tests.py index 7ce503c..a39b155 100644 --- a/paperwork/tests.py +++ b/paperwork/tests.py @@ -1,3 +1 @@ -from django.test import TestCase - # Create your tests here. diff --git a/paperwork/urls.py b/paperwork/urls.py index f23531f..e273c4d 100644 --- a/paperwork/urls.py +++ b/paperwork/urls.py @@ -1,7 +1,6 @@ from django.urls import path -from . import views -from . import autocomplete_views +from . import autocomplete_views, views app_name = "paperwork" diff --git a/paperwork/views.py b/paperwork/views.py index f284116..ed6d057 100644 --- a/paperwork/views.py +++ b/paperwork/views.py @@ -9,6 +9,7 @@ import requests import weasyprint from membershipworks.models import Member + from .models import Certification, Department WIKI_URL = settings.WIKI_URL diff --git a/pdm.lock b/pdm.lock index f09a01e..a6b8951 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "debug", "lint", "server", "typing", "dev"] strategy = ["cross_platform"] lock_version = "4.4.1" -content_hash = "sha256:91f554bae127245b4082d069629400706b8b43daf3bf1fb8fd963eee120ff449" +content_hash = "sha256:73715d6c541091f09cb8dea4f2baba6b58b0972a615b44e6f85869f918fdb360" [[package]] name = "aiohttp" @@ -164,31 +164,6 @@ files = [ {file = "beautifulsoup4-4.11.1.tar.gz", hash = "sha256:ad9aa55b65ef2808eb405f46cf74df7fcb7044d5cbc26487f96eb2ef2e436693"}, ] -[[package]] -name = "black" -version = "23.12.1" -requires_python = ">=3.8" -summary = "The uncompromising code formatter." -dependencies = [ - "click>=8.0.0", - "mypy-extensions>=0.4.3", - "packaging>=22.0", - "pathspec>=0.9.0", - "platformdirs>=2", -] -files = [ - {file = "black-23.12.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:8d4df77958a622f9b5a4c96edb4b8c0034f8434032ab11077ec6c56ae9f384ba"}, - {file = "black-23.12.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:602cfb1196dc692424c70b6507593a2b29aac0547c1be9a1d1365f0d964c353b"}, - {file = "black-23.12.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9c4352800f14be5b4864016882cdba10755bd50805c95f728011bcb47a4afd59"}, - {file = "black-23.12.1-cp311-cp311-win_amd64.whl", hash = "sha256:0808494f2b2df923ffc5723ed3c7b096bd76341f6213989759287611e9837d50"}, - {file = "black-23.12.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:25e57fd232a6d6ff3f4478a6fd0580838e47c93c83eaf1ccc92d4faf27112c4e"}, - {file = "black-23.12.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2d9e13db441c509a3763a7a3d9a49ccc1b4e974a47be4e08ade2a228876500ec"}, - {file = "black-23.12.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d1bd9c210f8b109b1762ec9fd36592fdd528485aadb3f5849b2740ef17e674e"}, - {file = "black-23.12.1-cp312-cp312-win_amd64.whl", hash = "sha256:ae76c22bde5cbb6bfd211ec343ded2163bba7883c7bc77f6b756a1049436fbb9"}, - {file = "black-23.12.1-py3-none-any.whl", hash = "sha256:78baad24af0f033958cad29731e27363183e140962595def56423e626f4bee3e"}, - {file = "black-23.12.1.tar.gz", hash = "sha256:4ce3ef14ebe8d9509188014d96af1c456a910d5b5cbf434a09fef7e024b3d0d5"}, -] - [[package]] name = "brotli" version = "1.0.9" @@ -1291,16 +1266,6 @@ files = [ {file = "Pillow-9.3.0.tar.gz", hash = "sha256:c935a22a557a560108d780f9a0fc426dd7459940dc54faa49d83249c8d3e760f"}, ] -[[package]] -name = "platformdirs" -version = "2.5.3" -requires_python = ">=3.7" -summary = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -files = [ - {file = "platformdirs-2.5.3-py3-none-any.whl", hash = "sha256:0cb405749187a194f444c25c82ef7225232f11564721eabffc6ec70df83b11cb"}, - {file = "platformdirs-2.5.3.tar.gz", hash = "sha256:6e52c21afff35cb659c6e52d8b4d61b9bd544557180440538f255d9382c8cbe0"}, -] - [[package]] name = "prompt-toolkit" version = "3.0.41" @@ -1554,6 +1519,31 @@ files = [ {file = "requests-2.31.0.tar.gz", hash = "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"}, ] +[[package]] +name = "ruff" +version = "0.1.13" +requires_python = ">=3.7" +summary = "An extremely fast Python linter and code formatter, written in Rust." +files = [ + {file = "ruff-0.1.13-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:e3fd36e0d48aeac672aa850045e784673449ce619afc12823ea7868fcc41d8ba"}, + {file = "ruff-0.1.13-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:9fb6b3b86450d4ec6a6732f9f60c4406061b6851c4b29f944f8c9d91c3611c7a"}, + {file = "ruff-0.1.13-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b13ba5d7156daaf3fd08b6b993360a96060500aca7e307d95ecbc5bb47a69296"}, + {file = "ruff-0.1.13-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:9ebb40442f7b531e136d334ef0851412410061e65d61ca8ce90d894a094feb22"}, + {file = "ruff-0.1.13-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:226b517f42d59a543d6383cfe03cccf0091e3e0ed1b856c6824be03d2a75d3b6"}, + {file = "ruff-0.1.13-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:5f0312ba1061e9b8c724e9a702d3c8621e3c6e6c2c9bd862550ab2951ac75c16"}, + {file = "ruff-0.1.13-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2f59bcf5217c661254bd6bc42d65a6fd1a8b80c48763cb5c2293295babd945dd"}, + {file = "ruff-0.1.13-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e6894b00495e00c27b6ba61af1fc666f17de6140345e5ef27dd6e08fb987259d"}, + {file = "ruff-0.1.13-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9a1600942485c6e66119da294c6294856b5c86fd6df591ce293e4a4cc8e72989"}, + {file = "ruff-0.1.13-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:ee3febce7863e231a467f90e681d3d89210b900d49ce88723ce052c8761be8c7"}, + {file = "ruff-0.1.13-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:dcaab50e278ff497ee4d1fe69b29ca0a9a47cd954bb17963628fa417933c6eb1"}, + {file = "ruff-0.1.13-py3-none-musllinux_1_2_i686.whl", hash = "sha256:f57de973de4edef3ad3044d6a50c02ad9fc2dff0d88587f25f1a48e3f72edf5e"}, + {file = "ruff-0.1.13-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:7a36fa90eb12208272a858475ec43ac811ac37e91ef868759770b71bdabe27b6"}, + {file = "ruff-0.1.13-py3-none-win32.whl", hash = "sha256:a623349a505ff768dad6bd57087e2461be8db58305ebd5577bd0e98631f9ae69"}, + {file = "ruff-0.1.13-py3-none-win_amd64.whl", hash = "sha256:f988746e3c3982bea7f824c8fa318ce7f538c4dfefec99cd09c8770bd33e6539"}, + {file = "ruff-0.1.13-py3-none-win_arm64.whl", hash = "sha256:6bbbc3042075871ec17f28864808540a26f0f79a4478c357d3e3d2284e832998"}, + {file = "ruff-0.1.13.tar.gz", hash = "sha256:e261f1baed6291f434ffb1d5c6bd8051d1c2a26958072d38dfbec39b3dda7352"}, +] + [[package]] name = "semver" version = "3.0.2" diff --git a/pyproject.toml b/pyproject.toml index ba42452..4c281ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,8 +41,24 @@ server = [ [project.entry-points."djangoq.errorreporters"] admin_email = "cmsmanage.django_q2_admin_email_reporter:AdminEmailReporter" -[tool.black] +[tool.ruff] line-length = 88 +select = ["E4", "E7", "E9", "F", "I"] + +[tool.ruff.lint.isort] +known-first-party = [ + "cmsmanage", + "dashboard", + "doorcontrol", + "membershipworks", + "paperwork", + "rentals", + "tasks", +] +section-order = ["future", "standard-library", "django", "third-party", "first-party", "local-folder"] + +[tool.ruff.lint.isort.sections] +"django" = ["django"] [tool.djlint] profile="django" @@ -82,8 +98,8 @@ include_packages = ["openapi-client-udm"] [tool.pdm.dev-dependencies] lint = [ - "black~=23.12", "djlint~=1.34", + "ruff~=0.1", ] typing = [ "mypy~=1.7", diff --git a/rentals/admin.py b/rentals/admin.py index f92ab8f..a3ae7d6 100644 --- a/rentals/admin.py +++ b/rentals/admin.py @@ -1,8 +1,9 @@ -from django.db.models import Prefetch -from django.contrib import admin from django import forms +from django.contrib import admin +from django.db.models import Prefetch from membershipworks.models import Member + from .models import LockerBank, LockerInfo, LockerUnit diff --git a/rentals/migrations/0001_initial.py b/rentals/migrations/0001_initial.py index 1125b2f..c279d06 100644 --- a/rentals/migrations/0001_initial.py +++ b/rentals/migrations/0001_initial.py @@ -1,8 +1,8 @@ # Generated by Django 4.0.2 on 2022-02-16 21:19 import django.core.validators -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/rentals/models.py b/rentals/models.py index 09c0cf3..7e6eaa6 100644 --- a/rentals/models.py +++ b/rentals/models.py @@ -3,8 +3,7 @@ from django.core import validators from django.core.exceptions import ValidationError from django.db import models, transaction from django.db.models import F, Q -from django.db.models.functions import Chr, Ord, Concat - +from django.db.models.functions import Chr, Concat, Ord from membershipworks.models import Member diff --git a/rentals/tests.py b/rentals/tests.py index 7ce503c..a39b155 100644 --- a/rentals/tests.py +++ b/rentals/tests.py @@ -1,3 +1 @@ -from django.test import TestCase - # Create your tests here. diff --git a/rentals/views.py b/rentals/views.py index f2f101a..91bfa7d 100644 --- a/rentals/views.py +++ b/rentals/views.py @@ -1,12 +1,11 @@ -from django.contrib.auth.decorators import login_required, permission_required 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.urls import reverse -from .models import LockerBank, LockerInfo - from .forms import LockerInfoForm +from .models import LockerBank, LockerInfo def lockerIndex(request): diff --git a/tasks/admin.py b/tasks/admin.py index a9fb681..b144aa1 100644 --- a/tasks/admin.py +++ b/tasks/admin.py @@ -1,7 +1,8 @@ from django.contrib import admin + from markdownx.admin import MarkdownxModelAdmin -from .models import Tool, Task, Event, GroupTaskSubscription, GroupToolSubscription +from .models import Event, GroupTaskSubscription, GroupToolSubscription, Task, Tool class GroupTaskSubscriptionInline(admin.TabularInline): diff --git a/tasks/forms.py b/tasks/forms.py index 5d581d0..1229f14 100644 --- a/tasks/forms.py +++ b/tasks/forms.py @@ -1,6 +1,7 @@ from datetime import datetime from django import forms + from markdownx.widgets import MarkdownxWidget from .models import Event diff --git a/tasks/management/commands/sendNotifications.py b/tasks/management/commands/sendNotifications.py index aed570b..5b21c12 100644 --- a/tasks/management/commands/sendNotifications.py +++ b/tasks/management/commands/sendNotifications.py @@ -1,10 +1,8 @@ -from itertools import groupby - from django.core.mail import send_mail -from django.core.management.base import BaseCommand, CommandError +from django.core.management.base import BaseCommand from django.template import loader -from tasks.models import Tool, Task, Event, GroupToolSubscription, GroupTaskSubscription +from tasks.models import GroupTaskSubscription, GroupToolSubscription class Command(BaseCommand): diff --git a/tasks/migrations/0001_initial.py b/tasks/migrations/0001_initial.py index 3acdbb8..8c3b85b 100644 --- a/tasks/migrations/0001_initial.py +++ b/tasks/migrations/0001_initial.py @@ -1,8 +1,9 @@ # Generated by Django 3.2.3 on 2021-05-19 18:05 +import django.db.models.deletion from django.conf import settings from django.db import migrations, models -import django.db.models.deletion + import markdownx.models diff --git a/tasks/migrations/0003_task_recurrence.py b/tasks/migrations/0003_task_recurrence.py index 0f9f141..40762d9 100644 --- a/tasks/migrations/0003_task_recurrence.py +++ b/tasks/migrations/0003_task_recurrence.py @@ -1,6 +1,7 @@ # Generated by Django 3.2.3 on 2021-05-19 21:46 from django.db import migrations + import recurrence import recurrence.fields diff --git a/tasks/models.py b/tasks/models.py index 82638e3..4f71c12 100644 --- a/tasks/models.py +++ b/tasks/models.py @@ -4,6 +4,7 @@ from django.contrib.auth import get_user_model from django.contrib.auth.models import Group from django.db import models from django.urls import reverse + from markdownx.models import MarkdownxField from recurrence.fields import RecurrenceField diff --git a/tasks/templates/tasks/taskDetail.dj.html b/tasks/templates/tasks/taskDetail.dj.html index 091795e..83f2382 100644 --- a/tasks/templates/tasks/taskDetail.dj.html +++ b/tasks/templates/tasks/taskDetail.dj.html @@ -120,9 +120,7 @@ {{ event.date }} {{ event.user }} - - {{ event.notes_html|safe }} - + {{ event.notes_html|safe }} {% endfor %} diff --git a/tasks/tests.py b/tasks/tests.py index 7ce503c..a39b155 100644 --- a/tasks/tests.py +++ b/tasks/tests.py @@ -1,3 +1 @@ -from django.test import TestCase - # Create your tests here. diff --git a/tasks/views.py b/tasks/views.py index 8f7c006..3cafc4a 100644 --- a/tasks/views.py +++ b/tasks/views.py @@ -1,8 +1,7 @@ from django.shortcuts import get_object_or_404, render -from django.http import HttpResponse -from .models import Tool, Task, Event from .forms import EventForm +from .models import Event, Task, Tool def index(request): diff --git a/templates/base.dj.html b/templates/base.dj.html index 5f688f6..8e92773 100644 --- a/templates/base.dj.html +++ b/templates/base.dj.html @@ -39,27 +39,43 @@