Skip to content

Commit adfc253

Browse files
authored
Merge pull request #340 from PyCQA/github-actions
Replacing travis with GitHub actions
2 parents b0af386 + ac2f70a commit adfc253

24 files changed

+177
-154
lines changed

.github/workflows/testing.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: testing
2+
3+
on:
4+
push:
5+
branches: master
6+
pull_request:
7+
8+
jobs:
9+
sanity:
10+
name: sanity / ${{ matrix.toxenv }}
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
python-version: [3.6]
16+
toxenv: [django_not_installed, django_is_installed, flake8, pylint, readme]
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v1
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Execute tests
26+
run: |
27+
pip install tox
28+
pip install -e .[for_tests]
29+
30+
export TOXENV=${{ matrix.toxenv }}
31+
export PYTHON=${{ matrix.python-version }}
32+
tox
33+
34+
35+
test:
36+
name: test / Django@${{ matrix.django-version }} / Python@${{ matrix.python-version }}
37+
runs-on: ubuntu-latest
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
python-version: [3.6, 3.7, 3.8, 3.9]
42+
django-version: [-main, 3.2, 3.1, "3.0", "2.0", 1.11]
43+
44+
steps:
45+
- uses: actions/checkout@v2
46+
- name: Set up Python ${{ matrix.python-version }}
47+
uses: actions/setup-python@v1
48+
with:
49+
python-version: ${{ matrix.python-version }}
50+
51+
- name: Execute tests
52+
run: |
53+
pip install tox
54+
pip install -e .[for_tests]
55+
56+
export DJANGO=${{ matrix.django-version }}
57+
export PYTHON=${{ matrix.python-version }}
58+
export TOXENV=$(echo py${{ matrix.python-version }}-django${{ matrix.django-version }} | tr -d .)
59+
tox
60+
61+
- name: Coveralls
62+
env:
63+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
run: |
66+
pip install coveralls
67+
coveralls --service=github
68+
69+
build_and_package_sanity:
70+
runs-on: ubuntu-latest
71+
strategy:
72+
matrix:
73+
python-version: [3.6]
74+
75+
steps:
76+
- uses: actions/checkout@v2
77+
- name: Set up Python ${{ matrix.python-version }}
78+
uses: actions/setup-python@v1
79+
with:
80+
python-version: ${{ matrix.python-version }}
81+
82+
- name: Build
83+
run: |
84+
pip install tox
85+
pip install -e .[for_tests]
86+
87+
./scripts/build.sh

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ repos:
1313
rev: 4.0.1
1414
hooks:
1515
- id: flake8
16-
args: [ --max-line-length=120 ]
16+
args: [ --max-line-length=140 ]
1717
- repo: https://github.com/python/black
1818
rev: 21.9b0
1919
hooks:
2020
- id: black
21-
args: [--safe, --line-length=120]
21+
args: [--safe, --line-length=140]
2222
- repo: https://github.com/PyCQA/isort
2323
rev: 5.10.1
2424
hooks:

.travis.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
Version 2.5 [WIP]
5+
---------------------------
6+
- Moved from Travis CI to GitHub Actions (`#366 <https://github.com/PyCQA/pylint-django/pull/366>`_ and `#340 <https://github.com/PyCQA/pylint-django/pull/340>`_)
7+
- Added pre-commit configuration and began enforcing black/isort code formatting (TODO: add github action to enforce)
8+
- Multiple test fixes (including `#338 <https://github.com/PyCQA/pylint-django/issues/338>`_) - newer versions of pylint expect a different format for the expected messages txt files.
9+
- TODO: Bumped dependency for pylint-django-utils to get `multi-threaded pylint support <https://github.com/PyCQA/pylint-plugin-utils/pull/21>`_
10+
411
Version 2.4.4 (26 Apr 2021)
512
---------------------------
613

README.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
pylint-django
22
=============
33

4-
.. image:: https://travis-ci.org/PyCQA/pylint-django.svg?branch=master
5-
:target: https://travis-ci.org/PyCQA/pylint-django
6-
7-
.. image:: https://landscape.io/github/landscapeio/pylint-django/master/landscape.png
8-
:target: https://landscape.io/github/landscapeio/pylint-django
4+
.. image:: https://github.com/PyCQA/pylint-django/actions/workflows/testing.yml/badge.svg
5+
:target: https://github.com/PyCQA/pylint-django/actions/workflows/testing.yml
96

107
.. image:: https://coveralls.io/repos/PyCQA/pylint-django/badge.svg
118
:target: https://coveralls.io/r/PyCQA/pylint-django

pylint_django/augmentations/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,10 @@
281281

