Skip to content

Commit 51c0a78

Browse files
committed
updates
1 parent b915a3c commit 51c0a78

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1687
-450
lines changed

.github/workflows/tests.yaml

+11-11
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
fail-fast: false
2828
matrix:
2929
python-version: [ "3.11", "3.12"]
30-
django-version: [ "4.2", "5.1"]
30+
django-version: [ "3.2", "4.2", "5.1"]
3131
db-engine: ["pg", "mysql"]
3232
env:
3333
PY_VER: ${{ matrix.python-version}}
@@ -47,16 +47,16 @@ jobs:
4747
- 5432:5432
4848
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
4949

50-
# mysql:
51-
# image: mysql:5.7
52-
# env:
53-
# MYSQL_DATABASE: test_db
54-
# MYSQL_USER: user
55-
# MYSQL_PASSWORD: password
56-
# MYSQL_ROOT_PASSWORD: rootpassword
57-
# ports:
58-
# - 33306:3306
59-
# options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
50+
mysql:
51+
image: mysql:5.7
52+
env:
53+
MYSQL_DATABASE: test_db
54+
MYSQL_USER: user
55+
MYSQL_PASSWORD: password
56+
MYSQL_ROOT_PASSWORD: rootpassword
57+
ports:
58+
- 33306:3306
59+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
6060

6161
steps:
6262
- uses: actions/checkout@v2

.gitignore

+1-4
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,5 @@ __pycache__
1919
*.mo
2020
*.sqlite
2121
.testmondata
22-
Pipfile.lock
23-
poetry.lock
24-
!pyproject.toml
2522
.venv/
26-
pdm.lock
23+
src/concurrency/version.py

.pre-commit-config.yaml

+34-36
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,35 @@
1-
exclude: '^$'
2-
fail_fast: false
31
repos:
4-
- repo: local
5-
hooks:
6-
- id: isort
7-
args:
8-
- -rc
9-
- src/
10-
- tests/
11-
name: isort
12-
entry: isort
13-
language: system
14-
types: [python]
15-
16-
17-
- repo: https://github.com/pre-commit/pre-commit-hooks
18-
rev: v1.4.0
19-
hooks:
20-
- id: debug-statements
21-
exclude: manage.py
22-
- id: end-of-file-fixer
23-
- id: flake8
24-
exclude: docs/
25-
args:
26-
- src/
27-
- tests/
28-
- id: check-merge-conflict
29-
- id: check-case-conflict
30-
# - id: name-tests-test
31-
# - id: trailing-whitespace
32-
# - id: requirements-txt-fixer
33-
# files: requirements-dev.txt
34-
#- repo: git://github.com/asottile/reorder_python_imports
35-
# rev: v1.0.1
36-
# hooks:
37-
# - id: reorder-python-imports
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: end-of-file-fixer
6+
- id: trailing-whitespace
7+
- repo: https://github.com/python-jsonschema/check-jsonschema
8+
rev: 0.31.0
9+
hooks:
10+
- id: check-github-workflows
11+
args: [ "--verbose" ]
12+
- repo: https://github.com/tox-dev/tox-ini-fmt
13+
rev: "1.5.0"
14+
hooks:
15+
- id: tox-ini-fmt
16+
args: [ "-p", "lint" ]
17+
- repo: https://github.com/tox-dev/pyproject-fmt
18+
rev: "v2.5.0"
19+
hooks:
20+
- id: pyproject-fmt
21+
- repo: https://github.com/astral-sh/ruff-pre-commit
22+
rev: "v0.9.4"
23+
hooks:
24+
- id: ruff-format
25+
- id: ruff
26+
args: [ "--fix", "--unsafe-fixes", "--exit-non-zero-on-fix" ]
27+
- repo: https://github.com/adamchainz/djade-pre-commit
28+
rev: "1.3.2"
29+
hooks:
30+
- id: djade
31+
args: [ --target-version, "5.1" ] # Replace with Django version
32+
- repo: meta
33+
hooks:
34+
- id: check-hooks-apply
35+
- id: check-useless-excludes

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ travis:
3434

3535

