From c21aec2aff35c7a94fd5fa4391dad2355e914bc3 Mon Sep 17 00:00:00 2001 From: David Paul Graham Date: Thu, 3 Oct 2024 22:47:26 -0400 Subject: [PATCH] upgrade ruff pre-commit hook version --- .pre-commit-config.yaml | 2 +- server/conftest.py | 9 ++++----- server/core/management/commands/celery_beat.py | 1 - server/core/services/rcrainfo_service.py | 1 - server/core/tests/conftest.py | 1 - server/manifest/services/manifest.py | 2 +- server/manifest/tasks.py | 6 ++++-- server/org/serializers.py | 2 +- server/org/tests/conftest.py | 2 +- server/profile/tests/conftest.py | 3 +-- server/pyproject.toml | 2 +- server/rcrasite/admin.py | 2 +- server/rcrasite/services/rcra_site.py | 2 +- server/rcrasite/services/rcra_site_search.py | 3 +-- server/rcrasite/tests/test_site_search.py | 2 +- server/wasteline/tests/conftest.py | 2 +- 16 files changed, 19 insertions(+), 23 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 87ed5337..11856edc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ repos: exclude: (?x)^(\.idea\/.*|\.vscode\/.*)$ # Ruff - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.5.6 + rev: v0.6.8 hooks: - id: ruff args: [--fix, --config, ./server/pyproject.toml] diff --git a/server/conftest.py b/server/conftest.py index 39195cb5..5f5775c2 100644 --- a/server/conftest.py +++ b/server/conftest.py @@ -10,16 +10,14 @@ import pytest import pytest_mock import responses +from core.models import ( + TrakUser, +) from django.contrib.auth.models import User from django.db import IntegrityError from faker import Faker from faker.providers import BaseProvider from guardian.shortcuts import assign_perm -from rest_framework.test import APIClient - -from core.models import ( - TrakUser, -) from org.models import Org, Site from rcrasite.models import ( Address, @@ -27,6 +25,7 @@ RcraPhone, RcraSite, ) +from rest_framework.test import APIClient class SiteIDProvider(BaseProvider): diff --git a/server/core/management/commands/celery_beat.py b/server/core/management/commands/celery_beat.py index 651909eb..43359848 100644 --- a/server/core/management/commands/celery_beat.py +++ b/server/core/management/commands/celery_beat.py @@ -7,7 +7,6 @@ from django.core.management.base import BaseCommand from django.utils import autoreload from django_celery_beat.models import CrontabSchedule, IntervalSchedule, PeriodicTask - from wasteline.tasks import pull_federal_codes CELERY_LOG_LEVEL = os.getenv("CELERY_LOG_LEVEL", "INFO") diff --git a/server/core/services/rcrainfo_service.py b/server/core/services/rcrainfo_service.py index 4d6b3500..ee5475b7 100644 --- a/server/core/services/rcrainfo_service.py +++ b/server/core/services/rcrainfo_service.py @@ -5,7 +5,6 @@ import emanifest from django.db import IntegrityError from emanifest import RcrainfoClient, RcrainfoResponse - from org.models import Org from wasteline.models import WasteCode diff --git a/server/core/tests/conftest.py b/server/core/tests/conftest.py index e5a7b04c..7464656c 100644 --- a/server/core/tests/conftest.py +++ b/server/core/tests/conftest.py @@ -3,7 +3,6 @@ import pytest from faker import Faker - from rcrasite.models import RcraSiteType diff --git a/server/manifest/services/manifest.py b/server/manifest/services/manifest.py index 4908d565..81c155b0 100644 --- a/server/manifest/services/manifest.py +++ b/server/manifest/services/manifest.py @@ -3,11 +3,11 @@ from django.db import transaction from django.db.models import Q, QuerySet +from org.models import Site from manifest.models import Manifest from manifest.services import EManifest, EManifestError, TaskResponse from manifest.tasks import save_to_emanifest as save_to_emanifest_task -from org.models import Site logger = logging.getLogger(__name__) diff --git a/server/manifest/tasks.py b/server/manifest/tasks.py index 5e022ff8..0a0590e4 100644 --- a/server/manifest/tasks.py +++ b/server/manifest/tasks.py @@ -3,7 +3,6 @@ from celery import Task, shared_task, states from celery.exceptions import Ignore, Reject - from core.services import get_rcra_client logger = logging.getLogger(__name__) @@ -16,6 +15,7 @@ def pull_manifest(self: Task, *, mtn: List[str], username: str) -> dict: """ from core.services import TaskService + from manifest.services import EManifest logger.info(f"start task {self.name}, manifest {mtn}") @@ -60,9 +60,10 @@ def sign_manifest( def sync_site_manifests(self, *, site_id: str, username: str): """asynchronous task to sync an EPA site's manifests""" - from manifest.services.emanifest import sync_manifests from org.services import get_user_site, update_emanifest_sync_date + from manifest.services.emanifest import sync_manifests + try: client = get_rcra_client(username=username) site = get_user_site(username=username, epa_id=site_id) @@ -85,6 +86,7 @@ def save_to_emanifest(self, *, manifest_data: dict, username: str): user who is creating the manifest """ from core.services import TaskService + from manifest.services import EManifest, EManifestError logger.info(f"start task: {self.name}") diff --git a/server/org/serializers.py b/server/org/serializers.py index 2ffdfe41..abe1a435 100644 --- a/server/org/serializers.py +++ b/server/org/serializers.py @@ -1,8 +1,8 @@ +from rcrasite.serializers import RcraSiteSerializer from rest_framework import serializers from rest_framework.serializers import ModelSerializer from org.models import Org, Site -from rcrasite.serializers import RcraSiteSerializer class OrgSerializer(ModelSerializer): diff --git a/server/org/tests/conftest.py b/server/org/tests/conftest.py index 82587653..7b357e38 100644 --- a/server/org/tests/conftest.py +++ b/server/org/tests/conftest.py @@ -1,9 +1,9 @@ from typing import Optional import pytest +from rcrasite.models import RcraSite from org.models import Org, Site -from rcrasite.models import RcraSite @pytest.fixture diff --git a/server/profile/tests/conftest.py b/server/profile/tests/conftest.py index 2d3bf8f4..d23c6b65 100644 --- a/server/profile/tests/conftest.py +++ b/server/profile/tests/conftest.py @@ -2,9 +2,8 @@ from typing import Optional import pytest -from faker import Faker - from conftest import SiteIDProvider +from faker import Faker @pytest.fixture diff --git a/server/pyproject.toml b/server/pyproject.toml index f64a9826..f095cdfd 100644 --- a/server/pyproject.toml +++ b/server/pyproject.toml @@ -43,7 +43,7 @@ exclude = [ ] [tool.ruff.lint] -select = ["F", "E", "W", "Q", "I001"] +select = ["F", "E", "W", "Q"] ignore = ["F401"] [tool.pytest.ini_options] diff --git a/server/rcrasite/admin.py b/server/rcrasite/admin.py index d424e10b..6bed924f 100644 --- a/server/rcrasite/admin.py +++ b/server/rcrasite/admin.py @@ -1,6 +1,6 @@ +from core.admin import HiddenListView from django.contrib import admin -from core.admin import HiddenListView from rcrasite.models import ( Address, Contact, diff --git a/server/rcrasite/services/rcra_site.py b/server/rcrasite/services/rcra_site.py index 6fa7733a..f4b5241d 100644 --- a/server/rcrasite/services/rcra_site.py +++ b/server/rcrasite/services/rcra_site.py @@ -1,12 +1,12 @@ import logging from typing import Dict, Optional, TypedDict +from core.services import RcraClient, get_rcra_client from django.core.cache import CacheKeyWarning, cache from django.db import transaction from django.db.models import QuerySet from rest_framework.exceptions import ValidationError -from core.services import RcraClient, get_rcra_client from rcrasite.models import RcraSite from rcrasite.serializers import RcraSiteSerializer diff --git a/server/rcrasite/services/rcra_site_search.py b/server/rcrasite/services/rcra_site_search.py index fe687686..da170212 100644 --- a/server/rcrasite/services/rcra_site_search.py +++ b/server/rcrasite/services/rcra_site_search.py @@ -1,8 +1,7 @@ from typing import Literal, Optional -from emanifest import RcrainfoResponse - from core.services import RcraClient +from emanifest import RcrainfoResponse SiteType = Literal["Generator", "Tsdf", "Transporter", "Broker"] diff --git a/server/rcrasite/tests/test_site_search.py b/server/rcrasite/tests/test_site_search.py index 9b806ee1..4c26ee63 100644 --- a/server/rcrasite/tests/test_site_search.py +++ b/server/rcrasite/tests/test_site_search.py @@ -1,8 +1,8 @@ import json import pytest - from core.services import RcraClient + from rcrasite.services import RcraSiteSearch diff --git a/server/wasteline/tests/conftest.py b/server/wasteline/tests/conftest.py index 1c77e2a0..1a41fdde 100644 --- a/server/wasteline/tests/conftest.py +++ b/server/wasteline/tests/conftest.py @@ -2,8 +2,8 @@ import pytest from faker import Faker - from manifest.models import Manifest + from wasteline.models import DotLookup, DotLookupType, WasteCode, WasteLine