Skip to content

Commit

Permalink
Add support for Django 4.2 (#214)
Browse files Browse the repository at this point in the history
* Replace flake8 with ruff
* Update classifiers
  • Loading branch information
yakky authored Apr 20, 2023
1 parent 7948d99 commit 9210b8b
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 3 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
29 changes: 8 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions .pyup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
update: all
pin: False
branch:
schedule: "every week"
search: True
branch_prefix: pyup/
close_prs: True
5 changes: 2 additions & 3 deletions app_helper/urls.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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()
1 change: 1 addition & 0 deletions changes/208.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for Django 4.x
6 changes: 3 additions & 3 deletions helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -32,7 +32,7 @@ def run():
import cms # noqa: F401 F811

runner.cms("app_helper")
except ImportError:
except (ImportError, ModuleNotFoundError):
runner.run("app_helper")


Expand All @@ -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)

Expand Down
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 11 additions & 10 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[bumpversion]
current_version = 3.2.1.dev0
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.?)(?P<release>[a-z]*)(?P<relver>\d*)
serialize =
serialize =
{major}.{minor}.{patch}.{release}{relver}
{major}.{minor}.{patch}
commit = True
Expand All @@ -12,7 +12,7 @@ message = Release {new_version}

[bumpversion:part:release]
optional_value = gamma
values =
values =
dev
a
b
Expand All @@ -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 = [email protected]
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down
Loading

0 comments on commit 9210b8b

Please sign in to comment.