Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 226b622

Browse files
Merge pull request #717 from codecov/dorian/lint-compare
Dorian/lint compare
2 parents 760d2b4 + eb455b4 commit 226b622

12 files changed

+54
-16
lines changed

.circleci/config.yml

+15-1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ jobs:
105105
apk add git
106106
chmod +x codecov-alpine
107107
./codecov-alpine -R . --url https://stage-web.codecov.dev -t $CODECOV_STAGING_TOKEN -F unit
108+
lint:
109+
executor: codecov-api
110+
steps:
111+
- run:
112+
name: Pylint
113+
command: make lint
108114
portable:
109115
executor: codecov-deploy
110116
steps:
@@ -196,6 +202,10 @@ workflows:
196202
filters:
197203
tags:
198204
only: /.*/
205+
- lint:
206+
context: "circleci google deploy context"
207+
requires:
208+
- build
199209
- build-enterprise:
200210
context: "circleci google deploy context"
201211
requires:
@@ -228,6 +238,7 @@ workflows:
228238
requires:
229239
- build
230240
- test
241+
- lint
231242
filters:
232243
branches:
233244
only:
@@ -238,6 +249,7 @@ workflows:
238249
requires:
239250
- build
240251
- test
252+
- lint
241253
filters:
242254
branches:
243255
only: staging
@@ -246,6 +258,7 @@ workflows:
246258
requires:
247259
- build
248260
- test
261+
- lint
249262
- dive
250263
filters:
251264
branches:
@@ -269,6 +282,7 @@ workflows:
269282
requires:
270283
- build-enterprise
271284
- test
285+
- lint
272286
- dive-enterprise
273287
filters:
274288
tags:
@@ -298,4 +312,4 @@ workflows:
298312
tags:
299313
only: /^enterprise-.*/
300314
branches:
301-
ignore: /.*/
315+
ignore: /.*/

.pylintrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[MESSAGES CONTROL]
2+
disable=C0114,C0115,C0116,R0201,R0801
3+
4+
[FORMAT]
5+
max-line-length=120

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ test.unit:
4747
test.integration:
4848
python -m pytest --cov=./ -m "integration" --cov-report=xml:integration.coverage.xml
4949

50+
lint:
51+
pylint --load-plugins pylint_django --django-settings-module=codecov.settings_dev compare
52+
5053
tag.qa-release:
5154
git tag -a qa-${release_version}-${sha}-${epoch} -m "Autogenerated tag for enterprise api QA ${version}"
5255
git push origin qa-${release_version}-${sha}-${epoch}

compare/admin.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def get_queryset(self, request):
3535
"base_commit", "compare_commit", "base_commit__repository"
3636
).defer("base_commit__report", "compare_commit__report")
3737

38-
def has_add_permission(self, _, obj=None):
38+
def has_add_permission(self, *args, **kwargs):
3939
return False
4040

41-
def has_delete_permission(self, _, obj=None):
42-
return False
41+
def has_delete_permission(self, *args, **kwargs):
42+
return True

compare/commands/compare/interactors/compare_commits.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
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 compare.models import CommitComparison
65
from services.task import TaskService

compare/commands/compare/interactors/get_impacted_files.py

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def get_comparison_data_from_archive(self, comparison):
2424
try:
2525
data = archive_service.read_file(comparison.report_storage_path)
2626
return json.loads(data)
27+
# pylint: disable=W0702
2728
except:
2829
log.error(
2930
"GetImpactedFiles - couldnt fetch data from storage", exc_info=True

compare/commands/compare/interactors/tests/test_compare_commits.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
from asgiref.sync import async_to_sync
21
from unittest.mock import patch
3-
import pytest
42

3+
from asgiref.sync import async_to_sync
54
from django.contrib.auth.models import AnonymousUser
65
from django.test import TransactionTestCase
76

87
from core.tests.factories import CommitFactory
9-
from compare.models import CommitComparison
108
from compare.tests.factories import CommitComparisonFactory
9+
1110
from ..compare_commits import CompareCommitsInteractor
1211

1312

compare/commands/compare/interactors/tests/test_get_impacted_files.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import json
2-
3-
from asgiref.sync import async_to_sync
42
from unittest.mock import patch
5-
import pytest
63

4+
from asgiref.sync import async_to_sync
75
from django.contrib.auth.models import AnonymousUser
86
from django.test import TransactionTestCase
97
from shared.reports.types import ReportTotals
108

119
from core.tests.factories import CommitFactory
12-
from compare.models import CommitComparison
1310
from compare.tests.factories import CommitComparisonFactory
1411
from ..get_impacted_files import GetImpactedFilesInteractor
1512

compare/commands/compare/tests/test_compare.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import asyncio
2+
from unittest.mock import patch
3+
24
from django.test import TransactionTestCase
35
from core.tests.factories import CommitFactory
4-
from unittest.mock import patch
56

67
from codecov_auth.tests.factories import OwnerFactory
78
from compare.tests.factories import CommitComparisonFactory

compare/tests/test_admin.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,5 @@ def setUp(self):
1414
self.client.force_login(user=self.staff_user)
1515

1616
def test_compare_admin_detail_page(self):
17-
response = self.client.get(
18-
reverse(f"admin:compare_commitcomparison_changelist")
19-
)
17+
response = self.client.get(reverse("admin:compare_commitcomparison_changelist"))
2018
self.assertEqual(response.status_code, 200)

requirements.in

+2
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ aiodataloader
3737
fakeredis
3838
opentelemetry-sdk
3939
opentelemetry-instrumentation-django
40+
pylint
41+
pylint-django

requirements.txt

+19
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ asgiref==3.3.4
2020
# opentelemetry-util-http
2121
asn1crypto==1.4.0
2222
# via cryptography
23+
astroid==2.6.6
24+
# via pylint
2325
attrs==20.3.0
2426
# via
2527
# pytest
@@ -143,14 +145,20 @@ iniconfig==1.1.1
143145
# via pytest
144146
intervaltree==3.1.0
145147
# via ddtrace
148+
isort==5.9.3
149+
# via pylint
146150
jmespath==0.10.0
147151
# via
148152
# boto3
149153
# botocore
150154
kombu==4.6.11
151155
# via celery
156+
lazy-object-proxy==1.6.0
157+
# via astroid
152158
marshmallow==3.8.0
153159
# via environs
160+
mccabe==0.6.1
161+
# via pylint
154162
minio==6.0.0
155163
# via
156164
# -r requirements.in
@@ -215,6 +223,15 @@ pyasn1==0.4.8
215223
# rsa
216224
pycparser==2.20
217225
# via cffi
226+
pylint-django==2.4.4
227+
# via -r requirements.in
228+
pylint-plugin-utils==0.6
229+
# via pylint-django
230+
pylint==2.9.6
231+
# via
232+
# -r requirements.in
233+
# pylint-django
234+
# pylint-plugin-utils
218235
pyparsing==2.4.7
219236
# via packaging
220237
pytest-cov==2.11.1
@@ -323,6 +340,7 @@ tlslite-ng==0.7.5
323340
toml==0.10.2
324341
# via
325342
# pre-commit
343+
# pylint
326344
# pytest
327345
tornado==6.0.4
328346
# via shared
@@ -346,6 +364,7 @@ whitenoise==5.2.0
346364
# via -r requirements.in
347365
wrapt==1.12.1
348366
# via
367+
# astroid
349368
# deprecated
350369
# opentelemetry-instrumentation
351370
# vcrpy

0 commit comments

Comments
 (0)