Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.3.0
current_version = 1.4.0
commit = False
tag = False

Expand All @@ -8,5 +8,5 @@ search = version = "{current_version}"
replace = version = "{new_version}"

[bumpversion:file:Makefile]
search = django-idempotency-key-{current_version}.tar.gz
replace = django-idempotency-key-{new_version}.tar.gz
search = django_idempotency_key-{current_version}.tar.gz
replace = django_idempotency_key-{new_version}.tar.gz
16 changes: 0 additions & 16 deletions .flake8

This file was deleted.

10 changes: 5 additions & 5 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: "Linting"
runs:
using: "composite"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4.2.2

- name: Set up Python 3.11
uses: actions/setup-python@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5.3.0
with:
python-version: "3.11"
python-version: "3.9"

- name: pre-commit
uses: pre-commit/[email protected].0
uses: pre-commit/[email protected].1
8 changes: 1 addition & 7 deletions .github/actions/tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ runs:
- name: Start Redis
uses: supercharge/[email protected]

- name: tox tests for python 3.7
- name: tox tests
shell: bash
if: ${{inputs.python-version == '3.7'}}
run: tox -e py37-django22-drf38,py37-django22-drf39,py37-django22-drf310,py37-django22-drf311,py37-django22-drf312,py37-django22-drf313,py37-django32-drf311,py37-django32-drf312,py37-django32-drf313

- name: tox tests for python >= 3.8
shell: bash
if: ${{inputs.python-version != '3.7'}}
run: |
tox
2 changes: 1 addition & 1 deletion .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
fail-fast: false
steps:
- name: Check out repository
Expand Down
9 changes: 0 additions & 9 deletions .isort.cfg

This file was deleted.

71 changes: 36 additions & 35 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.2
hooks:
- id: ruff
alias: autoformat
args: [--fix]
language_version: python3.9
- id: ruff-format
language_version: python3.9

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

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-json
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-encoding-pragma
args: [--remove]
- id: forbid-new-submodules
- id: mixed-line-ending
args: [--fix=lf]
- id: trailing-whitespace
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-ast
language_version: python3.9
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-xml
- id: check-yaml
- id: debug-statements
language_version: python3.9
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-encoding-pragma
args: [--remove]
- id: forbid-new-submodules
- id: mixed-line-ending
args: [--fix=lf]
- id: no-commit-to-branch
args: [--branch=master]
- id: trailing-whitespace
40 changes: 40 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# https://docs.astral.sh/ruff/tutorial/#configuration
# https://docs.astral.sh/ruff/settings/
# Set the maximum line length to 88.
line-length = 88
indent-width = 4
target-version="py39"

[lint]
select = [
"B", # flake8-bugbear
"C",
"DJ", # flake8-django
"E", # pycodestyle
"F", # Pyflakes
"I", # isort
"PL", # pylint
"UP", # pyupgrade
"W",
"B9"
]
ignore = ["E203", "B904", "DJ001", "DJ006", "W191"]


# Add the `line-too-long` rule to the enforced rule set. By default, Ruff omits rules that
# overlap with the use of a formatter, like Black, but we can override this behavior by
# explicitly adding the rule.
extend-select = ["E501"]

[format]
quote-style = "double"
indent-style = "space"

[lint.isort]
known-first-party = ["idempotency_key"]

[lint.mccabe] # DO NOT INCREASE THIS VALUE
max-complexity = 18 # default: 10

[lint.pylint]
max-args = 10
11 changes: 11 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ updating.

**[Breaking changes]** - There are changes that break existing compatibility.

---
# 1.4.0
**[Dropped support]**
- Python 3.7 and 3.8
- Django 2.2

**[Added support]**
- Python 3.12 & 3.13
- Django 5.0 & 5.1

---
# 1.3.0
**[Dropped support]**
Expand All @@ -28,6 +38,7 @@ updating.
- Added support for Django 4.1 and Django 4.2
- Added HTTP_AUTHORIZATION header when generating encoded key for extra security. (Submitted by Artem)

---
# 1.2.0
**[Dropped support]**

Expand Down
82 changes: 58 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,51 +1,81 @@
build: clean database

.PHONY: help
help:
@echo "Please use 'make <target>' where <target> is one of"
@echo " build cleans the environment and runs the migrations on the database"
@echo " deps to install dependencies for local development"
@echo " clean to clean up environment"
@echo " lint runs linting on all the files using Ruff"
@echo " database Creates the idempotency-key database and runs the migrations"
@echo " tests to run tests"
@echo " coverage to run code coverage"
@echo " bundle Generates a zip file of the pacakge so we can later upload to PyPi"
@echo " release_test Pushes the bundle to test.pypi.org to prove it works and the contents are correct"
@echo " release Pushes the bundle to pypi.org for a proper release"
@echo " bump-major bumps the major version number in respective files so that we can generate a bundle for that version and release it."
@echo " bump-minor bumps the minor version number."
@echo " bump-revision bumps the revision version number."
@echo " install-poetry installs the correct version poetry"
@echo " uninstall-poetry uninstalls poetry if things go wrong."
@echo " tree Produces and ASCII directory tree to provide AI bots with context of the project."
@echo " showoutdatedpackages Ask poetry for a list of top-level packages that can be updated."

