From 7b571dd60fdf2aede71338b1c703b9a2f58e5fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20M=C3=A9ndez?= Date: Wed, 7 Feb 2024 04:31:30 -0600 Subject: [PATCH 1/9] Properly specifying compatible python & django versions in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 13ca93c..f8f0210 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ django-generic-links ![Python Compatibility](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue.svg) [![PyPi Version](https://img.shields.io/pypi/v/django-generic-links.svg)](https://pypi.python.org/pypi/django-generic-links) ![CI badge](https://github.com/matagus/django-generic-links/actions/workflows/ci.yml/badge.svg) [![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) -Simple app to attach links to any Django model. Compatible with Django 4+ and Python 3.9+ +Simple app to attach links to any Django model. Compatible with Django 4.x to 5.0 and Python 3.9 to 3.12. ![](docs/images/admin.png) From 9a634e42c5096f4a53a80db6d1899b403dc0c582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20M=C3=A9ndez?= Date: Wed, 7 Feb 2024 04:31:51 -0600 Subject: [PATCH 2/9] Added some more classifiers to pyproject.toml --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index dd04518..68b5f50 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,6 +29,8 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries", ] dependencies = [ From 8b1980be3c0babb93fc6ada04accb42c60a4a745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20M=C3=A9ndez?= Date: Wed, 7 Feb 2024 04:35:05 -0600 Subject: [PATCH 3/9] Removing shebangs which don't make sense --- tests/test_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index 0aa2b6c..62adf7d 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,10 +1,10 @@ -#!/usr/bin/env python """ test_generic_links ------------ Tests for `generic_links` models module. """ + from __future__ import annotations from django.test import TestCase From 3a10a71653598a16aed6d129798faed73210810a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20M=C3=A9ndez?= Date: Wed, 7 Feb 2024 04:38:30 -0600 Subject: [PATCH 4/9] Added black badge to README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8f0210..0e53002 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ for more information. Acknowledgements ================ -Develop & built using [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) +Develop & built using [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![code style - black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) Tools used in building this package: From ad091019f4cd3efb8a849a91a12b213b585e052e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20M=C3=A9ndez?= Date: Wed, 7 Feb 2024 20:51:37 -0600 Subject: [PATCH 5/9] Setting max-parallel limit for CI jobs --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index deffd8a..2dc1679 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,7 @@ on: jobs: test: strategy: + max-parallel: 2 fail-fast: true matrix: python-version: ["3.9", "3.10", "3.11", "3.12"] From 7395c39d0469ed3b3e56684a5ca2a57c06b49bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20M=C3=A9ndez?= Date: Wed, 7 Feb 2024 20:52:08 -0600 Subject: [PATCH 6/9] Upgrading pre-commit hooks --- .pre-commit-config.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index adde937..9d1bf2d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ default_language_version: repos: - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: "v0.2.0" + rev: "v0.2.1" hooks: - id: ruff args: [--fix] @@ -14,8 +14,6 @@ repos: hooks: - id: black args: - - "--line-length=120" - - "--target-version=py38" - "--target-version=py39" - "--target-version=py310" - "--target-version=py311" From c771907209c328c24615a2d6ae3fe710c9b73c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20M=C3=A9ndez?= Date: Wed, 7 Feb 2024 20:54:10 -0600 Subject: [PATCH 7/9] Several improvements for example_project --- example_project/example_project/settings.py | 1 + example_project/music_app/admin.py | 1 - example_project/music_app/models.py | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example_project/example_project/settings.py b/example_project/example_project/settings.py index 7911be1..eb95994 100644 --- a/example_project/example_project/settings.py +++ b/example_project/example_project/settings.py @@ -39,6 +39,7 @@ "django.contrib.staticfiles", "music_app", "generic_links", + "django_extensions", ] MIDDLEWARE = [ diff --git a/example_project/music_app/admin.py b/example_project/music_app/admin.py index 3184142..854c297 100644 --- a/example_project/music_app/admin.py +++ b/example_project/music_app/admin.py @@ -1,7 +1,6 @@ from django.contrib import admin from generic_links.admin import GenericLinkStackedInline - from music_app.models import Album, Artist diff --git a/example_project/music_app/models.py b/example_project/music_app/models.py index d6344ce..cb0befd 100644 --- a/example_project/music_app/models.py +++ b/example_project/music_app/models.py @@ -9,7 +9,7 @@ class Artist(models.Model): updated_at = models.DateTimeField(auto_now=True) def __str__(self): - return self.name + return f"{self.name}" class Album(models.Model): From 70300b52cf04eccc94bcd6217625554839694792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20M=C3=A9ndez?= Date: Wed, 7 Feb 2024 20:55:43 -0600 Subject: [PATCH 8/9] Formatting fixes recommended by black & ruff --- generic_links/migrations/0001_initial.py | 7 ++++--- generic_links/templatetags/generic_links_tags.py | 4 +--- tests/test_templatetags.py | 3 +-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/generic_links/migrations/0001_initial.py b/generic_links/migrations/0001_initial.py index ec6366d..50dc22e 100644 --- a/generic_links/migrations/0001_initial.py +++ b/generic_links/migrations/0001_initial.py @@ -1,8 +1,7 @@ from __future__ import annotations from django.conf import settings -from django.db import migrations -from django.db import models +from django.db import migrations, models class Migration(migrations.Migration): @@ -36,7 +35,9 @@ class Migration(migrations.Migration): ("is_external", models.BooleanField(default=True, db_index=True)), ( "content_type", - models.ForeignKey(to="contenttypes.ContentType", on_delete=models.CASCADE), + models.ForeignKey( + to="contenttypes.ContentType", on_delete=models.CASCADE + ), ), ( "user", diff --git a/generic_links/templatetags/generic_links_tags.py b/generic_links/templatetags/generic_links_tags.py index 7e71ccf..3c669e1 100644 --- a/generic_links/templatetags/generic_links_tags.py +++ b/generic_links/templatetags/generic_links_tags.py @@ -5,12 +5,10 @@ from __future__ import annotations from django import template -from django.db.models import Model -from django.db.models import QuerySet +from django.db.models import Model, QuerySet from generic_links import utils - register = template.Library() diff --git a/tests/test_templatetags.py b/tests/test_templatetags.py index 03cb81f..77a5fab 100644 --- a/tests/test_templatetags.py +++ b/tests/test_templatetags.py @@ -1,7 +1,6 @@ from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType -from django.template import Context -from django.template import Template +from django.template import Context, Template from django.test import TestCase from generic_links.models import GenericLink From cd77afd36e51d6f1d7f72d7b388c99073e8b0d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20M=C3=A9ndez?= Date: Wed, 7 Feb 2024 20:56:48 -0600 Subject: [PATCH 9/9] pyproject.toml improvements --- pyproject.toml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 68b5f50..d15827d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,8 @@ keywords = [ ] classifiers = [ "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 4.0", "Framework :: Django :: 4.1", @@ -59,9 +61,13 @@ include = [ [tool.hatch.envs.default] dependencies = [ - "Django>=4.0", "ipython", "ipdb", "mypy", "typing-extensions", + "Django>=4.0", "ipython", "ipdb", "mypy", "typing-extensions", "django-extensions", "Werkzeug" ] +[tool.hatch.envs.default.scripts] +runserver = "python example_project/manage.py runserver_plus" +shell = "python example_project/manage.py shell_plus" + # Test environment [[tool.hatch.envs.test.matrix]] django = ["4.0"] @@ -87,3 +93,10 @@ test = "python -m django test --settings tests.settings" test-cov = "coverage run -m django test --settings tests.settings" cov-report = ["coverage combine", "coverage report"] cov = ["test-cov", "cov-report"] +test-cov-report = ["test-cov", "cov-report"] + +[tool.ruff] +line-length = 120 + +[tool.black] +line-length = 120