Skip to content

Commit

Permalink
chore: Adds pre-commit config and updates supported python/django ver…
Browse files Browse the repository at this point in the history
…sions (django-cms#208)
  • Loading branch information
marksweb authored Sep 9, 2022
1 parent d49b260 commit f1b51a9
Show file tree
Hide file tree
Showing 20 changed files with 105 additions and 84 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish-to-live-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Python 🐍 distributions 📦 to pypi
name: Publish 🐍 📦 to pypi

on:
release:
Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Publish 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
.
- name: Publish 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ 3.8, 3.9, ] # latest release minus two
python-version: [ 3.8, 3.9, "3.10"] # latest release minus two
requirements-file: [
dj22_cms37.txt,
dj22_cms38.txt,
dj30_cms37.txt,
dj30_cms38.txt,
dj31_cms38.txt,
dj32_cms310.txt,
dj32_cms311.txt,
dj40_cms311.txt,
]
os: [
Expand Down
37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
ci:
autofix_commit_msg: |
ci: auto fixes from pre-commit hooks
for more information, see https://pre-commit.ci
autofix_prs: false
autoupdate_commit_msg: 'ci: pre-commit autoupdate'
autoupdate_schedule: monthly

repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.37.3
hooks:
- id: pyupgrade
args: ["--py36-plus"]

- repo: https://github.com/adamchainz/django-upgrade
rev: '1.7.0'
hooks:
- id: django-upgrade
args: [--target-version, "2.2"]

- repo: https://github.com/PyCQA/flake8
rev: 5.0.2
hooks:
- id: flake8

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-merge-conflict
- id: mixed-line-ending

- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Changelog
Unreleased
==========

* Added support for python 3.9 and 3.10
* Dropped support for django < 3.2
* Dropped support for python < 3.8
* fix: Remove deprecated test suite assertEquals

3.1.0 (2022-08-19)
Expand Down
2 changes: 1 addition & 1 deletion aldryn_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Form(forms.BaseForm):
"""

def clean(self):
data = super(Form, self).clean()
data = super().clean()

# prettify
data['templates'] = ', '.join(split_and_strip(data['templates']))
Expand Down
2 changes: 1 addition & 1 deletion djangocms_link/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_render_queryset(cls):
return queryset.select_related('internal_link')

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

def render(self, context, instance, placeholder):
context['link'] = instance.get_link()
Expand Down
3 changes: 1 addition & 2 deletions djangocms_link/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def is_select2_enabled():


if is_select2_enabled():
from djangocms_link.fields_select2 import \
Select2PageSearchField as PageSearchField # noqa
from djangocms_link.fields_select2 import Select2PageSearchField as PageSearchField # noqa
else:
from cms.forms.fields import PageSelectFormField as PageSearchField # noqa
8 changes: 4 additions & 4 deletions djangocms_link/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __str__(self):

def get_short_description(self):
if self.name and self.get_link():
return '{} ({})'.format(self.name, self.get_link())
return f'{self.name} ({self.get_link()})'
return self.name or self.get_link() or gettext('<link is missing>')

def get_link(self):
Expand Down Expand Up @@ -179,7 +179,7 @@ def get_link(self):

if ref_page_site_id != cms_page_site_id:
ref_site = Site.objects._get_site_by_id(ref_page_site_id).domain
link = '//{}{}'.format(ref_site, link)
link = f'//{ref_site}{link}'

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

elif self.mailto:
link = 'mailto:{}'.format(self.mailto)
link = f'mailto:{self.mailto}'

else:
link = ''

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

return link

Expand Down
29 changes: 29 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[flake8]
max-line-length = 119
exclude =
*.egg-info,
.eggs,
.env,
.git,
.settings,
.tox,
.venv,
build,
data,
dist,
docs,
*migrations*,
requirements,
tmp

[isort]
line_length = 119
skip = manage.py, *migrations*, .tox, .eggs, .env, .venv, data
include_trailing_comma = true
multi_line_output = 5
lines_after_imports = 2
default_section = THIRDPARTY
sections = FUTURE, STDLIB, DJANGO, CMS, THIRDPARTY, FIRSTPARTY, LOCALFOLDER
known_first_party = djangocms_link
known_cms = cms, menus
known_django = django
15 changes: 7 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@
'Operating System :: OS Independent',
'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',
'Framework :: Django',
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.0',
'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django CMS',
'Framework :: Django CMS :: 3.7',
'Framework :: Django CMS :: 3.8',
'Framework :: Django CMS :: 3.9',
'Framework :: Django CMS :: 3.10',
'Framework :: Django CMS :: 3.11',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development',
Expand Down
4 changes: 0 additions & 4 deletions tests/requirements/dj22_cms37.txt

This file was deleted.

4 changes: 0 additions & 4 deletions tests/requirements/dj22_cms38.txt

This file was deleted.

4 changes: 0 additions & 4 deletions tests/requirements/dj30_cms37.txt

This file was deleted.

4 changes: 0 additions & 4 deletions tests/requirements/dj30_cms38.txt

This file was deleted.

4 changes: 0 additions & 4 deletions tests/requirements/dj31_cms38.txt

This file was deleted.

4 changes: 4 additions & 0 deletions tests/requirements/dj32_cms310.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-r base.txt

Django>=3.2,<4.0
django-cms>=3.10,<3.11
4 changes: 4 additions & 0 deletions tests/requirements/dj32_cms311.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-r base.txt

Django>=3.2,<4.0
django-cms>=3.11,<4.0
2 changes: 1 addition & 1 deletion tests/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ def test_for_missing_migrations(self):
status_code = '0'

if status_code == '1':
self.fail('There are missing migrations:\n {}'.format(output.getvalue()))
self.fail(f'There are missing migrations:\n {output.getvalue()}')
45 changes: 7 additions & 38 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,18 @@
envlist =
flake8
isort
py{35,36,37,38}-dj{22}-cms{37,38}
py{36,37,38}-dj{30}-cms{37,38}
py{36,37,38}-dj{31}-cms{38}
py{38,39,310}-dj{32}-cms{310,311}
py{38,39,310}-dj{40}-cms{311}

skip_missing_interpreters=True

[flake8]
max-line-length = 119
exclude =
*.egg-info,
.eggs,
.git,
.settings,
.tox,
build,
data,
dist,
docs,
*migrations*,
requirements,
tmp

[isort]
line_length = 79
skip = manage.py, *migrations*, .tox, .eggs, data
include_trailing_comma = true
multi_line_output = 5
not_skip = __init__.py
lines_after_imports = 2
default_section = THIRDPARTY
sections = FUTURE, STDLIB, DJANGO, CMS, THIRDPARTY, FIRSTPARTY, LIB, LOCALFOLDER
known_first_party = djangocms_link
known_cms = cms, menus
known_django = django

[testenv]
deps =
-r{toxinidir}/tests/requirements/base.txt
dj22: Django>=2.2,<3.0
dj30: Django>=3.0,<3.1
dj31: Django>=3.1,<3.2
cms37: django-cms>=3.7,<3.8
cms38: django-cms>=3.8,<3.9
dj32: Django>=3.2,<4.0
dj40: Django>=4.0,<4.1
cms310: django-cms>=3.10,<3.11
cms311: django-cms>=3.11,<3.12
commands =
{envpython} --version
{env:COMMAND:coverage} erase
Expand All @@ -57,5 +26,5 @@ commands = flake8

[testenv:isort]
deps = isort
commands = isort -c -rc -df djangocms_link
commands = isort --check --diff djangocms_link
skip_install = true

0 comments on commit f1b51a9

Please sign in to comment.