Skip to content

Commit

Permalink
Merge pull request #92 from StevenMapes/develop
Browse files Browse the repository at this point in the history
Updating actions and readme to show support for Django 3.2, 4.0, 4.1, 4.2 and 5.0 including new testing matrix
  • Loading branch information
StevenMapes authored Oct 18, 2024
2 parents a551c93 + ed7af73 commit 20d9cfa
Show file tree
Hide file tree
Showing 15 changed files with 291 additions and 181 deletions.
8 changes: 8 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
max-line-length = 119
exclude =
.git,
__pycache__,
.venv,
build
ignore = E101,E111,E114,E115,E116,E117,E12,E13,E2,E3,E401,E5,E70,W1,W2,W3,W5
60 changes: 40 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,60 @@ jobs:
fail-fast: false
matrix:
include:
- python: 3.x
toxenv: lint
- python: 3.6
toxenv: py36-django22
- python: 3.7
toxenv: py37-django22
- python: 3.8
toxenv: py38-django22
- python: 3.9
toxenv: py39-django22
- python: 3.6
toxenv: py36-django30
- python: 3.7
toxenv: py37-django30
- python: 3.8
toxenv: py38-django30
- python: 3.9
toxenv: py39-django30
- python: 3.6
toxenv: py36-django31
- python: 3.7
toxenv: py37-django31
- python: 3.8
toxenv: py38-django31
- python: 3.9
toxenv: py39-django31
- python: 3.6
toxenv: py36-djangomaster
- python: 3.7
toxenv: py37-djangomaster
- python: 3.8
toxenv: py38-djangomaster
toxenv: py38-django32
- python: 3.9
toxenv: py39-djangomaster
toxenv: py39-django32
- python: "3.10"
toxenv: py310-django32
- python: 3.8
toxenv: py38-django40
- python: 3.8
toxenv: py38-django40
- python: "3.10"
toxenv: py310-django40
- python: 3.8
toxenv: py38-django41
- python: 3.9
toxenv: py39-django41
- python: "3.10"
toxenv: py310-django41
- python: "3.11"
toxenv: py311-django41
- python: "3.10"
toxenv: py310-django42
- python: "3.11"
toxenv: py311-django42
- python: "3.12"
toxenv: py312-django42
- python: "3.10"
toxenv: py310-django50
- python: "3.11"
toxenv: py311-django50
- python: "3.12"
toxenv: py312-django50
- python: "3.13"
toxenv: py313-django50
- python: "3.10"
toxenv: py310-django51
- python: "3.11"
toxenv: py311-django51
- python: "3.12"
toxenv: py312-django51
- python: "3.13"
toxenv: py313-django51

steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
__pycache__/
build/
dist/

.idea
.venv
25 changes: 17 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
repos:
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
- repo: https://github.com/PyCQA/isort
rev: 5.6.4
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: 7.1.0
hooks:
- id: flake8
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/asottile/blacken-docs
rev: 1.18.0
hooks:
- id: blacken-docs
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
2 changes: 2 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
``decorator_include`` was written by Jeff Kistler in 2011.

Adapted for Python 3 and Django 1.6+ by Stéphane "Twidi" Angel <[email protected]>
Adapted for Python 3.10 and Django 4+ by Steven Mapes <[email protected]>

Contributors
------------

* Jeff Kistler
* Stéphane "Twidi" Angel <https://www.twidi.com/>
* Steve Mapes <https://www.mapestech.co.uk/>
* Jon Dufresne <[email protected]>
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

Release *v3.1* - ``TBC``
-------------------------------
* Updated to include support for Python < 3.14 and Django <5.2
* Updated to use Black along with Flake8 and iSort

Release *v3.0* - ``2020-05-07``
-------------------------------
* Handle namespace/app_name the same way as Django `include` function
Expand Down
57 changes: 38 additions & 19 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,49 @@ Herei s an example URL conf::
Supported versions
------------------

=============== ==================
=============== ========================
Django versions Python versions
=============== ==================
=============== ========================
2.2 3.6, 3.7, 3.8, 3.9
3.0 3.6, 3.7, 3.8, 3.9
3.1 3.6, 3.7, 3.8, 3.9
=============== ==================
3.2 3.6, 3.7, 3.8, 3.9, 3.10
4.0 3.8, 3.9, 3.10
4.1 3.8, 3.9, 3.10, 3.11
4.2 3.8, 3.9, 3.10, 3.11, 3.12
5.0 3.10, 3.11, 3.12, 3.13
5.1 3.10, 3.11, 3.12, 3.13

=============== ========================

* Python 3.11 only works with Django 4.1.3+


All library versions to use for old Django/Python support
---------------------------------------------------------