282282
VIEW_ATTRS = {
283283
(
284-
("{}.{}".format(cls.__module__, cls.__name__), ".{}".format(cls.__name__)),
284+
(
285+
f"{cls.__module__}.{cls.__name__}",
286+
f".{cls.__name__}",
287+
),
285288
tuple(cls.__dict__.keys()),
286289
)
287290
for cls in (

pylint_django/checkers/auth_user.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,15 @@ class AuthUserChecker(checkers.BaseChecker):
1010
name = "auth-user-checker"
1111

1212
msgs = {
13-
"E%d41"
14-
% BASE_ID: (
13+
f"E{BASE_ID}41": (
1514
"Hard-coded 'auth.User'",
1615
"hard-coded-auth-user",
17-
"Don't hard-code the auth.User model. " "Use settings.AUTH_USER_MODEL instead!",
16+
"Don't hard-code the auth.User model. Use settings.AUTH_USER_MODEL instead!",
1817
),
19-
"E%d42"
20-
% BASE_ID: (
18+
f"E{BASE_ID}42": (
2119
"User model imported from django.contrib.auth.models",
2220
"imported-auth-user",
23-
"Don't import django.contrib.auth.models.User model. " "Use django.contrib.auth.get_user_model() instead!",
21+
"Don't import django.contrib.auth.models.User model. Use django.contrib.auth.get_user_model() instead!",
2422
),
2523
}
2624

pylint_django/checkers/django_installed.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ class DjangoInstalledChecker(BaseChecker):
1010
name = "django-installed-checker"
1111

1212
msgs = {
13-
"F%s01"
14-
% BASE_ID: (
13+
f"F{BASE_ID}01": (
1514
"Django is not available on the PYTHONPATH",
1615
"django-not-available",
1716
"Django could not be imported by the pylint-django plugin, so most Django related "
1817
"improvements to pylint will fail.",
1918
),
20-
"W%s99"
21-
% BASE_ID: (
19+
f"W{BASE_ID}99": (
2220
"Placeholder message to prevent disabling of checker",
2321
"django-not-available-placeholder",
2422
"PyLint does not recognise checkers as being enabled unless they have at least"

pylint_django/checkers/foreign_key_strings.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,13 @@ class ForeignKeyStringsChecker(BaseChecker):
4444
)
4545

4646
msgs = {
47-
"E%s10"
48-
% BASE_ID: (
47+
f"E{BASE_ID}10": (
4948
"Django was not configured. For more information run "
5049
"pylint --load-plugins=pylint_django --help-msg=django-not-configured",
5150
"django-not-configured",
5251
_LONG_MESSAGE,
5352
),
54-
"F%s10"
55-
% BASE_ID: (
53+
f"F{BASE_ID}10": (
5654
"Provided Django settings %s could not be loaded",
5755
"django-settings-module-not-found",
5856
"The provided Django settings module %s was not found on the path",
@@ -80,9 +78,12 @@ def open(self):
8078
# must wait until some module is inspected to be able to raise... so that
8179
# state is stashed in this property.
8280

83-
from django.core.exceptions import ( # pylint: disable=import-outside-toplevel
84-
ImproperlyConfigured,
85-
)
81+
try:
82+
from django.core.exceptions import ( # pylint: disable=import-outside-toplevel
83+
ImproperlyConfigured,
84+
)
85+
except ModuleNotFoundError:
86+
return
8687

8788
try:
8889
import django # pylint: disable=import-outside-toplevel

pylint_django/checkers/forms.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ class FormChecker(BaseChecker):
2222

2323
name = "django-form-checker"
2424
msgs = {
25-
"W%d04"
26-
% BASE_ID: (
25+
f"W{BASE_ID}04": (
2726
"Use explicit fields instead of exclude in ModelForm",
2827
"modelform-uses-exclude",
29-
"Prevents accidentally allowing users to set fields, " "especially when adding new fields to a Model",
28+
"Prevents accidentally allowing users to set fields, especially when adding new fields to a Model",
3029
)
3130
}
3231

@@ -47,5 +46,5 @@ def visit_classdef(self, node):
4746
continue
4847

4948
if child.targets[0].name == "exclude":
50-
self.add_message("W%s04" % BASE_ID, node=child)
49+
self.add_message(f"W{BASE_ID}04", node=child)
5150
break

pylint_django/checkers/json_response.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,17 @@ class JsonResponseChecker(checkers.BaseChecker):
2424
# configuration section name
2525
name = "json-response-checker"
2626
msgs = {
27-
"R%s01"
28-
% BASE_ID: (
27+
f"R{BASE_ID}01": (
2928
"Instead of HttpResponse(json.dumps(data)) use JsonResponse(data)",
3029
"http-response-with-json-dumps",
3130
"Used when json.dumps() is used as an argument to HttpResponse().",
3231
),
33-
"R%s02"
34-
% BASE_ID: (
32+
f"R{BASE_ID}02": (
3533
"Instead of HttpResponse(content_type='application/json') use JsonResponse()",
3634
"http-response-with-content-type-json",
3735
"Used when HttpResponse() is returning application/json.",
3836
),
39-
"R%s03"
40-
% BASE_ID: (
37+
f"R{BASE_ID}03": (
4138
"Redundant content_type parameter for JsonResponse()",
4239
"redundant-content-type-for-json-response",
4340
"Used when JsonResponse() contains content_type parameter. "

pylint_django/checkers/migrations.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,10 @@ class NewDbFieldWithDefaultChecker(checkers.BaseChecker):
5656
# configuration section name
5757
name = "new-db-field-with-default"
5858
msgs = {
59-
"W%s98"
60-
% BASE_ID: (
59+
f"W{BASE_ID}98": (
6160
"%s AddField with default value",
6261
"new-db-field-with-default",
63-
"Used when Pylint detects migrations adding new " "fields with a default value.",
62+
"Used when Pylint detects migrations adding new fields with a default value.",
6463
)
6564
}
6665

@@ -119,11 +118,10 @@ class MissingBackwardsMigrationChecker(checkers.BaseChecker):
119118
name = "missing-backwards-migration-callable"
120119

121120
msgs = {
122-
"W%s97"
123-
% BASE_ID: (
121+
f"W{BASE_ID}97": (
124122
"Always include backwards migration callable",
125123
"missing-backwards-migration-callable",
126-
"Always include a backwards/reverse callable counterpart" " so that the migration is not irreversable.",
124+
"Always include a backwards/reverse callable counterpart so that the migration is not irreversable.",
127125
)
128126
}
129127

0 commit comments

Comments
 (0)