Skip to content

Commit

Permalink
Merge pull request #29 from matagus/misc-fixes-5
Browse files Browse the repository at this point in the history
Several improvements to pyproject.toml, pre-commit config, README and example project
  • Loading branch information
matagus authored Feb 8, 2024
2 parents e60b4b7 + cd77afd commit 809ee44
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 17 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
4 changes: 1 addition & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -14,8 +14,6 @@ repos:
hooks:
- id: black
args:
- "--line-length=120"
- "--target-version=py38"
- "--target-version=py39"
- "--target-version=py310"
- "--target-version=py311"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:

Expand Down
1 change: 1 addition & 0 deletions example_project/example_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"django.contrib.staticfiles",
"music_app",
"generic_links",
"django_extensions",
]

MIDDLEWARE = [
Expand Down
1 change: 0 additions & 1 deletion example_project/music_app/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.contrib import admin

from generic_links.admin import GenericLinkStackedInline

from music_app.models import Album, Artist


Expand Down
2 changes: 1 addition & 1 deletion example_project/music_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 4 additions & 3 deletions generic_links/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 1 addition & 3 deletions generic_links/templatetags/generic_links_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
17 changes: 16 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -29,6 +31,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 = [
Expand Down Expand Up @@ -57,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"]
Expand All @@ -85,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
2 changes: 1 addition & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions tests/test_templatetags.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 809ee44

Please sign in to comment.