From 0121055e07b3226f277cbe5be04755aa174dd1a4 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 7 Feb 2024 19:00:34 -0600 Subject: [PATCH 1/7] ruff . --select COM --fix --- docs/conf.py | 2 +- test_app/models.py | 2 +- tests/settings.py | 2 +- tests/test_filters.py | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index fbf15c4..84dd4d2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -94,7 +94,7 @@ "sidebar/navigation.html", "sidebar/projects.html", "sidebar/scroll-end.html", - ] + ], } # linkify_issues diff --git a/test_app/models.py b/test_app/models.py index f1c4ef0..6373a06 100644 --- a/test_app/models.py +++ b/test_app/models.py @@ -10,5 +10,5 @@ class MyModel(models.Model): title = models.CharField(max_length=255) django_extensions_slug = django_extensions.db.fields.AutoSlugField( - populate_from="title", slugify_function=slugify + populate_from="title", slugify_function=slugify, ) diff --git a/tests/settings.py b/tests/settings.py index d52e77e..76fc07f 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -5,7 +5,7 @@ SECRET_KEY: str = os.getenv("SECRET_KEY", "dummy") DATABASES: t.Dict[str, t.Any] = { - "default": {"NAME": ":memory:", "ENGINE": "django.db.backends.sqlite3"} + "default": {"NAME": ":memory:", "ENGINE": "django.db.backends.sqlite3"}, } INSTALLED_APPS: t.List[str] = ["test_app"] diff --git a/tests/test_filters.py b/tests/test_filters.py index 3efb76f..b2bc407 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -12,9 +12,9 @@ def test_slugify_via_builtin_override(settings: t.Any) -> None: "BACKEND": "django.template.backends.django.DjangoTemplates", "APP_DIRS": True, "OPTIONS": { - "builtins": ["django_slugify_processor.templatetags.slugify_processor"] + "builtins": ["django_slugify_processor.templatetags.slugify_processor"], }, - } + }, ] template = Template("{{'c++'|slugify}}") @@ -26,7 +26,7 @@ def test_slugify_via_load_templatetags(settings: t.Any) -> None: settings.SLUGIFY_PROCESSORS = ["test_app.coding.slugify_programming"] settings.INSTALLED_APPS = ["django_slugify_processor"] settings.TEMPLATES = [ - {"BACKEND": "django.template.backends.django.DjangoTemplates", "APP_DIRS": True} + {"BACKEND": "django.template.backends.django.DjangoTemplates", "APP_DIRS": True}, ] template = Template('{% load slugify_processor %}{{"c++"|slugify}}') From 9727f1e3e72b7da6f0afef13b36eaa56730627dd Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 7 Feb 2024 19:00:44 -0600 Subject: [PATCH 2/7] ruff format (after adding flake8-commas) --- test_app/models.py | 3 ++- tests/test_filters.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test_app/models.py b/test_app/models.py index 6373a06..6fe722a 100644 --- a/test_app/models.py +++ b/test_app/models.py @@ -10,5 +10,6 @@ class MyModel(models.Model): title = models.CharField(max_length=255) django_extensions_slug = django_extensions.db.fields.AutoSlugField( - populate_from="title", slugify_function=slugify, + populate_from="title", + slugify_function=slugify, ) diff --git a/tests/test_filters.py b/tests/test_filters.py index b2bc407..972918d 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -26,7 +26,10 @@ def test_slugify_via_load_templatetags(settings: t.Any) -> None: settings.SLUGIFY_PROCESSORS = ["test_app.coding.slugify_programming"] settings.INSTALLED_APPS = ["django_slugify_processor"] settings.TEMPLATES = [ - {"BACKEND": "django.template.backends.django.DjangoTemplates", "APP_DIRS": True}, + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "APP_DIRS": True, + }, ] template = Template('{% load slugify_processor %}{{"c++"|slugify}}') From 309ae6616e827ffe580607f664e877085b163c26 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 8 Feb 2024 04:43:24 -0600 Subject: [PATCH 3/7] pyproject(ruff): Add flake8-commas, ignore COM812 for `ruff format` See also: - https://docs.astral.sh/ruff/rules/#flake8-commas-com - https://pypi.org/project/flake8-commas/ Ignoring COM812: - https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules - https://docs.astral.sh/ruff/rules/missing-trailing-comma/ --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 387b632..65e57cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -138,6 +138,7 @@ select = [ "UP", # pyupgrade "B", # flake8-bugbear "C4", # flake8-comprehensions + "COM", # flake8-commas "Q", # flake8-quotes "PTH", # flake8-use-pathlib "SIM", # flake8-simplify @@ -146,6 +147,9 @@ select = [ "RUF", # Ruff-specific rules "D", # pydocstyle ] +ignore = [ + "COM812", # missing trailing comma, ruff format conflict +] [tool.ruff.lint.isort] known-first-party = [ From 292d63b626320424f40fe9b79e216be43d0f4eb8 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 8 Feb 2024 04:43:49 -0600 Subject: [PATCH 4/7] pyproject(ruff): flake8-builtins See also: - https://docs.astral.sh/ruff/rules/#flake8-builtins-a - https://pypi.org/project/flake8-builtins/ --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 65e57cb..777d04c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -136,6 +136,7 @@ select = [ "F", # pyflakes "I", # isort "UP", # pyupgrade + "A", # flake8-builtins "B", # flake8-bugbear "C4", # flake8-comprehensions "COM", # flake8-commas From 38b5924d61a6dbdb9324c2cc3fd8031540fbb248 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 8 Feb 2024 04:44:06 -0600 Subject: [PATCH 5/7] fix!: Fix shadowing of python builtins docs/conf.py:54:1: A001 Variable `copyright` is shadowing a Python builtin --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 84dd4d2..4750b6b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -51,7 +51,7 @@ master_doc = "index" project = about["__title__"] -copyright = about["__copyright__"] +project_copyright = about["__copyright__"] version = "%s" % (".".join(about["__version__"].split("."))[:2]) release = "%s" % (about["__version__"]) From 9a21ad93817aac6069a1415434e603e6d1c5dfaf Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 8 Feb 2024 04:46:00 -0600 Subject: [PATCH 6/7] pyproject(ruff): Add flake8-errmsg See also: - https://docs.astral.sh/ruff/rules/#flake8-errmsg-em - https://pypi.org/project/flake8-errmsg/ --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 777d04c..9c123d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -140,6 +140,7 @@ select = [ "B", # flake8-bugbear "C4", # flake8-comprehensions "COM", # flake8-commas + "EM", # flake8-errmsg "Q", # flake8-quotes "PTH", # flake8-use-pathlib "SIM", # flake8-simplify From 8c6ea2f0024d0be3045a2318c2899cd4ceab59e0 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 8 Feb 2024 04:46:32 -0600 Subject: [PATCH 7/7] docs(CHANGES): Note linting improvements --- CHANGES | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGES b/CHANGES index 86612d3..6e11685 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,25 @@ - _Add your latest changes from PRs here_ +### Development + +- Strengthen linting (#385) + + - Add flake8-commas (COM) + + - https://docs.astral.sh/ruff/rules/#flake8-commas-com + - https://pypi.org/project/flake8-commas/ + + - Add flake8-builtins (A) + + - https://docs.astral.sh/ruff/rules/#flake8-builtins-a + - https://pypi.org/project/flake8-builtins/ + + - Add flake8-errmsg (EM) + + - https://docs.astral.sh/ruff/rules/#flake8-errmsg-em + - https://pypi.org/project/flake8-errmsg/ + ## django-slugify-processor 1.6.0 (2023-12-09) _Maintenance only, no bug fixes or features_