Skip to content

Commit

Permalink
Merge pull request #45 from avallbona/upgrade-python-and-django
Browse files Browse the repository at this point in the history
Adding support for Python 3.10, 3.11 and 3.12; also adding support for Django 4.1 and 4.2
  • Loading branch information
avallbona authored Dec 3, 2023
2 parents d02813e + 5828569 commit 930e17f
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 56 deletions.
155 changes: 127 additions & 28 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Python package
name: python package

on:
push:
Expand All @@ -11,63 +11,162 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
# python: [3.5, 3.6, 3.7, 3.8, 3.9]
python: [3.6, 3.7, 3.8, 3.9]
django: [
"Django>=1.11,<2.0",
"Django>=2.0,<2.1",
"Django>=2.1,<2.2",
"Django>=2.2,<3.0",
"Django>=3.0,<3.1",
"Django>=3.1,<3.2"
"django>=2.0,<2.1",
"django>=2.1,<2.2",
"django>=2.2,<3.0",
"django>=3.0,<3.1",
"django>=3.1,<3.2",
"django>=3.2,<4.0",
"django>=4.0,<4.1",
"django>=4.1,<4.2",
"django>=4.2,<5.0",
]
# exclude:
# - python: 3.5
# django: Django>=3.0
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
exclude:
# django 2.0
- django: "django>=2.0,<2.1"
python: "3.8"
- django: "django>=2.0,<2.1"
python: "3.9"
- django: "django>=2.0,<2.1"
python: "3.10"
- django: "django>=2.0,<2.1"
python: "3.11"
- django: "django>=2.0,<2.1"
python: "3.12"
# django 2.1
- django: "django>=2.1,<2.2"
python: "3.4"
- django: "django>=2.1,<2.2"
python: "3.8"
- django: "django>=2.1,<2.2"
python: "3.9"
- django: "django>=2.1,<2.2"
python: "3.10"
- django: "django>=2.1,<2.2"
python: "3.11"
- django: "django>=2.1,<2.2"
python: "3.12"
# django 2.2
- django: "django>=2.2,<3.0"
python: "3.4"
- django: "django>=2.2,<3.0"
python: "3.10"
- django: "django>=2.2,<3.0"
python: "3.11"
- django: "django>=2.2,<3.0"
python: "3.12"
# django 3.0
- django: "django>=3.0,<3.1"
python: "3.4"
- django: "django>=3.0,<3.1"
python: "3.5"
- django: "django>=3.0,<3.1"
python: "3.10"
- django: "django>=3.0,<3.1"
python: "3.11"
- django: "django>=3.0,<3.1"
python: "3.12"
# django 3.1
- django: "django>=3.1,<3.2"
python: "3.4"
- django: "django>=3.1,<3.2"
python: "3.5"
- django: "django>=3.1,<3.2"
python: "3.10"
- django: "django>=3.1,<3.2"
python: "3.11"
- django: "django>=3.1,<3.2"
python: "3.12"
# django 3.2
- django: "django>=3.2,<4.0"
python: "3.4"
- django: "django>=3.2,<4.0"
python: "3.5"
- django: "django>=3.2,<4.0"
python: "3.11"
- django: "django>=3.2,<4.0"
python: "3.12"
# django 4.0
- django: "django>=4.0,<4.1"
python: "3.4"
- django: "django>=4.0,<4.1"
python: "3.5"
- django: "django>=4.0,<4.1"
python: "3.6"
- django: "django>=4.0,<4.1"
python: "3.7"
- django: "django>=4.0,<4.1"
python: "3.11"
- django: "django>=4.0,<4.1"
python: "3.12"
# django 4.1
- django: "django>=4.1,<4.2"
python: "3.4"
- django: "django>=4.1,<4.2"
python: "3.5"
- django: "django>=4.1,<4.2"
python: "3.6"
- django: "django>=4.1,<4.2"
python: "3.7"
- django: "django>=4.1,<4.2"
python: "3.12"
# django 4.2
- django: "django>=4.2,<5.0"
python: "3.4"
- django: "django>=4.2,<5.0"
python: "3.5"
- django: "django>=4.2,<5.0"
python: "3.6"
- django: "django>=4.2,<5.0"
python: "3.7"