3636
clean:
37-
rm -fr ${BUILDDIR} dist *.egg-info .coverage coverage.xml .eggs
37+
rm -fr ${BUILDDIR} dist *.egg-info .coverage coverage.xml .eggs build
3838
find src -name __pycache__ -o -name "*.py?" -o -name "*.orig" -prune | xargs rm -rf
3939
find tests -name __pycache__ -o -name "*.py?" -o -name "*.orig" -prune | xargs rm -rf
4040
find src/concurrency/locale -name django.mo | xargs rm -f

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Django Concurrency
66
[![coverage](https://codecov.io/github/saxix/django-concurrency/coverage.svg?branch=develop)](https://codecov.io/github/saxix/django-concurrency?branch=develop)
77
[![Test](https://github.com/saxix/django-concurrency/actions/workflows/tests.yaml/badge.svg)](https://github.com/saxix/django-concurrency/actions/workflows/tests.yaml)
88
[![Docs](https://readthedocs.org/projects/django-concurrency/badge/?version=stable)](http://django-concurrency.readthedocs.io/en/stable/)
9+
[![Django](https://img.shields.io/pypi/frameworkversions/django/django-concurrency)](https://pypi.org/project/django-concurrency/)
10+
[![Supported Python versions](https://img.shields.io/pypi/pyversions/django-concurrency.svg)](https://pypi.org/project/django-concurrency/)
911

1012

1113
django-concurrency is an [optimistic lock][1] implementation for Django.
@@ -48,8 +50,8 @@ you will get a ``RecordModifiedError`` on ``b.save()``
4850
Similar projects
4951
----------------
5052

51-
Other projects that handle concurrent editing are [django-optimistic-lock][10]
52-
and [django-locking][11] anyway concurrency is "a batteries included" optimistic
53+
Other projects that handle concurrent editing are [django-optimistic-lock][10]
54+
and [django-locking][11] anyway concurrency is "a batteries included" optimistic
5355
lock management system, here some features not available elsewhere:
5456

5557
* can be applied to any model; not only your code (ie. django.contrib.auth.Group)

compose.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
services:
2+
3+
postgres:
4+
image: postgis/postgis:14-3.4-alpine
5+
platform: linux/amd64
6+
ports:
7+
- "5432:5432"
8+
shm_size: '1gb'
9+
environment:
10+
POSTGRES_PASSWORD: password
11+
POSTGRES_USER: postgres
12+
POSTGRES_HOST_AUTH_METHOD: trust
13+
14+
mysql:
15+
image: mysql
16+
stdin_open: true
17+
tty: true
18+
ports:
19+
- "3306:3306"
20+
environment:
21+
MYSQL_ROOT_PASSWORD: root
22+
MYSQL_DATABASE: concurrency
23+
MYSQL_ALLOW_EMPTY_PASSWORD: true

docs/_ext/version.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import re
22

3-
from docutils.parsers.rst import Directive, directives
4-
from sphinx import addnodes, roles
5-
from sphinx.errors import ExtensionError
6-
from sphinx.util.console import bold
3+
74
# RE for option descriptions without a '--' prefix
8-
from sphinx.writers.html import HTMLTranslator
95

10-
simple_option_desc_re = re.compile(
11-
r'([-_a-zA-Z0-9]+)(\s*.*?)(?=,\s+(?:/|-|--)|$)')
6+
simple_option_desc_re = re.compile(r"([-_a-zA-Z0-9]+)(\s*.*?)(?=,\s+(?:/|-|--)|$)")
127

138

149
def setup(app):
@@ -20,19 +15,19 @@ def setup(app):
2015
app.add_crossref_type(
2116
directivename="templatetag",
2217
rolename="ttag",
23-
indextemplate="pair: %s; template tag"
18+
indextemplate="pair: %s; template tag",
2419
)
2520
app.add_crossref_type(
2621
directivename="templatefilter",
2722
rolename="tfilter",
28-
indextemplate="pair: %s; template filter"
23+
indextemplate="pair: %s; template filter",
2924
)
3025
app.add_crossref_type(
3126
directivename="fieldlookup",
3227
rolename="lookup",
3328
indextemplate="pair: %s; field lookup type",
3429
)
35-
app.add_config_value('next_version', '0.0', True)
30+
app.add_config_value("next_version", "0.0", True)
3631
app.add_crossref_type(
3732
directivename="release",
3833
rolename="release",

docs/conf.py

+45-34
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import concurrency
77

8-
src = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'src'))
8+
src = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, "src"))
99
sys.path.insert(0, src)
1010

1111

@@ -27,51 +27,52 @@
2727
# Add any Sphinx extension module names here, as strings. They can be extensions
2828
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
2929
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "_ext")))
30-
extensions = ['sphinx.ext.autodoc',
31-
'sphinx.ext.todo',
32-
'sphinx.ext.graphviz',
33-
'sphinx.ext.intersphinx',
34-
'sphinx.ext.doctest',
35-
'sphinx.ext.extlinks',
36-
'sphinx.ext.autosummary',
37-
'sphinx.ext.coverage',
38-
'sphinx.ext.viewcode',
39-
'sphinx_issues',
40-
'version'
41-
]
30+
extensions = [
31+
"sphinx.ext.autodoc",
32+
"sphinx.ext.todo",
33+
"sphinx.ext.graphviz",
34+
"sphinx.ext.intersphinx",
35+
"sphinx.ext.doctest",
36+
"sphinx.ext.extlinks",
37+
"sphinx.ext.autosummary",
38+
"sphinx.ext.coverage",
39+
"sphinx.ext.viewcode",
40+
"sphinx_issues",
41+
"version",
42+
]
4243

4344
intersphinx_mapping = {
44-
'python': ('https://docs.python.org/2.7/', None),
45-
'django': ('http://django.readthedocs.org/en/latest/', None),
46-
'sphinx': ('http://sphinx.readthedocs.org/en/latest/', None),
45+
"python": ("https://docs.python.org/2.7/", None),
46+
"django": ("http://django.readthedocs.org/en/latest/", None),
47+
"sphinx": ("http://sphinx.readthedocs.org/en/latest/", None),
48+
}
49+
extlinks = {
50+
"issue": ("https://github.com/saxix/django-concurrency/issues/%s", "issue #%s"),
51+
"django_issue": ("https://code.djangoproject.com/ticket/%s", "issue #%s"),
4752
}
48-
extlinks = {'issue': ('https://github.com/saxix/django-concurrency/issues/%s', 'issue #%s'),
49-
'django_issue': ('https://code.djangoproject.com/ticket/%s', 'issue #%s'),
50-
51-
}
5253

53-
github_project_url = 'https://github.com/saxix/django-concurrency'
54+
github_project_url = "https://github.com/saxix/django-concurrency"
5455

5556
todo_include_todos = True
5657

5758
# Add any paths that contain templates here, relative to this directory.
58-
templates_path = ['_templates']
59+
templates_path = ["_templates"]
5960

6061
# The suffix of source filenames.
61-
source_suffix = '.rst'
62+
source_suffix = ".rst"
6263

6364
# The encoding of source files.
6465
# source_encoding = 'utf-8-sig'
6566

6667
# The master toctree document.
67-
master_doc = 'index'
68+
master_doc = "index"
6869

6970
# HTML translator class for the builder
7071
html_translator_class = "version.DjangoHTMLTranslator"
7172

7273
# General information about the project.
73-
project = u'Django Concurrency'
74-
copyright = u'2012-2019, Stefano Apostolico'
74+
project = "Django Concurrency"
75+
copyright = "2012-2019, Stefano Apostolico"
7576

7677
# The version info for the project you're documenting, acts as replacement for
7778
# |version| and |release|, also used in various other places throughout the
@@ -81,7 +82,7 @@
8182
version = concurrency.VERSION
8283
# The full version, including alpha/beta/rc tags.
8384
release = concurrency.VERSION
84-
next_version = '2.6'
85+
next_version = "2.6"
8586

8687
# The language for content autogenerated by Sphinx. Refer to documentation
8788
# for a list of supported languages.
@@ -95,7 +96,7 @@
9596

9697
# List of patterns, relative to source directory, that match files and
9798
# directories to ignore when looking for source files.
98-
exclude_patterns = ['_build']
99+
exclude_patterns = ["_build"]
99100

100101
# The reST default role (used for this markup: `text`) to use for all documents.
101102
# default_role = None
@@ -112,7 +113,7 @@
112113
# show_authors = False
113114

114115
# The name of the Pygments (syntax highlighting) style to use.
115-
pygments_style = 'sphinx'
116+
pygments_style = "sphinx"
116117

117118
# A list of ignored prefixes for module index sorting.
118119
# modindex_common_prefix = []
@@ -195,7 +196,7 @@
195196
# html_file_suffix = None
196197

197198
# Output file base name for HTML help builder.
198-
htmlhelp_basename = 'djangoconcurrencydoc'
199+
htmlhelp_basename = "djangoconcurrencydoc"
199200

200201
# -- Options for LaTeX output --------------------------------------------------
201202

@@ -208,8 +209,13 @@
208209
# Grouping the document tree into LaTeX files. List of tuples
209210
# (source start file, target name, title, author, documentclass [howto/manual]).
210211
latex_documents = [
211-
('index', 'DjangoConcurrency.tex', u'Django Concurrency Documentation',
212-
u'Stefano Apostolico', 'manual'),
212+
(
213+
"index",
214+
"DjangoConcurrency.tex",
215+
"Django Concurrency Documentation",
216+
"Stefano Apostolico",
217+
"manual",
218+
),
213219
]
214220

215221
# The name of an image file (relative to this directory) to place at the top of
@@ -241,6 +247,11 @@
241247
# One entry per manual page. List of tuples
242248
# (source start file, name, description, authors, manual section).
243249
man_pages = [
244-
('index', 'djangoconcurrency', u'Django Concurrency Documentation',
245-
[u'Stefano Apostolico'], 1)
250+
(
251+
"index",
252+
"djangoconcurrency",
253+
"Django Concurrency Documentation",
254+
["Stefano Apostolico"],
255+
1,
256+
)
246257
]

docs/cookbook.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ To avoid this simply disable concurrency, by using a mixin:
101101
.. code-block:: python
102102
103103
class ConcurrencyVersionAdmin(reversion.admin.VersionAdmin):
104-
104+
105105
@disable_concurrency()
106106
def revision_view(self, request, object_id, version_id, extra_context=None):
107107
return super().revision_view(request, object_id, version_id, extra_context=None)

manage.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
import sys
44

55
here = os.path.abspath(os.path.join(os.path.dirname(__file__)))
6-
rel = lambda *args: os.path.join(here, *args)
6+
7+
8+
def rel(*args):
9+
return os.path.join(here, *args)
10+
711

812
sys.path.insert(0, rel(os.pardir))
913

1014

1115
if __name__ == "__main__":
12-
sys.path.insert(0, 'src')
13-
sys.path.insert(0, 'tests/demoapp')
16+
sys.path.insert(0, "src")
17+
sys.path.insert(0, "tests/demoapp")
1418
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demo.settings")
1519

1620
from django.core.management import execute_from_command_line

0 commit comments

Comments
 (0)