Skip to content

Commit f1b51a9

Browse files
authored
chore: Adds pre-commit config and updates supported python/django versions (django-cms#208)
1 parent d49b260 commit f1b51a9

20 files changed

+105
-84
lines changed

.github/workflows/publish-to-live-pypi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish Python 🐍 distributions 📦 to pypi
1+
name: Publish 🐍 📦 to pypi
22

33
on:
44
release:
@@ -33,7 +33,7 @@ jobs:
3333
3434
- name: Publish 📦 to PyPI
3535
if: startsWith(github.ref, 'refs/tags')
36-
uses: pypa/gh-action-pypi-publish@master
36+
uses: pypa/gh-action-pypi-publish@release/v1
3737
with:
3838
user: __token__
3939
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/publish-to-test-pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
.
3333
3434
- name: Publish 📦 to Test PyPI
35-
uses: pypa/gh-action-pypi-publish@master
35+
uses: pypa/gh-action-pypi-publish@release/v1
3636
with:
3737
user: __token__
3838
password: ${{ secrets.TEST_PYPI_API_TOKEN }}

.github/workflows/test.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
python-version: [ 3.8, 3.9, ] # latest release minus two
11+
python-version: [ 3.8, 3.9, "3.10"] # latest release minus two
1212
requirements-file: [
13-
dj22_cms37.txt,
14-
dj22_cms38.txt,
15-
dj30_cms37.txt,
16-
dj30_cms38.txt,
17-
dj31_cms38.txt,
13+
dj32_cms310.txt,
14+
dj32_cms311.txt,
1815
dj40_cms311.txt,
1916
]
2017
os: [

.pre-commit-config.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
ci:
2+
autofix_commit_msg: |
3+
ci: auto fixes from pre-commit hooks
4+
5+
for more information, see https://pre-commit.ci
6+
autofix_prs: false
7+
autoupdate_commit_msg: 'ci: pre-commit autoupdate'
8+
autoupdate_schedule: monthly
9+
10+
repos:
11+
- repo: https://github.com/asottile/pyupgrade
12+
rev: v2.37.3
13+
hooks:
14+
- id: pyupgrade
15+
args: ["--py36-plus"]
16+
17+
- repo: https://github.com/adamchainz/django-upgrade
18+
rev: '1.7.0'
19+
hooks:
20+
- id: django-upgrade
21+
args: [--target-version, "2.2"]
22+
23+
- repo: https://github.com/PyCQA/flake8
24+
rev: 5.0.2
25+
hooks:
26+
- id: flake8
27+
28+
- repo: https://github.com/pre-commit/pre-commit-hooks
29+
rev: v4.3.0
30+
hooks:
31+
- id: check-merge-conflict
32+
- id: mixed-line-ending
33+
34+
- repo: https://github.com/pycqa/isort
35+
rev: 5.10.1
36+
hooks:
37+
- id: isort

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Changelog
55
Unreleased
66
==========
77

8+
* Added support for python 3.9 and 3.10
9+
* Dropped support for django < 3.2
10+
* Dropped support for python < 3.8
811
* fix: Remove deprecated test suite assertEquals
912

1013
3.1.0 (2022-08-19)

aldryn_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Form(forms.BaseForm):
1818
"""
1919

2020
def clean(self):
21-
data = super(Form, self).clean()
21+
data = super().clean()
2222

2323
# prettify
2424
data['templates'] = ', '.join(split_and_strip(data['templates']))

djangocms_link/cms_plugins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def get_render_queryset(cls):
4545
return queryset.select_related('internal_link')
4646

4747
def get_render_template(self, context, instance, placeholder):
48-
return 'djangocms_link/{}/link.html'.format(instance.template)
48+
return f'djangocms_link/{instance.template}/link.html'
4949

5050
def render(self, context, instance, placeholder):
5151
context['link'] = instance.get_link()

djangocms_link/fields.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ def is_select2_enabled():
88

99

1010
if is_select2_enabled():
11-
from djangocms_link.fields_select2 import \
12-
Select2PageSearchField as PageSearchField # noqa
11+
from djangocms_link.fields_select2 import Select2PageSearchField as PageSearchField # noqa
1312
else:
1413
from cms.forms.fields import PageSelectFormField as PageSearchField # noqa

djangocms_link/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def __str__(self):
141141

142142
def get_short_description(self):
143143
if self.name and self.get_link():
144-
return '{} ({})'.format(self.name, self.get_link())
144+
return f'{self.name} ({self.get_link()})'
145145
return self.name or self.get_link() or gettext('<link is missing>')
146146

147147
def get_link(self):
@@ -179,7 +179,7 @@ def get_link(self):
179179

180180
if ref_page_site_id != cms_page_site_id:
181181
ref_site = Site.objects._get_site_by_id(ref_page_site_id).domain
182-
link = '//{}{}'.format(ref_site, link)
182+
link = f'//{ref_site}{link}'
183183

184184
elif self.file_link:
185185
link = self.file_link.url
@@ -191,13 +191,13 @@ def get_link(self):
191191
link = 'tel:{}'.format(self.phone.replace(' ', ''))
192192

193193
elif self.mailto:
194-
link = 'mailto:{}'.format(self.mailto)
194+
link = f'mailto:{self.mailto}'
195195

196196
else:
197197
link = ''
198198

199199
if (not self.phone and not self.mailto) and self.anchor:
200-
link += '#{}'.format(self.anchor)
200+
link += f'#{self.anchor}'
201201

202202
return link
203203

setup.cfg

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[flake8]
2+
max-line-length = 119
3+
exclude =
4+
*.egg-info,
5+
.eggs,
6+
.env,
7+
.git,
8+
.settings,
9+
.tox,
10+
.venv,
11+
build,
12+
data,
13+
dist,
14+
docs,
15+
*migrations*,
16+
requirements,
17+
tmp
18+
19+
[isort]
20+
line_length = 119
21+
skip = manage.py, *migrations*, .tox, .eggs, .env, .venv, data
22+
include_trailing_comma = true
23+
multi_line_output = 5
24+
lines_after_imports = 2
25+
default_section = THIRDPARTY
26+
sections = FUTURE, STDLIB, DJANGO, CMS, THIRDPARTY, FIRSTPARTY, LOCALFOLDER
27+
known_first_party = djangocms_link
28+
known_cms = cms, menus
29+
known_django = django

setup.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,16 @@
2020
'Operating System :: OS Independent',
2121
'Programming Language :: Python',
2222
'Programming Language :: Python :: 3',
23-
'Programming Language :: Python :: 3.5',
24-
'Programming Language :: Python :: 3.6',
25-
'Programming Language :: Python :: 3.7',
2623
'Programming Language :: Python :: 3.8',
24+
'Programming Language :: Python :: 3.9',
25+
'Programming Language :: Python :: 3.10',
2726
'Framework :: Django',
28-
'Framework :: Django :: 2.2',
29-
'Framework :: Django :: 3.0',
30-
'Framework :: Django :: 3.1',
27+
'Framework :: Django :: 3.2',
28+
'Framework :: Django :: 4.0',
3129
'Framework :: Django CMS',
32-
'Framework :: Django CMS :: 3.7',
33-
'Framework :: Django CMS :: 3.8',
30+
'Framework :: Django CMS :: 3.9',
31+
'Framework :: Django CMS :: 3.10',
32+
'Framework :: Django CMS :: 3.11',
3433
'Topic :: Internet :: WWW/HTTP',
3534
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
3635
'Topic :: Software Development',

tests/requirements/dj22_cms37.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/requirements/dj22_cms38.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/requirements/dj30_cms37.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/requirements/dj30_cms38.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/requirements/dj31_cms38.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/requirements/dj32_cms310.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-r base.txt
2+
3+
Django>=3.2,<4.0
4+
django-cms>=3.10,<3.11

tests/requirements/dj32_cms311.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-r base.txt
2+
3+
Django>=3.2,<4.0
4+
django-cms>=3.11,<4.0

tests/test_migrations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ def test_for_missing_migrations(self):
2727
status_code = '0'
2828

2929
if status_code == '1':
30-
self.fail('There are missing migrations:\n {}'.format(output.getvalue()))
30+
self.fail(f'There are missing migrations:\n {output.getvalue()}')

tox.ini

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,18 @@
22
envlist =
33
flake8
44
isort
5-
py{35,36,37,38}-dj{22}-cms{37,38}
6-
py{36,37,38}-dj{30}-cms{37,38}
7-
py{36,37,38}-dj{31}-cms{38}
5+
py{38,39,310}-dj{32}-cms{310,311}
6+
py{38,39,310}-dj{40}-cms{311}
87

98
skip_missing_interpreters=True
109

11-
[flake8]
12-
max-line-length = 119
13-
exclude =
14-
*.egg-info,
15-
.eggs,
16-
.git,
17-
.settings,
18-
.tox,
19-
build,
20-
data,
21-
dist,
22-
docs,
23-
*migrations*,
24-
requirements,
25-
tmp
26-
27-
[isort]
28-
line_length = 79
29-
skip = manage.py, *migrations*, .tox, .eggs, data
30-
include_trailing_comma = true
31-
multi_line_output = 5
32-
not_skip = __init__.py
33-
lines_after_imports = 2
34-
default_section = THIRDPARTY
35-
sections = FUTURE, STDLIB, DJANGO, CMS, THIRDPARTY, FIRSTPARTY, LIB, LOCALFOLDER
36-
known_first_party = djangocms_link
37-
known_cms = cms, menus
38-
known_django = django
39-
4010
[testenv]
4111
deps =
4212
-r{toxinidir}/tests/requirements/base.txt
43-
dj22: Django>=2.2,<3.0
44-
dj30: Django>=3.0,<3.1
45-
dj31: Django>=3.1,<3.2
46-
cms37: django-cms>=3.7,<3.8
47-
cms38: django-cms>=3.8,<3.9
13+
dj32: Django>=3.2,<4.0
14+
dj40: Django>=4.0,<4.1
15+
cms310: django-cms>=3.10,<3.11
16+
cms311: django-cms>=3.11,<3.12
4817
commands =
4918
{envpython} --version
5019
{env:COMMAND:coverage} erase
@@ -57,5 +26,5 @@ commands = flake8
5726

5827
[testenv:isort]
5928
deps = isort
60-
commands = isort -c -rc -df djangocms_link
29+
commands = isort --check --diff djangocms_link
6130
skip_install = true

0 commit comments

Comments
 (0)