Skip to content

Commit d2a7e51

Browse files
committed
Linting the whole codecov codebase
Running ``` black . isort --profile=black . ``` on the codebase
1 parent ff68189 commit d2a7e51

File tree

328 files changed

+1613
-1709
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

328 files changed

+1613
-1709
lines changed

billing/tests/test_views.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import stripe
21
import json
32
import time
4-
53
from unittest.mock import patch
64

5+
import stripe
76
from django.conf import settings
8-
9-
from rest_framework.test import APITestCase, APIRequestFactory
10-
from rest_framework.reverse import reverse
117
from rest_framework import status
8+
from rest_framework.reverse import reverse
9+
from rest_framework.test import APIRequestFactory, APITestCase
1210

1311
from codecov_auth.tests.factories import OwnerFactory
1412
from core.tests.factories import RepositoryFactory

billing/urls.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from .views import StripeWebhookHandler
44

5-
65
urlpatterns = [
76
path("stripe/webhooks", StripeWebhookHandler.as_view(), name="stripe-webhook"),
87
]

billing/views.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
import logging
2-
import stripe
31
import json
2+
import logging
43

5-
from rest_framework.views import APIView
6-
from rest_framework.permissions import AllowAny
7-
from rest_framework.response import Response
8-
from rest_framework import status
9-
4+
import stripe
105
from django.conf import settings
116
from django.core.exceptions import MultipleObjectsReturned
7+
from rest_framework import status
8+
from rest_framework.permissions import AllowAny
9+
from rest_framework.response import Response
10+
from rest_framework.views import APIView
1211

13-
from codecov_auth.models import Owner
1412
from codecov_auth.constants import PR_AUTHOR_PAID_USER_PLAN_REPRESENTATIONS
15-
from services.segment import SegmentService
13+
from codecov_auth.models import Owner
1614
from services.billing import BillingService
15+
from services.segment import SegmentService
1716

1817
from .constants import StripeHTTPHeaders, StripeWebhookEvents
1918

20-
2119
if settings.STRIPE_API_KEY:
2220
stripe.api_key = settings.STRIPE_API_KEY
2321

codecov/commands/executor.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
from utils.services import get_long_service_name
2-
31
from codecov_auth.commands.owner import OwnerCommands
4-
from core.commands.repository import RepositoryCommands
5-
from core.commands.commit import CommitCommands
6-
from core.commands.branch import BranchCommands
72
from compare.commands.compare import CompareCommands
3+
from core.commands.branch import BranchCommands
4+
from core.commands.commit import CommitCommands
85
from core.commands.pull import PullCommands
9-
6+
from core.commands.repository import RepositoryCommands
7+
from utils.services import get_long_service_name
108

119
mapping = {
1210
"commit": CommitCommands,
1311
"owner": OwnerCommands,
1412
"repository": RepositoryCommands,
1513
"branch": BranchCommands,
1614
"compare": CompareCommands,
17-
"pull": PullCommands
15+
"pull": PullCommands,
1816
}
1917

2018

codecov/commands/tests/test_base.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from django.contrib.auth.models import AnonymousUser
22

33
from core.commands.commit import CommitCommands
4+
45
from ..base import BaseCommand, BaseInteractor
56

67

codecov/commands/tests/test_executor.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
from django.contrib.auth.models import AnonymousUser
12
from django.test import RequestFactory
23
from django.urls import ResolverMatch
3-
from django.contrib.auth.models import AnonymousUser
44

55
from codecov_auth.commands.owner import OwnerCommands
6-
from ..executor import Executor, get_executor_from_request, get_executor_from_command
6+
7+
from ..executor import Executor, get_executor_from_command, get_executor_from_request
78

89

910
def test_get_executor_from_request():

codecov/settings_base.py

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from corsheaders.defaults import default_headers
2-
3-
from utils.config import get_config, get_settings_module, SettingsModule
41
import os
52

3+
from corsheaders.defaults import default_headers
4+
5+
from utils.config import SettingsModule, get_config, get_settings_module
66

77
# SECURITY WARNING: keep the secret key used in production secret!
88
# TODO: get this out of source control
@@ -105,15 +105,9 @@
105105
{
106106
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
107107
},
108-
{
109-
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
110-
},
111-
{
112-
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
113-
},
114-
{
115-
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
116-
},
108+
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",},
109+
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",},
110+
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",},
117111
]
118112

