diff --git a/api/public/v2/compare/views.py b/api/public/v2/compare/views.py index 296e1a5ddd..518e64b3e2 100644 --- a/api/public/v2/compare/views.py +++ b/api/public/v2/compare/views.py @@ -1,6 +1,6 @@ -from distutils.util import strtobool from inspect import Parameter +from distutils.util import strtobool from drf_spectacular.types import OpenApiTypes from drf_spectacular.utils import OpenApiParameter, extend_schema from rest_framework import mixins diff --git a/api/shared/permissions.py b/api/shared/permissions.py index bcbd98104e..3c6cd7a242 100644 --- a/api/shared/permissions.py +++ b/api/shared/permissions.py @@ -1,18 +1,19 @@ import logging - from typing import Any, Tuple + from asgiref.sync import async_to_sync from django.conf import settings -from django.http import Http404 -from rest_framework.permissions import SAFE_METHODS # ['GET', 'HEAD', 'OPTIONS'] -from rest_framework.permissions import BasePermission -from django.http import HttpRequest +from django.http import Http404, HttpRequest +from rest_framework.permissions import ( + SAFE_METHODS, # ['GET', 'HEAD', 'OPTIONS'] + BasePermission, +) -from codecov_auth.models import Owner -from core.models import Repository import services.self_hosted as self_hosted from api.shared.mixins import InternalPermissionsMixin, SuperPermissionsMixin from api.shared.repo.repository_accessors import RepoAccessors +from codecov_auth.models import Owner +from core.models import Repository from services.activation import try_auto_activate from services.decorators import torngit_safe from services.repo_providers import get_generic_adapter_params, get_provider diff --git a/billing/tests/test_views.py b/billing/tests/test_views.py index a1e877846e..3274dee1ef 100644 --- a/billing/tests/test_views.py +++ b/billing/tests/test_views.py @@ -2,10 +2,10 @@ from datetime import datetime, timedelta from unittest.mock import patch -from pytest import raises import stripe from django.conf import settings from freezegun import freeze_time +from pytest import raises from rest_framework import status from rest_framework.reverse import reverse from rest_framework.test import APIRequestFactory, APITestCase diff --git a/codecov_auth/commands/owner/interactors/tests/test_get_is_current_user_an_admin.py b/codecov_auth/commands/owner/interactors/tests/test_get_is_current_user_an_admin.py index 56467eedb0..b0e23cc1d7 100644 --- a/codecov_auth/commands/owner/interactors/tests/test_get_is_current_user_an_admin.py +++ b/codecov_auth/commands/owner/interactors/tests/test_get_is_current_user_an_admin.py @@ -1,8 +1,8 @@ -from distutils.util import execute from unittest.mock import patch import pytest from asgiref.sync import async_to_sync +from distutils.util import execute from django.test import TransactionTestCase, override_settings from codecov_auth.tests.factories import GetAdminProviderAdapter, OwnerFactory diff --git a/graphql_api/types/config/config.py b/graphql_api/types/config/config.py index 65efe38abe..e11ba7ef34 100644 --- a/graphql_api/types/config/config.py +++ b/graphql_api/types/config/config.py @@ -1,7 +1,7 @@ -from distutils.util import strtobool from typing import List from ariadne import ObjectType +from distutils.util import strtobool from django.conf import settings import services.self_hosted as self_hosted diff --git a/ruff.toml b/ruff.toml index 77bf06f7da..b11c13ad5e 100644 --- a/ruff.toml +++ b/ruff.toml @@ -36,11 +36,13 @@ indent-width = 4 target-version = "py312" [lint] -# Currently only enabled F541: https://docs.astral.sh/ruff/rules/ -select = ["F541"] +# Currently only enabled for F541 and I: https://docs.astral.sh/ruff/rules/ +select = ["F541", "I"] ignore = [] # Allow fix for all enabled rules (when `--fix`) is provided. +# The preferred method (for now) w.r.t. fixable rules is to manually update the makefile +# with --fix and re-run 'make lint' fixable = ["ALL"] unfixable = [] diff --git a/upload/helpers.py b/upload/helpers.py index 83ce35b28b..4ea26302d7 100644 --- a/upload/helpers.py +++ b/upload/helpers.py @@ -37,6 +37,7 @@ from utils.config import get_config from utils.encryption import encryptor from utils.github import get_github_integration_token + from .constants import ci, global_upload_token_providers is_pull_noted_in_branch = re.compile(r".*(pull|pr)\/(\d+).*") diff --git a/upload/views/bundle_analysis.py b/upload/views/bundle_analysis.py index 41e995c9e3..85ed9c8b8a 100644 --- a/upload/views/bundle_analysis.py +++ b/upload/views/bundle_analysis.py @@ -6,8 +6,9 @@ from rest_framework.permissions import BasePermission from rest_framework.response import Response from rest_framework.views import APIView -from shared.bundle_analysis.storage import StoragePaths, get_bucket_name from sentry_sdk import metrics as sentry_metrics +from shared.bundle_analysis.storage import StoragePaths, get_bucket_name + from codecov_auth.authentication.repo_auth import ( GitHubOIDCTokenAuthentication, OrgLevelTokenAuthentication, diff --git a/upload/views/commits.py b/upload/views/commits.py index fe9eafdda5..bc96cf68a3 100644 --- a/upload/views/commits.py +++ b/upload/views/commits.py @@ -3,6 +3,7 @@ from rest_framework.exceptions import ValidationError from rest_framework.generics import ListCreateAPIView from sentry_sdk import metrics as sentry_metrics + from codecov_auth.authentication.repo_auth import ( GitHubOIDCTokenAuthentication, GlobalTokenAuthentication, diff --git a/upload/views/empty_upload.py b/upload/views/empty_upload.py index ef77308447..0432b9f3e8 100644 --- a/upload/views/empty_upload.py +++ b/upload/views/empty_upload.py @@ -8,8 +8,9 @@ from rest_framework.exceptions import NotFound from rest_framework.generics import CreateAPIView from rest_framework.response import Response -from shared.torngit.exceptions import TorngitClientError, TorngitClientGeneralError from sentry_sdk import metrics as sentry_metrics +from shared.torngit.exceptions import TorngitClientError, TorngitClientGeneralError + from codecov_auth.authentication.repo_auth import ( GitHubOIDCTokenAuthentication, GlobalTokenAuthentication, @@ -21,8 +22,8 @@ from services.task import TaskService from services.yaml import final_commit_yaml from upload.helpers import ( - try_to_get_best_possible_bot_token, generate_upload_sentry_metrics_tags, + try_to_get_best_possible_bot_token, ) from upload.views.base import GetterMixin from upload.views.uploads import CanDoCoverageUploadsPermission diff --git a/upload/views/reports.py b/upload/views/reports.py index 39f78e28f9..90027d7b0a 100644 --- a/upload/views/reports.py +++ b/upload/views/reports.py @@ -4,6 +4,7 @@ from rest_framework.exceptions import ValidationError from rest_framework.generics import CreateAPIView, ListCreateAPIView, RetrieveAPIView from sentry_sdk import metrics as sentry_metrics + from codecov_auth.authentication.repo_auth import ( GitHubOIDCTokenAuthentication, GlobalTokenAuthentication, diff --git a/upload/views/upload_completion.py b/upload/views/upload_completion.py index 7a6071a2b7..49d1d7aed5 100644 --- a/upload/views/upload_completion.py +++ b/upload/views/upload_completion.py @@ -4,6 +4,7 @@ from rest_framework.generics import CreateAPIView from rest_framework.response import Response from sentry_sdk import metrics as sentry_metrics + from codecov_auth.authentication.repo_auth import ( GitHubOIDCTokenAuthentication, GlobalTokenAuthentication,