Skip to content

Commit

Permalink
Modernise codebase (#14)
Browse files Browse the repository at this point in the history
- Updates linting configuration.
- Updates CI workflow to cancel in progress CI runs when you push a new commit.
- Swaps from feature checking to version checking for `JSONField`.
  • Loading branch information
knyghty authored Feb 20, 2022
1 parent 1305eb8 commit 933a69a
Show file tree
Hide file tree
Showing 17 changed files with 19 additions and 40 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ on:
types:
- published

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
black:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v2
- uses: actions/checkout@v2
- run: python -m pip install black
- run: black --check snakeoil tests
- uses: psf/black@stable

flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v2
- uses: actions/checkout@v2
- run: python -m pip install flake8 flake8-bugbear
- run: python -m pip install flake8
- run: flake8

isort:
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Development requirements.
black
coverage
django~=3.2
django~=4.0
flake8
flake8-bugbear
isort
pillow
rstcheck
Expand Down
1 change: 0 additions & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import django
from django.test.runner import DiscoverRunner


if __name__ == "__main__":
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.settings"
django.setup()
Expand Down
18 changes: 6 additions & 12 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,11 @@ omit =
setup.py

[flake8]
ignore = B008, E501, W503
max-line-length = 80
select = B, B950, C, D, E, F, W
max-line-length = 88
extend-ignore = E203

[isort]
force_grid_wrap = 0
include_trailing_comma = true
line_length = 88
lines_after_imports = 2
multi_line_output = 3
sections = FUTURE, STDLIB, THIRDPARTY, FIRSTPARTY, LOCALFOLDER
use_parentheses = True
profile = black

[metadata]
author = Tom Carrick
Expand All @@ -29,9 +22,10 @@ classifiers =
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python :: 3 :: Only
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
Topic :: Internet :: WWW/HTTP :: Site Management
description = Simple SEO & meta tag management for Django
keywords =
Expand All @@ -41,7 +35,7 @@ keywords =
long_description = file: README.rst
name = django-snakeoil
url = https://github.com/knyghty/django-snakeoil
version = 1.1.1
version = 1.1.2

[options]
include_package_data = true
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
from setuptools import setup


setup()
1 change: 0 additions & 1 deletion snakeoil/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

from .models import SEOPath


admin.site.register(SEOPath)
1 change: 0 additions & 1 deletion snakeoil/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.db import migrations, models


try:
from django.db.models import JSONField

Expand Down
1 change: 0 additions & 1 deletion snakeoil/migrations/0002_auto_20200727_0951.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.db import migrations


try:
from django.db.models import JSONField

Expand Down
14 changes: 6 additions & 8 deletions snakeoil/models.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import django
from django.db import models
from django.utils.translation import gettext_lazy as _


try:
from django.db.models import JSONField

postgres_only = False
except ImportError:
from django.contrib.postgres.fields import JSONField

if django.VERSION <= (3, 0):
postgres_only = True
from django.contrib.postgres.fields import JSONField
else:
postgres_only = False
from django.db.models import JSONField


class SEOModel(models.Model):
Expand Down
1 change: 0 additions & 1 deletion snakeoil/templatetags/snakeoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from ..utils import get_meta_tags


register = template.Library()


Expand Down
1 change: 0 additions & 1 deletion snakeoil/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from .models import SEOPath


logger = logging.getLogger(__name__)
register = template.Library()

Expand Down
1 change: 0 additions & 1 deletion tests/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from django.conf import settings
from django.db import migrations, models


try:
from django.db.models import JSONField
except ImportError:
Expand Down
1 change: 0 additions & 1 deletion tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from snakeoil.models import SEOModel


User = get_user_model()


Expand Down
1 change: 0 additions & 1 deletion tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
from pathlib import Path


TESTS_DIR = Path(__file__).resolve(strict=True).parents[0]

db = os.getenv("DB")
Expand Down
1 change: 0 additions & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from .models import Article


User = get_user_model()


Expand Down
1 change: 0 additions & 1 deletion tests/test_template_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from .models import Article


User = get_user_model()


Expand Down
1 change: 0 additions & 1 deletion tests/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from . import views


urlpatterns = [
path(
"articles/<slug:slug>/",
Expand Down

0 comments on commit 933a69a

Please sign in to comment.