Skip to content

Commit

Permalink
get_context call to super, drop support below DJ4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Feb 11, 2024
1 parent 5825483 commit f0a10dc
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 46 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10']
django-version: ['3.2', '4.0', '4.1', 'dev']
python-version: ['3.11', '3.12']
django-version: ['4.2', '5.0', 'dev']

exclude:
- python-version: '3.12'
django-version: '4.2'
- python-version: '3.11'
django-version: 'dev'
services:

mysql:
image: mysql:latest
env:
Expand All @@ -32,20 +36,19 @@ jobs:
sudo apt-get -y update
sudo apt-get install libcups2-dev wamerican
- uses: actions/checkout@v2

- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
echo "dir=$(pip cache dir)" >>$GITHUB_OUTPUT
- name: Cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
Expand All @@ -65,7 +68,7 @@ jobs:
env:
DJANGO: ${{ matrix.django-version }}

- name: Upload coverage
uses: codecov/codecov-action@v1
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
name: Python ${{ matrix.python-version }}
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ exclude: tests/etc/user-*

repos:
- repo: https://github.com/PyCQA/bandit
rev: 1.7.4
rev: 1.7.7
hooks:
- id: bandit
args:
- "-x *test*.py"

- repo: https://github.com/psf/black
rev: 22.6.0
rev: 24.1.1
hooks:
- id: black
language_version: python3.9
language_version: python3.11

- repo: https://github.com/pycqa/flake8
rev: 5.0.4
rev: 7.0.0
hooks:
- id: flake8
args:
- "--config=setup.cfg"

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: requirements-txt-fixer
files: requirements/.*\.txt$
Expand All @@ -42,7 +42,7 @@ repos:
- id: detect-private-key

- repo: https://github.com/adrienverge/yamllint
rev: v1.27.1
rev: v1.33.0
hooks:
- id: yamllint
args:
Expand Down
10 changes: 5 additions & 5 deletions django_revision/views.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Any

from .revision import Revision


class RevisionMixin:

manual_revision = None

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
def get_context_data(self, **kwargs) -> dict[str, Any]:
revision = Revision(manual_revision=self.manual_revision)
context.update({"revision": revision.tag or revision.commit})
return context
kwargs.update({"revision": revision.tag or revision.commit})
return super().get_context_data(**kwargs)
35 changes: 18 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
[build-system]
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=60", "setuptools-scm>=8.0"]

[tool.setuptools_scm]
write_to = "_version.py"
version_file="_version.py"

[tool.black]
line-length = 95
target-version = ["py39"]
target-version = ["py311"]
extend-exclude = '''^(.*\/)*\b(migrations)\b($|\/.*$)'''

[tool.isort]
profile = "black"
py_version = "39"
py_version = "311"
skip = [".tox", ".eggs", "migrations"]

[tool.coverage.run]
Expand All @@ -27,42 +26,44 @@ source = ["django_revision"]
show_missing = true
skip_covered = true
omit = ["requirements.txt"]
exclude_lines = [
"pragma: no cover",
"if TYPE_CHECKING:",
]

[tool.tox]
legacy_tox_ini = """
[tox]
envlist =
py{38,39,310}-dj{32,40,41,dev},
py{311}-dj{42,50},
py{312}-dj{50,dev},
lint
isolated_build = true
[gh-actions]
python =
3.8: py38
3.9: py39, lint
3.10: py310
3.11: py311
3.12: py312, lint
[gh-actions:env]
DJANGO =
3.2: dj32, lint
4.0: dj40
4.1: dj41
dev: djdev
4.2: dj42
5.0: dj50
dev: djdev, lint
[testenv]
deps =
-r https://raw.githubusercontent.com/clinicedc/edc/develop/requirements.tests/tox.txt
-r https://raw.githubusercontent.com/clinicedc/edc/develop/requirements.tests/test_utils.txt
-r https://raw.githubusercontent.com/clinicedc/edc/develop/requirements.tests/edc.txt
-r https://raw.githubusercontent.com/clinicedc/edc/develop/requirements.tests/third_party_dev.txt
dj32: Django>=3.2,<3.3
dj40: Django>=4.0,<4.1
dj41: Django>=4.1,<4.2
dj42: Django>=4.2,<5.0
dj50: Django>=5.0
djdev: https://github.com/django/django/tarball/main
commands =
pip install -U pip
pip install -U pip coverage[toml]
pip --version
pip freeze
coverage run -a runtests.py
Expand Down
11 changes: 4 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ keywords = django Edc fields git
classifiers=
Environment :: Web Environment
Framework :: Django
Framework :: Django :: 3.2
Framework :: Django :: 4.0
Framework :: Django :: 4.1
Framework :: Django :: 4.2
Intended Audience :: Developers
Intended Audience :: Science/Research
Operating System :: OS Independent
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
License :: OSI Approved :: GNU General Public License v3 (GPLv3)


[options]
python_requires = >=3.8
python_requires = >=3.11
zip_safe = False
include_package_data = True
packages = find:
Expand Down

0 comments on commit f0a10dc

Please sign in to comment.