diff --git a/.fussyfox.yml b/.fussyfox.yml deleted file mode 100644 index 6a17e6bd..00000000 --- a/.fussyfox.yml +++ /dev/null @@ -1,5 +0,0 @@ -- bandit -- black -- flake8 -- isort -- pydocstyle diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ddd59a2e..042d813a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,26 @@ on: jobs: + lint: + runs-on: ubuntu-latest + strategy: + matrix: + lint-command: + - bandit -r . -x ./tests + - black --check --diff . + - flake8 . + - isort --check-only --diff . + - pydocstyle . + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.x" + cache: 'pip' + cache-dependency-path: 'linter-requirements.txt' + - run: python -m pip install -r linter-requirements.txt + - run: ${{ matrix.lint-command }} + dist: runs-on: ubuntu-latest steps: @@ -41,6 +61,7 @@ jobs: PyTest: needs: + - lint - standardjs strategy: matrix: @@ -65,6 +86,7 @@ jobs: Selenium: needs: + - lint - standardjs strategy: matrix: diff --git a/django_select2/conf.py b/django_select2/conf.py index a3117014..03ebe7dd 100644 --- a/django_select2/conf.py +++ b/django_select2/conf.py @@ -198,7 +198,7 @@ class Select2Conf(AppConf): ``settings.DJANGO_SELECT2_I18N`` refers to :attr:`.I18N_PATH`. """ - JSON_ENCODER = 'django.core.serializers.json.DjangoJSONEncoder' + JSON_ENCODER = "django.core.serializers.json.DjangoJSONEncoder" """ A :class:`JSONEncoder` used to generate the API response for the model widgets. diff --git a/django_select2/views.py b/django_select2/views.py index 0af69b64..1665dbd5 100644 --- a/django_select2/views.py +++ b/django_select2/views.py @@ -2,8 +2,8 @@ from django.core import signing from django.core.signing import BadSignature from django.http import Http404, JsonResponse -from django.views.generic.list import BaseListView from django.utils.module_loading import import_string +from django.views.generic.list import BaseListView from .cache import cache from .conf import settings @@ -45,7 +45,7 @@ def get(self, request, *args, **kwargs): ], "more": context["page_obj"].has_next(), }, - encoder=import_string(settings.SELECT2_JSON_ENCODER) + encoder=import_string(settings.SELECT2_JSON_ENCODER), ) def get_queryset(self): diff --git a/linter-requirements.txt b/linter-requirements.txt new file mode 100644 index 00000000..c3083bcb --- /dev/null +++ b/linter-requirements.txt @@ -0,0 +1,5 @@ +bandit==1.7.4 +black==22.10.0 +flake8==5.0.4 +isort==5.10.1 +pydocstyle[toml]==6.1.1 diff --git a/tests/conftest.py b/tests/conftest.py index 3ac31e51..60bbe399 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,9 +7,8 @@ def pytest_configure(config): - config.addinivalue_line( - "markers", "selenium: skip if selenium is not installed" - ) + config.addinivalue_line("markers", "selenium: skip if selenium is not installed") + def random_string(n): return "".join( diff --git a/tests/test_forms.py b/tests/test_forms.py index 6e81f50b..621a24e1 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -20,8 +20,8 @@ HeavySelect2Widget, ModelSelect2TagWidget, ModelSelect2Widget, - Select2Widget, Select2AdminMixin, + Select2Widget, ) from tests.testapp import forms from tests.testapp.forms import (