diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3c526bf..35d31ae 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: python-version: [3.10.x] - toxenv: [pep8, isort, black, pypi-description, docs, towncrier] + toxenv: [ruff, isort, black, pypi-description, docs, towncrier] steps: - uses: actions/checkout@v3 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ec9036c..919ca43 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,19 +9,10 @@ jobs: continue-on-error: ${{ matrix.continue-on-error }} strategy: matrix: - python-version: [3.11, 3.10.x, 3.9, 3.8, 3.7] - django: [32, 22] - cms: [nocms, cms37, cms38, cms39, cms311, async] + python-version: [3.11, 3.10.x, 3.9] + django: [42, 32] + cms: [nocms, cms311, async] continue-on-error: [false] - exclude: - - python-version: 3.10.3 - django: 22 - - django: 32 - cms: cms37 - - django: 32 - cms: cms38 - - django: 22 - cms: cms311 steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4c1a6e4..a622c7b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,34 +25,21 @@ repos: rev: 23.3.0 hooks: - id: black - - repo: https://github.com/pycqa/flake8 - rev: 5.0.4 + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: 'v0.0.262' hooks: - - id: flake8 - additional_dependencies: - - flake8-broken-line - - flake8-bugbear - - flake8-builtins - - flake8-coding - - flake8-commas - - flake8-comprehensions - - flake8-eradicate - - flake8-quotes - - flake8-tidy-imports - - pep8-naming - - repo: https://github.com/econchick/interrogate - rev: 1.5.0 - hooks: - - id: interrogate - args: - - "-cpyproject.toml" - - "--quiet" + - id: ruff - repo: https://github.com/asottile/pyupgrade rev: v3.3.1 hooks: - id: pyupgrade args: - --py3-plus + - repo: https://github.com/adamchainz/django-upgrade + rev: "1.13.0" + hooks: + - id: django-upgrade + args: [--target-version, "3.2"] - repo: local hooks: - id: towncrier diff --git a/.pyup.yml b/.pyup.yml new file mode 100644 index 0000000..e036ee9 --- /dev/null +++ b/.pyup.yml @@ -0,0 +1,7 @@ +update: all +pin: False +branch: +schedule: "every week" +search: True +branch_prefix: pyup/ +close_prs: True diff --git a/app_helper/urls.py b/app_helper/urls.py index cc81b9d..9cef0f8 100644 --- a/app_helper/urls.py +++ b/app_helper/urls.py @@ -1,9 +1,8 @@ from django.conf import settings -from django.conf.urls import include from django.conf.urls.i18n import i18n_patterns from django.contrib import admin from django.contrib.staticfiles.urls import staticfiles_urlpatterns -from django.urls import re_path +from django.urls import include, path, re_path from django.views.i18n import JavaScriptCatalog from django.views.static import serve @@ -28,7 +27,7 @@ pass if settings.USE_CMS: - i18n_urls.append(re_path(r"^", include("cms.urls"))) # NOQA + i18n_urls.append(path("", include("cms.urls"))) # NOQA urlpatterns += i18n_patterns(*i18n_urls) urlpatterns += staticfiles_urlpatterns() diff --git a/changes/208.feature b/changes/208.feature new file mode 100644 index 0000000..155dea0 --- /dev/null +++ b/changes/208.feature @@ -0,0 +1 @@ +Add support for Django 4.x diff --git a/helper.py b/helper.py index 667424e..46717ef 100755 --- a/helper.py +++ b/helper.py @@ -21,7 +21,7 @@ def gettext(s): import cms # noqa: F401 HELPER_SETTINGS["INSTALLED_APPS"].append("djangocms_text_ckeditor") -except ImportError: +except (ImportError, ModuleNotFoundError): pass @@ -32,7 +32,7 @@ def run(): import cms # noqa: F401 F811 runner.cms("app_helper") - except ImportError: + except (ImportError, ModuleNotFoundError): runner.run("app_helper") @@ -43,7 +43,7 @@ def setup(): import cms # noqa: F401 F811 use_cms = True - except ImportError: + except (ImportError, ModuleNotFoundError): use_cms = False runner.setup("app_helper", sys.modules[__name__], use_cms=use_cms) diff --git a/pyproject.toml b/pyproject.toml index 1c88cc6..7e89d11 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,3 +28,22 @@ verbose = 0 quiet = false whitelist-regex = [] color = true + +[tool.isort] +profile = "black" +combine_as_imports = true +default_section = "THIRDPARTY" +force_grid_wrap = 0 +include_trailing_comma = true +known_first_party = "knocker" +line_length = 119 +multi_line_output = 3 +use_parentheses = true + +[tool.ruff] +ignore = [] +line-length = 119 +target-version = "py310" + +[tool.ruff.mccabe] +max-complexity = 10 diff --git a/setup.cfg b/setup.cfg index c1d5679..eedecf4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [bumpversion] current_version = 3.2.1.dev0 parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.?)(?P[a-z]*)(?P\d*) -serialize = +serialize = {major}.{minor}.{patch}.{release}{relver} {major}.{minor}.{patch} commit = True @@ -12,7 +12,7 @@ message = Release {new_version} [bumpversion:part:release] optional_value = gamma -values = +values = dev a b @@ -25,7 +25,7 @@ values = name = django-app-helper version = attr: app_helper.__version__ url = https://github.com/nephila/django-app-helper -project_urls = +project_urls = Documentation = https://django-app-helper.readthedocs.io/ author = Iacopo Spalletti author_email = i.spalletti@nephila.digital @@ -34,12 +34,13 @@ long_description = file: README.rst, HISTORY.rst long_description_content_type = text/x-rst license = GPLv2+ license_file = LICENSE -classifiers = +classifiers = License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+) Development Status :: 5 - Production/Stable Framework :: Django - Framework :: Django :: 2.2 Framework :: Django :: 3.2 + Framework :: Django :: 4.1 + Framework :: Django :: 4.2 Programming Language :: Python Programming Language :: Python :: 3 Programming Language :: Python :: 3.7 @@ -50,17 +51,17 @@ classifiers = [options] include_package_data = True -install_requires = +install_requires = dj-database-url docopt six -setup_requires = +setup_requires = setuptools packages = find: python_requires = >=3.7 test_suite = app_helper.tests zip_safe = False -keywords = +keywords = django tests development @@ -72,12 +73,12 @@ keywords = app_helper = *.html *.png *.gif *js *jpg *jpeg *svg *py *mo *po [options.entry_points] -console_scripts = +console_scripts = django-app-helper = app_helper.main:main [options.extras_require] cms = django-cms>=3.7,<3.12 -async = +async = channels daphne diff --git a/tasks.py b/tasks.py index ce8eaf5..22d63a4 100644 --- a/tasks.py +++ b/tasks.py @@ -26,7 +26,7 @@ def clean(c): @task def lint(c): """Run linting tox environments.""" - c.run("tox -epep8,isort,black,pypi-description") + c.run("tox -eruff,isort,black,pypi-description") @task # NOQA diff --git a/tests/test_commands.py b/tests/test_commands.py index 5623bd0..2eb1efa 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -386,6 +386,8 @@ def test_extra_settings(self): def test_server_django(self, run_with_reloader): """Run server command and create default user - django version.""" with work_in(self.basedir): + User = get_user_model() + User.objects.all().delete() with captured_output() as (out, err): args = copy(DEFAULT_ARGS) args["server"] = True @@ -401,6 +403,8 @@ def test_server_channels(self, run_with_reloader): import channels # noqa: F401 except ImportError: raise unittest.SkipTest("channels is not available, skipping test") + if channels.__version__ > "4.0": + raise unittest.SkipTest("channels 4 removed support for runserver, use daphne version instead, skipping") with work_in(self.basedir): with captured_output() as (out, err): args = copy(DEFAULT_ARGS) @@ -420,6 +424,8 @@ def test_server_daphne(self, run_with_reloader): except ImportError: raise unittest.SkipTest("daphne is not available, skipping test") with work_in(self.basedir): + User = get_user_model() + User.objects.all().delete() with captured_output() as (out, err): args = copy(DEFAULT_ARGS) args["server"] = True diff --git a/tox.ini b/tox.ini index f92702d..e0ad65f 100644 --- a/tox.ini +++ b/tox.ini @@ -5,38 +5,25 @@ envlist = docs isort isort_format - pep8 + ruff pypi-description towncrier - py{311}-django{41,40,32}-{cms311, nocms, async} - py{310}-django{41,40,32}-{cms311,cms310,nocms,async} - py{39,38,37}-django{32}-{cms311,cms310,cms39,nocms,async} - py{39,38,37}-django{22}-{cms310,cms39,cms38,cms37,nocms,async} + py{311}-django{42,41,40,32}-{cms311,nocms,async} + py{310}-django{42,41,40,32}-{cms311,nocms,async} + py{39}-django{32}-{cms311,nocms,async} minversion = 3.23 [testenv] commands = {env:COMMAND:python} helper.py {posargs} deps= - django22: django~=2.2.0 django32: django~=3.2.0 - django32: channels>2.0,<4.0 - django32: daphne<4.0 - django32: asgiref django40: django~=4.0.0 - django41: django~=4.1rc1 - cms37: https://github.com/divio/django-cms/archive/release/3.7.x.zip - cms37: djangocms-text-ckeditor - cms38: https://github.com/divio/django-cms/archive/release/3.8.x.zip - cms38: djangocms-text-ckeditor>=4.0,<5.0 - cms39: https://github.com/divio/django-cms/archive/release/3.9.x.zip - cms39: djangocms-text-ckeditor>=5.0,<6.0 - cms310: https://github.com/divio/django-cms/archive/release/3.10.x.zip - cms310: djangocms-text-ckeditor>=5.0,<6.0 + django41: django~=4.1.0 + django42: django~=4.2.0 cms311: https://github.com/divio/django-cms/archive/release/3.11.x.zip cms311: djangocms-text-ckeditor>=5.0,<6.0 -r{toxinidir}/requirements-test.txt - async: channels>2.0 - async: daphne + async: channels[daphne]~=4.0.0 passenv = COMMAND PYTEST_* @@ -44,29 +31,19 @@ passenv = [testenv:nocms] alwayscopy = True -[testenv:pep8] +[testenv:ruff] commands = - {envpython} -m flake8 + {envpython} -m ruff check app_helper tests {posargs} {envpython} -minterrogate -c pyproject.toml app_helper tests deps = interrogate - flake8 - flake8-broken-line - flake8-bugbear - flake8-builtins - flake8-coding - flake8-commas - flake8-comprehensions - flake8-eradicate - flake8-quotes - flake8-tidy-imports - pep8-naming + ruff skip_install = true [testenv:isort] commands = {envpython} -m isort -c --df app_helper tests -deps = isort>5.10,<5.11 +deps = isort~=5.12.0 skip_install = true [testenv:isort_format] @@ -111,12 +88,12 @@ skip_install = true commands = {envpython} -m invoke clean {envpython} -m check_manifest - {envpython} -m pep517.build . + {envpython} -m build . {envpython} -m twine check dist/* deps = invoke check-manifest - pep517 + build twine skip_install = true @@ -124,35 +101,13 @@ skip_install = true commands = {envpython} -m invoke clean {envpython} -m check_manifest - {envpython} -m pep517.build . + {envpython} -m build . {envpython} -m twine upload {posargs} dist/* deps = {[testenv:pypi-description]deps} passenv = TWINE_* skip_install = true -[flake8] -exclude = *.egg-info,.git,.settings,.tox,build,dist,docs,requirements,tmp,*migrations*,tests,data -ignore = E800, W503, C812, C813, C815, C818, C819, C408 -max-line-length = 119 -# flake8-quotes -inline-quotes = double -# flake8-coding -no-accept-encodings = True -# flake8-tidy-imports -banned-modules = __future__ = this project supports python3 only - -[isort] -combine_as_imports = true -default_section = THIRDPARTY -force_grid_wrap = 0 -include_trailing_comma = true -known_first_party = app_helper -line_length = 119 -multi_line_output = 3 -skip = data, .tox -use_parentheses = True - [check-manifest] ignore = .*