.PHONY: build
build: clean deps database

.PHONY: deps
deps:
poetry env remove 3.9
poetry env use 3.9
poetry install

.PHONY: lint
lint:
poetry run pre-commit run --all-files

.PHONY: clean
clean:
rm -rf .tox/ .pytest_cache/ dist/ htmlcov/ .coverage coverage.xml db.sqlite3
find . -type f -name "*.pyc" -delete

.PHONY: database
database:
psql -lqt | cut -d \| -f 1 | grep -wq idempotency-key || createdb idempotency-key
poetry run ./manage.py migrate

static_analysis: pep8 xenon black

black:
@echo "Running black over codebase"
black .

pep8:
@echo "Running flake8 over codebase"
flake8 --ignore=E501,W391,F999 --exclude=migrations idempotency_key/

xenon:
@echo "Running xenon over codebase"
poetry run xenon --max-absolute C --max-modules B --max-average A --exclude test_*.py idempotency_key/

test: static_analysis coverage
.PHONY: tests
tests: coverage
# ensure that `docker compose up` is running to start the redis server before
# running these tests.
poetry run tox $(pytest_args)

coverage:
.PHONY: coverage
coverage: lint
poetry run py.test --cov=idempotency_key tests/ --cov-report html
@echo Access the report here:
@echo file://${PWD}/htmlcov/index.html

bundle: static_analysis coverage
.PHONY: bundle
bundle: coverage
rm -r ./dist/ || true
poetry build

.PHONY: release-test
release-test:
poetry run twine upload --repository-url https://test.pypi.org/legacy/ dist/django_idempotency_key-1.3.0.tar.gz
poetry run twine upload --repository-url https://test.pypi.org/legacy/dist/django_idempotency_key-1.4.0.tar.gz

release: static_analysis coverage
.PHONY: release
release: coverage
poetry run twine upload dist/*

.PHONY: bump-major
bump-major:
poetry run bump2version major

.PHONY: bump-minor
bump-minor:
poetry run bump2version minor

.PHONY: bump-patch
bump-patch:
poetry run bump2version patch

Expand All @@ -57,6 +87,10 @@ install-poetry:
uninstall-poetry:
curl -sSL https://install.python-poetry.org | python3 - --uninstall

.PHONY: bump-major bump-minor bump-patch bundle clean coverage database pep8 black
.PHONY: release release-test static_analysis test virtualenv xenon
.PHONY: install-poetry uninstall-poetry
.PHONY: tree
tree:
tree -I __pycache__ -I *.pyc 2>/dev/null

.PHONY: showoutdatedpackages
showoutdatedpackages:
poetry show --outdated -T
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@ nothing new is created.

Django idempotency key requires the following:

Python (3.7 to 3.11)
Python (3.9 to 3.13)

Django (2.2, 3.2, 4.0, 4.1, 4.2)
Django (3.2, 4.0, 4.1, 4.2, 5.0, 5.1)

The following is a list of Django versions and the respective
DjangoRestFramework and python versions that it supports.

Python | Django | DRF
--------|--------|--------
\>=3.7 | 2.2 | \>=3.8
\>=3.7 | 3.2 | \>=3.11
\>=3.8 | 4.0 | \>=3.13
\>=3.8 | 4.1 | \>=3.14
\>=3.8 | 4.2 | \>=3.14
Python | Django | DRF
----------------|--------|--------
\>=3.9, <3.13 | 3.2 | \>=3.11
\>=3.9 | 4.0 | \>=3.13
\>=3.9 | 4.1 | \>=3.14
\>=3.9 | 4.2 | \>=3.14
\>=3.10 | 5.0 | \>=3.15
\>=3.10 | 5.1 | \>=3.15

## Installation

Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
redis:
image: redis:7-alpine # Use the desired Redis version
container_name: redis_local
ports:
- "6379:6379" # Maps host port 6379 to container port 6379
command: ["redis-server", "--appendonly", "yes"] # Enables persistence
volumes:
- redis_data:/data # Persist data

volumes:
redis_data:
driver: local
Empty file modified idempotency_key/decorators.py
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion idempotency_key/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from idempotency_key.exceptions import MissingIdempotencyKeyError


class IdempotencyKeyEncoder(object):
class IdempotencyKeyEncoder:
@abc.abstractmethod
def encode_key(self, request, key):
raise NotImplementedError
Expand Down
Loading
Loading