119113

codecov/settings_dev.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from .settings_base import *
21
import logging
32

3+
from .settings_base import *
44

55
DEBUG = True
66
ALLOWED_HOSTS = get_config("setup", "api_allowed_hosts", default=["localhost"])

codecov/settings_enterprise.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
from .settings_base import *
21
import os
32
from urllib.parse import urlparse
3+
44
from utils.config import get_config, get_settings_module
55

6+
from .settings_base import *
7+
68
DEBUG = False
79
THIS_POD_IP = os.environ.get("THIS_POD_IP")
810
ALLOWED_HOSTS = get_config("setup", "api_allowed_hosts", default=["*"])
@@ -73,4 +75,4 @@
7375
ALLOWED_HOSTS.append(API_DOMAIN)
7476
# Referenced at module level of services/billing.py, so it needs to be defined
7577
STRIPE_API_KEY = None
76-
SILENCED_SYSTEM_CHECKS = ['urls.W002']
78+
SILENCED_SYSTEM_CHECKS = ["urls.W002"]

codecov/settings_prod.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
from .settings_base import *
21
import os
2+
33
import sentry_sdk
44
from sentry_sdk.integrations.django import DjangoIntegration
55

6+
from .settings_base import *
67

78
DEBUG = False
89
THIS_POD_IP = os.environ.get("THIS_POD_IP")

codecov/settings_staging.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
from .settings_base import *
1+
import os
2+
23
import sentry_sdk
34
from sentry_sdk.integrations.django import DjangoIntegration
4-
import os
55

6+
from .settings_base import *
67

78
DEBUG = False
89
THIS_POD_IP = os.environ.get("THIS_POD_IP")

codecov/settings_test.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from .settings_base import *
22

3-
43
DEBUG = True
54
ALLOWED_HOSTS = ["localhost"]
65
WEBHOOK_URL = "" # NGROK TUNNEL HERE

codecov/tests/test_urls.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import json
22

3+
import pytest
34
from django.conf import settings
4-
from django.test.client import Client
55
from django.test import TestCase
6-
7-
import pytest
6+
from django.test.client import Client
87

98

109
class ViewTest(TestCase):

codecov/urls.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from django.conf import settings
22
from django.contrib import admin
3-
from django.urls import path, include, re_path
3+
from django.urls import include, path, re_path
44

5-
from internal_api.constants import INTERNAL_API_PREFIX
65
from codecov import views
6+
from internal_api.constants import INTERNAL_API_PREFIX
77

88
urlpatterns = [
99
path("billing/", include("billing.urls")),
@@ -13,8 +13,7 @@
1313
path("health/", views.health),
1414
path("", views.health),
1515
path(
16-
"<str:service>/<str:owner_username>/<str:repo_name>/",
17-
include("graphs.urls"),
16+
"<str:service>/<str:owner_username>/<str:repo_name>/", include("graphs.urls"),
1817
),
1918
path("upload/", include("upload.urls")),
2019
]

codecov/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from django.http import HttpResponse, HttpResponseRedirect
21
from django.conf import settings
2+
from django.http import HttpResponse, HttpResponseRedirect
33

44
from core.models import Version
55

codecov/wsgi.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
and os.getenv("OPENTELEMETRY_CODECOV_RATE")
2121
):
2222
from open_telemetry import instrument
23+
2324
instrument()
2425

2526
application = get_wsgi_application()

codecov_auth/authentication/__init__.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
from django.utils import timezone
2-
from django.contrib.auth.backends import BaseBackend
1+
import hashlib
2+
import hmac
33
import logging
44
from base64 import b64decode
5-
import hmac
6-
import hashlib
75

8-
from rest_framework import authentication
9-
from rest_framework import exceptions
6+
from django.contrib.auth.backends import BaseBackend
7+
from django.utils import timezone
8+
from rest_framework import authentication, exceptions
109

11-
from codecov_auth.models import Session, Owner
1210
from codecov_auth.helpers import decode_token_from_cookie
11+
from codecov_auth.models import Owner, Session
1312
from utils.config import get_config
1413
from utils.services import get_long_service_name
1514

codecov_auth/authentication/repo_auth.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
from django.utils import timezone
44
from rest_framework import authentication, exceptions
55