steps:
- uses: actions/checkout@v2
- name: Setup Python
- name: setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install pytest, pytest-django and pytest-lazy-fixture, django and impostor
- name: install pytest, pytest-django and pytest-lazy-fixture, django and impostor
run: |
pip install pytest==6.1.2 pytest-django==4.1.0 pytest-lazy-fixture==0.6.3
pip install pytest==7.4.3 pytest-django==4.5.0 pytest-lazy-fixture==0.6.3
pip install "${{ matrix.django }}"
pip install -e .
- name: Run tests
run: pytest -v
- name: run tests
run: pytest -v tests/

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python
- name: setup python
uses: actions/setup-python@v2
- name: Install Tox and any other packages
- name: install tox and any other packages
run: |
pip install flake8
- name: Lint with flake8
- name: lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# stop the build if there are python syntax errors or undefined names
flake8 . --count --select=e9,f63,f7,f82 --show-source --statistics
# exit-zero treats all errors as warnings. the github editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python
- name: setup python
uses: actions/setup-python@v2
- name: Install Coverage
with:
python-version: "3.11"
- name: install coverage
run: |
pip install django pytest pytest-django pytest-lazy-fixture pytest-cov
pip install django pytest==7.4.3 pytest-django==4.7.0 pytest-lazy-fixture==0.6.3 pytest-cov==4.1.0
pip install -e .
- name: Execute coverage
- name: execute coverage
run: |
# execute tests with coverage
pytest --cov-report=xml --cov=impostor tests/
export CODECOV_TOKEN="${{ secrets.CODECOV_TOKEN }}"
export codecov_token="${{ secrets.codecov_token }}"
bash <(curl -s https://codecov.io/bash)
17 changes: 8 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
repos:
- repo: https://github.com/ambv/black
rev: 20.8b1
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
exclude: .tox, venv
- repo: https://github.com/timothycrosley/isort
rev: 5.7.0
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
files: .+\.py$
exclude: .tox, venv
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
files: .+\.py$
exclude: .tox, venv, migrations
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
rev: v4.5.0
hooks:
- id: debug-statements
files: .+\.py$
exclude: .tox, venv
files: .+\.py$
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 3.1.0 (2023-12-03)
* added support for django 4.1 and 4.2
* added support for python 3.10, 3.11 and 3.12
* dropped support for django 1.11
* dropped support for pythjon 3.4, 3.5 and 3.6

## 3.0.0 (2022-04-15)
* added support for django 3.2 and django 4.0
* implemented support for custom user model and custom USERNAME_FIELD ([Saurav Sharma](https://github.com/iamsauravsharma))
Expand Down
2 changes: 1 addition & 1 deletion impostor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Impostor."""
__version__ = "3.0.0"
__version__ = "3.1.0"
__author__ = "Marko Samastur"
__email__ = "[email protected]"
__mantainer__ = "Andreu Vallbona"
Expand Down
5 changes: 4 additions & 1 deletion impostor/templatetags/impostor_tags.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""template tags for impostor."""

from django import template

from impostor.models import ImpostorLog

register = template.Library()
Expand All @@ -14,7 +15,9 @@ def get_impersonated_as(request):
:return:
"""
try:
impersonated_as = ImpostorLog.objects.get(token=request.session['impostor_token'])
impersonated_as = ImpostorLog.objects.get(
token=request.session["impostor_token"]
)
except (ImpostorLog.DoesNotExist, KeyError):
impersonated_as = None

Expand Down
19 changes: 12 additions & 7 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
appdirs==1.4.4
asgiref==3.2.10
asgiref==3.7.2
attrs==19.3.0
backcall==0.2.0
coverage==7.3.2
decorator==4.4.2
Django==3.1.7
distlib==0.3.7
Django==4.2.7
filelock==3.0.12
importlib-metadata==1.6.1
importlib-resources==1.5.0
ipython==7.15.0
iniconfig==2.0.0
ipython==7.16.3
ipython-genutils==0.2.0
jedi==0.17.0
more-itertools==8.3.0
Expand All @@ -18,14 +22,15 @@ pluggy==0.13.1
prompt-toolkit==3.0.5
ptyprocess==0.6.0
py==1.10.0
Pygments==2.7.4
Pygments==2.17.2
pyparsing==2.4.7
pytest==6.1.2
pytest-django==4.1.0
pytest==7.4.3
pytest-cov==4.1.0
pytest-django==4.7.0
pytest-lazy-fixture==0.6.3
pytz==2020.1
six==1.15.0
sqlparse==0.3.1
sqlparse==0.4.4
toml==0.10.1
tox==3.15.2
traitlets==4.3.3
Expand Down
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,29 @@ def read(fname):
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Django :: 1.11",
"Framework :: Django :: 2.0",
"Framework :: Django :: 2.1",
"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",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"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",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Topic :: Utilities",
],
install_requires=[
"Django>=1.11",
"Django>=2.0",
],
)
Empty file added tests/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"django.contrib.staticfiles",
"django.contrib.auth",
"impostor",
"tests.testapp.apps.TestAppConfig",
"tests.testapp",
]

AUTHENTICATION_BACKENDS = (
Expand Down
Loading

0 comments on commit 930e17f

Please sign in to comment.