From 11158d73133f5a5ac0451676974ea705d74c9a70 Mon Sep 17 00:00:00 2001 From: David Cain Date: Sat, 24 Feb 2024 04:44:15 -0700 Subject: [PATCH] Upgrade to newest ruff Ruff version 0.2 has a number of bugfixes & optimizations, but also changes the structure of pyproject.toml -- we can upgrade straight to 0.3.5. --- poetry.lock | 36 ++++++++++++++++++------------------ pyproject.toml | 10 +++++----- ws/car_states.py | 1 + ws/conf/local_settings.py | 9 +++++---- ws/conf/test_settings.py | 1 + ws/merge.py | 1 + ws/messages/__init__.py | 1 + ws/messages/leader.py | 1 + ws/mixins.py | 1 + ws/signals/signup_signals.py | 1 + ws/unsubscribe.py | 1 + ws/utils/dates.py | 1 + ws/utils/geardb.py | 1 + ws/utils/member_sheets.py | 1 + ws/utils/membership_api.py | 1 + ws/views/account.py | 1 + ws/views/applications.py | 1 + ws/views/itinerary.py | 1 + ws/views/leaders.py | 1 + ws/views/participant.py | 1 + ws/views/preferences.py | 1 + ws/views/trips.py | 1 + ws/views/winter_school.py | 1 + 23 files changed, 48 insertions(+), 27 deletions(-) diff --git a/poetry.lock b/poetry.lock index e03f2f03..7104812c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1837,28 +1837,28 @@ pyasn1 = ">=0.1.3" [[package]] name = "ruff" -version = "0.1.14" +version = "0.3.5" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.1.14-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:96f76536df9b26622755c12ed8680f159817be2f725c17ed9305b472a757cdbb"}, - {file = "ruff-0.1.14-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:ab3f71f64498c7241123bb5a768544cf42821d2a537f894b22457a543d3ca7a9"}, - {file = "ruff-0.1.14-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7060156ecc572b8f984fd20fd8b0fcb692dd5d837b7606e968334ab7ff0090ab"}, - {file = "ruff-0.1.14-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:a53d8e35313d7b67eb3db15a66c08434809107659226a90dcd7acb2afa55faea"}, - {file = "ruff-0.1.14-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:bea9be712b8f5b4ebed40e1949379cfb2a7d907f42921cf9ab3aae07e6fba9eb"}, - {file = "ruff-0.1.14-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:2270504d629a0b064247983cbc495bed277f372fb9eaba41e5cf51f7ba705a6a"}, - {file = "ruff-0.1.14-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:80258bb3b8909b1700610dfabef7876423eed1bc930fe177c71c414921898efa"}, - {file = "ruff-0.1.14-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:653230dd00aaf449eb5ff25d10a6e03bc3006813e2cb99799e568f55482e5cae"}, - {file = "ruff-0.1.14-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:87b3acc6c4e6928459ba9eb7459dd4f0c4bf266a053c863d72a44c33246bfdbf"}, - {file = "ruff-0.1.14-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:6b3dadc9522d0eccc060699a9816e8127b27addbb4697fc0c08611e4e6aeb8b5"}, - {file = "ruff-0.1.14-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:1c8eca1a47b4150dc0fbec7fe68fc91c695aed798532a18dbb1424e61e9b721f"}, - {file = "ruff-0.1.14-py3-none-musllinux_1_2_i686.whl", hash = "sha256:62ce2ae46303ee896fc6811f63d6dabf8d9c389da0f3e3f2bce8bc7f15ef5488"}, - {file = "ruff-0.1.14-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:b2027dde79d217b211d725fc833e8965dc90a16d0d3213f1298f97465956661b"}, - {file = "ruff-0.1.14-py3-none-win32.whl", hash = "sha256:722bafc299145575a63bbd6b5069cb643eaa62546a5b6398f82b3e4403329cab"}, - {file = "ruff-0.1.14-py3-none-win_amd64.whl", hash = "sha256:e3d241aa61f92b0805a7082bd89a9990826448e4d0398f0e2bc8f05c75c63d99"}, - {file = "ruff-0.1.14-py3-none-win_arm64.whl", hash = "sha256:269302b31ade4cde6cf6f9dd58ea593773a37ed3f7b97e793c8594b262466b67"}, - {file = "ruff-0.1.14.tar.gz", hash = "sha256:ad3f8088b2dfd884820289a06ab718cde7d38b94972212cc4ba90d5fbc9955f3"}, + {file = "ruff-0.3.5-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:aef5bd3b89e657007e1be6b16553c8813b221ff6d92c7526b7e0227450981eac"}, + {file = "ruff-0.3.5-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:89b1e92b3bd9fca249153a97d23f29bed3992cff414b222fcd361d763fc53f12"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5e55771559c89272c3ebab23326dc23e7f813e492052391fe7950c1a5a139d89"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:dabc62195bf54b8a7876add6e789caae0268f34582333cda340497c886111c39"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3a05f3793ba25f194f395578579c546ca5d83e0195f992edc32e5907d142bfa3"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:dfd3504e881082959b4160ab02f7a205f0fadc0a9619cc481982b6837b2fd4c0"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:87258e0d4b04046cf1d6cc1c56fadbf7a880cc3de1f7294938e923234cf9e498"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:712e71283fc7d9f95047ed5f793bc019b0b0a29849b14664a60fd66c23b96da1"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a532a90b4a18d3f722c124c513ffb5e5eaff0cc4f6d3aa4bda38e691b8600c9f"}, + {file = "ruff-0.3.5-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:122de171a147c76ada00f76df533b54676f6e321e61bd8656ae54be326c10296"}, + {file = "ruff-0.3.5-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:d80a6b18a6c3b6ed25b71b05eba183f37d9bc8b16ace9e3d700997f00b74660b"}, + {file = "ruff-0.3.5-py3-none-musllinux_1_2_i686.whl", hash = "sha256:a7b6e63194c68bca8e71f81de30cfa6f58ff70393cf45aab4c20f158227d5936"}, + {file = "ruff-0.3.5-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:a759d33a20c72f2dfa54dae6e85e1225b8e302e8ac655773aff22e542a300985"}, + {file = "ruff-0.3.5-py3-none-win32.whl", hash = "sha256:9d8605aa990045517c911726d21293ef4baa64f87265896e491a05461cae078d"}, + {file = "ruff-0.3.5-py3-none-win_amd64.whl", hash = "sha256:dc56bb16a63c1303bd47563c60482a1512721053d93231cf7e9e1c6954395a0e"}, + {file = "ruff-0.3.5-py3-none-win_arm64.whl", hash = "sha256:faeeae9905446b975dcf6d4499dc93439b131f1443ee264055c5716dd947af55"}, + {file = "ruff-0.3.5.tar.gz", hash = "sha256:a067daaeb1dc2baf9b82a32dae67d154d95212080c80435eb052d95da647763d"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index b7ea3333..7983fbf2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.ruff] -select = [ +lint.select = [ "A", # flake8-builtins "ANN", # flake8-annotations "ARG", # flake8-unused-arguments @@ -65,7 +65,7 @@ select = [ # "NPY", # NumPy-specific rules -- I don't use numpy ] -ignore = [ +lint.ignore = [ # Specific rules ignored from checkers I otherwise view as valuable: "ANN001", # Type annotations are knowingly incomplete. "ANN002", # Type annotations are knowingly incomplete. @@ -113,10 +113,10 @@ exclude = [ "static/", ] -fixable = ["ALL"] -unfixable = [] +lint.fixable = ["ALL"] +lint.unfixable = [] -[tool.ruff.flake8-self] +[tool.ruff.lint.flake8-self] ignore-names = [ "_asdict", "_replace", diff --git a/ws/car_states.py b/ws/car_states.py index 56332230..bb4a401e 100644 --- a/ws/car_states.py +++ b/ws/car_states.py @@ -3,6 +3,7 @@ We used to rely on `localflavor` for this, but given that plates are the *only* use for this enum, it's easy/simple to just enumerate. """ + from typing import Final US_STATES: Final[tuple[tuple[str, str], ...]] = ( diff --git a/ws/conf/local_settings.py b/ws/conf/local_settings.py index f3f3a742..552e8c83 100644 --- a/ws/conf/local_settings.py +++ b/ws/conf/local_settings.py @@ -1,10 +1,11 @@ """Local settings, intended for use on a local computer for basic feature testing. - - Exposed secret key - - DEBUG enabled - - Project root is just '/' - - Send emails to console +- Exposed secret key +- DEBUG enabled +- Project root is just '/' +- Send emails to console """ + from typing import Any DEBUG = True diff --git a/ws/conf/test_settings.py b/ws/conf/test_settings.py index 2e9d9a3e..cfba259e 100644 --- a/ws/conf/test_settings.py +++ b/ws/conf/test_settings.py @@ -2,6 +2,7 @@ Intended to mirror production as much as is possible. """ + from typing import Any DEBUG = False diff --git a/ws/merge.py b/ws/merge.py index a22bd042..b28762cf 100644 --- a/ws/merge.py +++ b/ws/merge.py @@ -8,6 +8,7 @@ account where they can log in with either email address, and get access to a complete history. """ + from collections.abc import Iterable from typing import cast diff --git a/ws/messages/__init__.py b/ws/messages/__init__.py index 6a39318c..cac36ef6 100644 --- a/ws/messages/__init__.py +++ b/ws/messages/__init__.py @@ -2,6 +2,7 @@ Some messages may be called on *every* request, others as needed. """ + from django.contrib import messages from django.contrib.messages.storage.base import Message from django.http import HttpRequest diff --git a/ws/messages/leader.py b/ws/messages/leader.py index eb775f86..9520f360 100644 --- a/ws/messages/leader.py +++ b/ws/messages/leader.py @@ -1,4 +1,5 @@ """Messages for leaders!""" + from datetime import timedelta from django.contrib import messages diff --git a/ws/mixins.py b/ws/mixins.py index e749492f..df2e3178 100644 --- a/ws/mixins.py +++ b/ws/mixins.py @@ -1,4 +1,5 @@ """Mixins used across multiple views.""" + from datetime import timedelta from django.contrib.auth.decorators import login_required diff --git a/ws/signals/signup_signals.py b/ws/signals/signup_signals.py index ab32c8fc..e411a772 100644 --- a/ws/signals/signup_signals.py +++ b/ws/signals/signup_signals.py @@ -1,4 +1,5 @@ """Handle aspects of trip creation/modification when receiving signup changes.""" + # Signals are a terrible pattern that I aim to replace eventually. # Ruff will complain about the large number of arguments. We can ignore for now. # ruff: noqa: PLR0913 diff --git a/ws/unsubscribe.py b/ws/unsubscribe.py index cb77f56a..652c81ec 100644 --- a/ws/unsubscribe.py +++ b/ws/unsubscribe.py @@ -3,6 +3,7 @@ Ideally, participants just control their email preferences directly. However, we provide this method for single-click unsubscribe links. """ + import enum from datetime import timedelta from typing import NamedTuple, TypedDict diff --git a/ws/utils/dates.py b/ws/utils/dates.py index 0b45b65c..ce41a84e 100644 --- a/ws/utils/dates.py +++ b/ws/utils/dates.py @@ -1,4 +1,5 @@ """Some shortcuts to retrieve meaningful dates.""" + from datetime import date, datetime, time, timedelta from django.utils import timezone diff --git a/ws/utils/geardb.py b/ws/utils/geardb.py index 245f7796..23d020ad 100644 --- a/ws/utils/geardb.py +++ b/ws/utils/geardb.py @@ -3,6 +3,7 @@ The gear database is itself a Django application, which we interface with via machine-to-machine API endpoints. """ + import logging from collections.abc import Iterable, Iterator from datetime import date, datetime, timedelta diff --git a/ws/utils/member_sheets.py b/ws/utils/member_sheets.py index 6a820da1..0541334d 100644 --- a/ws/utils/member_sheets.py +++ b/ws/utils/member_sheets.py @@ -6,6 +6,7 @@ spreadsheets. Each spreadsheet will be shared with the company offering the discount, so that they can verify membership status. """ + import bisect import logging import random diff --git a/ws/utils/membership_api.py b/ws/utils/membership_api.py index 7015ddc4..7a254a7d 100644 --- a/ws/utils/membership_api.py +++ b/ws/utils/membership_api.py @@ -15,6 +15,7 @@ 'status': 'Missing', } """ + from datetime import date from typing import Any, Literal, TypedDict diff --git a/ws/views/account.py b/ws/views/account.py index b973a469..543c29fe 100644 --- a/ws/views/account.py +++ b/ws/views/account.py @@ -1,4 +1,5 @@ """Views relating to account management.""" + import logging from urllib.parse import urlencode diff --git a/ws/views/applications.py b/ws/views/applications.py index 0b44aacd..4e9c8df5 100644 --- a/ws/views/applications.py +++ b/ws/views/applications.py @@ -4,6 +4,7 @@ and activity chairs can respond to those applications with recommendations and/or ratings. """ + from collections import defaultdict from collections.abc import Iterator, Mapping diff --git a/ws/views/itinerary.py b/ws/views/itinerary.py index 4489b98a..80362790 100644 --- a/ws/views/itinerary.py +++ b/ws/views/itinerary.py @@ -4,6 +4,7 @@ That itinerary specifies who (if anybody) will be driving for the trip, what the intended route will be, when to worry, and more. """ + from django.contrib.auth.decorators import login_required from django.core.exceptions import PermissionDenied from django.db.models import Q diff --git a/ws/views/leaders.py b/ws/views/leaders.py index f5c2e8cc..65de8e50 100644 --- a/ws/views/leaders.py +++ b/ws/views/leaders.py @@ -5,6 +5,7 @@ For views relating to the leader application process, see ws.views.applications """ + from django.contrib import messages from django.core.exceptions import PermissionDenied from django.db.models import Max diff --git a/ws/views/participant.py b/ws/views/participant.py index 642844e9..057e9352 100644 --- a/ws/views/participant.py +++ b/ws/views/participant.py @@ -4,6 +4,7 @@ user who has completed the mandatory signup information is given a Participant object that's linked to their user account. """ + import logging from typing import Any, Literal, TypedDict, cast diff --git a/ws/views/preferences.py b/ws/views/preferences.py index d1ac08e6..92471528 100644 --- a/ws/views/preferences.py +++ b/ws/views/preferences.py @@ -4,6 +4,7 @@ paired with another participant. All of these options are deemed "preferences" of the participant. """ + import contextlib import json from datetime import datetime diff --git a/ws/views/trips.py b/ws/views/trips.py index dcef651c..d9621295 100644 --- a/ws/views/trips.py +++ b/ws/views/trips.py @@ -3,6 +3,7 @@ A "trip" is any official trip registered in the system - created by leaders, to be attended by any interested participants. """ + from collections import defaultdict from datetime import date, timedelta from typing import TYPE_CHECKING, Any, cast diff --git a/ws/views/winter_school.py b/ws/views/winter_school.py index 2e72ca0b..2d46a53c 100644 --- a/ws/views/winter_school.py +++ b/ws/views/winter_school.py @@ -5,6 +5,7 @@ Winter School. This module contains those views. The majority of the system works the same during Winter School as it does during the rest of the year. """ + from django.contrib import messages from django.shortcuts import redirect from django.urls import reverse