=============== ======================= ==================
Django versions Python versions Library versions
=============== ======================= ==================
1.4, 1.5 2.6, 2.7 1.2
1.6 2.6, 2.7, 3.2, 3.3 1.2
1.7 2.7, 3.2, 3.3, 3.4 1.2
1.8 2.7, 3.2, 3.3, 3.4, 3.5 1.3
1.9, 1.10 2.7, 3.4, 3.5 1.3
1.11 2.7, 3.4, 3.5, 3.6 1.4.x (>=1.4.1,<2)
2.0 3.4, 3.5, 3.6, 3.7 3.0
2.1 3.5, 3.6, 3.7 3.0
2.2 3.5, 3.6, 3.7, 3.8, 3.9 3.0
3.0 3.6, 3.7, 3.8, 3.9 3.0
3.1 3.6, 3.7, 3.8, 3.9 3.0
=============== ======================= ==================
=============== ======================== ==================
Django versions Python versions Library versions
=============== ======================== ==================
1.4, 1.5 2.6, 2.7 1.2
1.6 2.6, 2.7, 3.2, 3.3 1.2
1.7 2.7, 3.2, 3.3, 3.4 1.2
1.8 2.7, 3.2, 3.3, 3.4, 3.5 1.3
1.9, 1.10 2.7, 3.4, 3.5 1.3
1.11 2.7, 3.4, 3.5, 3.6 1.4.x (>=1.4.1,<2)
2.0 3.4, 3.5, 3.6, 3.7 3.0
2.1 3.5, 3.6, 3.7 3.0
2.2 3.5, 3.6, 3.7, 3.8, 3.9 3.0
3.0 3.6, 3.7, 3.8, 3.9 3.0
3.1 3.6, 3.7, 3.8, 3.9 3.0
3.2 3.6, 3.7, 3.8, 3.9, 3.10 3.0
4.0 3.8, 3.9, 3.10 3.0
4.1 3.8, 3.9, 3.10 3.0
4.2 3.10, 3.11, 3.12 3.0
4.2 3.10, 3.11, 3.12 3.0
5.0 3.10, 3.11, 3.12, 3.13 3.0
5.1 3.10, 3.11, 3.12, 3.13 3.0
=============== ======================== ==================


Development
Expand Down Expand Up @@ -115,7 +132,7 @@ Or simply launch the ``runtests.sh`` script (it will run this exact command)::

./runtests.sh

This project uses `pre-commit`_ to automatically run `flake8`_ and `isort`_ on
This project uses `pre-commit`_ to automatically run `black`_ , `flake8`_ and `isort`_ on
every commit. If you haven't already, first install pre-commit using the
project's documentation. Then, to enable pre-commit for
django-decorator-include::
Expand All @@ -141,3 +158,5 @@ When creating the pull request, ensure you are using the correct base
.. _pre-commit: https://pre-commit.com/
.. _flake8: https://flake8.pycqa.org/
.. _isort: https://pycqa.github.io/isort/
.. _black: https://github.com/psf/black/

24 changes: 9 additions & 15 deletions decorator_include.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,29 @@
"""

from importlib import import_module
from os import path

import pkg_resources
from django.urls import URLPattern, URLResolver, include
from django.utils.functional import cached_property


def _extract_version(package_name):
try:
# if package is installed
version = pkg_resources.get_distribution(package_name).version
except pkg_resources.DistributionNotFound:
# if not installed, so we must be in source, with ``setup.cfg`` available
from setuptools.config import read_configuration
_conf = read_configuration(path.join(
path.dirname(__file__), 'setup.cfg')
)
version = _conf['metadata']['version']
import importlib.metadata as importlib_metadata
except ImportError: # for python < 3.8
import importlib_metadata
version = importlib_metadata.version(package_name)

return tuple(int(part) for part in version.split('.') if part.isnumeric())
return tuple(int(part) for part in version.split(".") if part.isnumeric())


VERSION = _extract_version('django_decorator_include')
VERSION = _extract_version("django_decorator_include")


class DecoratedPatterns(object):
"""
A wrapper for an urlconf that applies a decorator to all its views.
"""

def __init__(self, urlconf_module, decorators):
# ``urlconf_module`` may be:
# - an object with an ``urlpatterns`` attribute
Expand Down Expand Up @@ -70,7 +64,7 @@ def decorate_pattern(self, pattern):
@cached_property
def urlpatterns(self):
# urlconf_module might be a valid set of patterns, so we default to it.
patterns = getattr(self.urlconf_module, 'urlpatterns', self.urlconf_module)
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
return [self.decorate_pattern(pattern) for pattern in patterns]

@cached_property
Expand All @@ -82,7 +76,7 @@ def urlconf_module(self):

@cached_property
def app_name(self):
return getattr(self.urlconf_module, 'app_name', None)
return getattr(self.urlconf_module, "app_name", None)


def decorator_include(decorators, arg, namespace=None):
Expand Down
16 changes: 14 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = django-decorator-include
version = 3.0
version = 3.1
author = Jeff Kistler
author_email = [email protected]
url = https://github.com/twidi/django-decorator-include
Expand All @@ -15,6 +15,12 @@ classifiers =
Framework :: Django :: 2.2
Framework :: Django :: 3.0
Framework :: Django :: 3.1
Framework :: Django :: 3.2
Framework :: Django :: 4.0
Framework :: Django :: 4.1
Framework :: Django :: 4.2
Framework :: Django :: 5.0
Framework :: Django :: 5.1
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Expand All @@ -25,12 +31,18 @@ classifiers =
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Topic :: Internet :: WWW/HTTP

[options]
zip_safe = True
py_modules = decorator_include
install_requires = Django>=2.2
install_requires =
Django>=2.2
importlib_metadata; python_version<"3.8"
python_requires = >=3.6

[flake8]
Expand Down
6 changes: 3 additions & 3 deletions tests/included.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@


def testify(request):
return HttpResponse('testify!')
return HttpResponse("testify!")


urlpatterns = [
path('included/', include('tests.included2')),
path('test/', testify, name='testify'),
path("included/", include("tests.included2")),
path("test/", testify, name="testify"),
]
4 changes: 2 additions & 2 deletions tests/included2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


def deeply_nested(request):
return HttpResponse('deeply nested!')
return HttpResponse("deeply nested!")


urlpatterns = [
path('deeply_nested/', deeply_nested, name='deeply_nested'),
path("deeply_nested/", deeply_nested, name="deeply_nested"),
]
Loading

0 comments on commit 20d9cfa

Please sign in to comment.