6-
from codecov_auth.authentication.types import (
7-
RepositoryAsUser,
8-
RepositoryAuthInterface,
9-
)
6+
from codecov_auth.authentication.types import RepositoryAsUser, RepositoryAuthInterface
107
from codecov_auth.models import RepositoryToken
118
from core.models import Repository
129

@@ -53,11 +50,12 @@ def authenticate(self, request):
5350
LegacyTokenRepositoryAuth(repository, {"token": token}),
5451
)
5552

53+
5654
class RepositoryLegacyTokenAuthentication(authentication.TokenAuthentication):
5755
def authenticate_credentials(self, token):
5856
try:
5957
token = UUID(token)
60-
except (ValueError, TypeError) :
58+
except (ValueError, TypeError):
6159
raise exceptions.AuthenticationFailed("Invalid token.")
6260
try:
6361
repository = Repository.objects.get(upload_token=token)

codecov_auth/authentication/types.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ def is_authenticated(self):
77

88

99
class RepositoryAuthInterface(object):
10-
1110
def get_scopes():
1211
raise NotImplementedError()
1312

codecov_auth/commands/owner/interactors/create_api_token.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from asgiref.sync import sync_to_async
22

3-
from codecov_auth.models import Session
43
from codecov.commands.base import BaseInteractor
54
from codecov.commands.exceptions import Unauthenticated, ValidationError
5+
from codecov_auth.models import Session
66

77

88
class CreateApiTokenInteractor(BaseInteractor):

codecov_auth/commands/owner/interactors/delete_session.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from asgiref.sync import sync_to_async
22

3-
from codecov_auth.models import Session
43
from codecov.commands.base import BaseInteractor
54
from codecov.commands.exceptions import Unauthenticated
5+
from codecov_auth.models import Session
66

77

88
class DeleteSessionInteractor(BaseInteractor):
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from asgiref.sync import sync_to_async
2+
23
from codecov.commands.base import BaseInteractor
34
from codecov_auth.models import Owner
45

6+
57
class FetchOwnerInteractor(BaseInteractor):
68
@sync_to_async
79
def execute(self, username):
8-
return Owner.objects.filter(username=username, service=self.service).first()
10+
return Owner.objects.filter(username=username, service=self.service).first()

codecov_auth/commands/owner/interactors/onboard_user.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from asgiref.sync import sync_to_async
21
import html
3-
import yaml
42

3+
import yaml
4+
from asgiref.sync import sync_to_async
55
from django import forms
66

7-
from codecov_auth.models import OwnerProfile
87
from codecov.commands.base import BaseInteractor
98
from codecov.commands.exceptions import Unauthenticated, Unauthorized, ValidationError
9+
from codecov_auth.models import OwnerProfile
1010

1111

1212
class OnboardForm(forms.Form):

codecov_auth/commands/owner/interactors/set_yaml_on_owner.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
from asgiref.sync import sync_to_async
21
import html
2+
33
import yaml
4+
from asgiref.sync import sync_to_async
5+
from shared.validation.exceptions import InvalidYamlException
6+
from shared.yaml.validation import validate_yaml
47

5-
from codecov_auth.models import Owner
6-
from codecov_auth.helpers import current_user_part_of_org
78
from codecov.commands.base import BaseInteractor
89
from codecov.commands.exceptions import (
10+
NotFound,
911
Unauthenticated,
10-
ValidationError,
1112
Unauthorized,
12-
NotFound,
13+
ValidationError,
1314
)
14-
from shared.yaml.validation import validate_yaml
15-
from shared.validation.exceptions import InvalidYamlException
15+
from codecov_auth.helpers import current_user_part_of_org
16+
from codecov_auth.models import Owner
1617

1718

1819
class SetYamlOnOwnerInteractor(BaseInteractor):

codecov_auth/commands/owner/interactors/tests/test_create_api_token.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import pytest
2-
from django.test import TransactionTestCase
32
from django.contrib.auth.models import AnonymousUser
3+
from django.test import TransactionTestCase
44

5+
from codecov.commands.exceptions import Unauthenticated, ValidationError
56
from codecov_auth.models import Session
67
from codecov_auth.tests.factories import OwnerFactory
8+
79
from ..create_api_token import CreateApiTokenInteractor
8-
from codecov.commands.exceptions import Unauthenticated, ValidationError
910

1011

1112
class CreateApiTokenInteractorTest(TransactionTestCase):

0 commit comments

Comments
 (0)