Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .coveragerc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
uses: actions/checkout@v3
- name: Start the app
run: docker compose up -d
- name: Run the tests and flake8
- name: Run the tests and ruff
run: docker compose run --rm web tox

5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9
FROM python:3.14

ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /app
Expand All @@ -15,4 +15,5 @@ WORKDIR /app
COPY . /app/

# Install dependencies
RUN pip install .'[dev,test,codestyle]'
RUN pip install tox
RUN pip install .'[dev,test]'
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Contributors:


## Requirements
- Python 3.9 or later
- Python 3.12 - 3.14


## Development
Expand Down Expand Up @@ -123,7 +123,7 @@ $ source env/bin/activate

Install the dev dependencies
```sh
$ pip install .'[dev,test,codestyle]'
$ pip install .'[dev,test]'
```

Replace the `DATABASES` Django setting in `./tests/settings/dev.py` with
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
mariadb:
image: mariadb:10.5
image: mariadb:11.4.13
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=name
Expand Down
17 changes: 7 additions & 10 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Django Name documentation build configuration file, created by
# sphinx-quickstart on Fri May 8 09:55:15 2015.
Expand All @@ -12,10 +11,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import re
import shlex

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -47,9 +44,9 @@
master_doc = 'index'

# General information about the project.
project = u'Django Name'
copyright = u'2017, University of North Texas Libraries'
author = u'University of North Texas Libraries'
project = 'Django Name'
copyright = '2017, University of North Texas Libraries'
author = 'University of North Texas Libraries'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -235,8 +232,8 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'DjangoName.tex', u'Django Name Documentation',
u'University of North Texas Libraries', 'manual'),
(master_doc, 'DjangoName.tex', 'Django Name Documentation',
'University of North Texas Libraries', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -265,7 +262,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'djangoname', u'Django Name Documentation',
(master_doc, 'djangoname', 'Django Name Documentation',
[author], 1)
]

Expand All @@ -279,7 +276,7 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'DjangoName', u'Django Name Documentation',
(master_doc, 'DjangoName', 'Django Name Documentation',
author, 'DjangoName', 'One line description of project.',
'Miscellaneous'),
]
Expand Down
2 changes: 1 addition & 1 deletion name/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__title__ = 'Django Name'
__version__ = '5.0.0'
__version__ = '6.0.0'
2 changes: 1 addition & 1 deletion name/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def get_label(self, obj):
"<name.name> (<name.disambiguation>)"
"""
if obj.disambiguation:
return '{0} ({1})'.format(obj.name, obj.disambiguation)
return f'{obj.name} ({obj.disambiguation})'
return obj.name


Expand Down
6 changes: 3 additions & 3 deletions name/api/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dateutil.relativedelta import relativedelta


class NameStatisticsMonth(object):
class NameStatisticsMonth:
"""A simple datatype to represent Name statistics for a
single month.
"""
Expand All @@ -15,7 +15,7 @@ def __init__(self, **kwargs):
self.month = kwargs.get('month', None)


class NameStatisticsType(object):
class NameStatisticsType:
"""Statistics class for calculating the number
of Name objects in the database using a DateTime field.

Expand Down Expand Up @@ -98,7 +98,7 @@ def process_raw_stats(self):
current += delta


class NameStatistics(object):
class NameStatistics:
"""Container class for all statistics gathered on
Name objects.
"""
Expand Down
2 changes: 1 addition & 1 deletion name/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class JSONResponse(http.HttpResponse):
def __init__(self, data, **kwargs):
content = JSONRenderer().render(data, renderer_context={'indent': 4})
kwargs['content_type'] = 'application/json'
super(JSONResponse, self).__init__(content, **kwargs)
super().__init__(content, **kwargs)


def name_json(request, name_id):
Expand Down
2 changes: 1 addition & 1 deletion name/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def jsonp_wrapper(request, *args, **kwargs):
if 'callback' in request.GET:
callback = request.GET['callback']
resp['Content-Type'] = 'application/javascript; charset=utf-8'
resp.content = "%s(%s)" % (callback, resp.content)
resp.content = f'{callback}({resp.content})'
return resp
else:
return resp
Expand Down
6 changes: 3 additions & 3 deletions name/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ class NameAtomFeedType(Atom1Feed):
GEO_RSS_NS = 'http://www.georss.org/georss'

def root_attributes(self):
attrs = super(NameAtomFeedType, self).root_attributes()
attrs = super().root_attributes()
attrs['xmlns:georss'] = self.GEO_RSS_NS
return attrs

def add_item_elements(self, handler, item):
super(NameAtomFeedType, self).add_item_elements(handler, item)
super().add_item_elements(handler, item)

# Add the georss:point element if the item has a geo_point
# attribute.
Expand All @@ -50,7 +50,7 @@ def item_title(self, obj):
return obj.name

def item_description(self, obj):
return 'Name Type: {0}'.format(obj.get_name_type_label())
return f'Name Type: {obj.get_name_type_label()}'

def item_link(self, obj):
return obj.get_absolute_url()
Expand Down
15 changes: 8 additions & 7 deletions name/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def save(self, *args, **kwargs):
self.normalized_variant = normalizeSimplified(self.variant)
if 'update_fields' in kwargs:
kwargs['update_fields'] = {'normalized_variant'}.union(kwargs['update_fields'])
super(Variant, self).save(*args, **kwargs)
super().save(*args, **kwargs)

def __str__(self):
return self.variant
Expand Down Expand Up @@ -196,7 +196,7 @@ def ticket(self):
return self.id

def __str__(self):
return 'nm{ticket:07d}'.format(ticket=self.ticket)
return f'nm{self.ticket:07d}'


class NameManager(models.Manager):
Expand Down Expand Up @@ -513,16 +513,17 @@ def save(self, *args, **kwargs):
self.__normalize_name()
self.__assign_name_id()
if 'update_fields' in kwargs:
kwargs['update_fields'] = {'normalized_name', 'name_id', 'last_modified'}.union(kwargs['update_fields'])
super(Name, self).save(*args, **kwargs)
kwargs['update_fields'] = ({'normalized_name', 'name_id', 'last_modified'}
.union(kwargs['update_fields']))
super().save(*args, **kwargs)
if self.is_building() and not self.location_set.count():
self.__find_location()

def clean(self, *args, **kwargs):
# Call merged_with_validator here so that we can pass in
# the model instance.
validate_merged_with(self)
super(Name, self).clean(*args, **kwargs)
super().clean(*args, **kwargs)

def __str__(self):
return self.name_id
Expand Down Expand Up @@ -587,14 +588,14 @@ class Meta:
base_manager_name = 'objects'

def geo_point(self):
return '{lat} {lng}'.format(lat=self.latitude, lng=self.longitude)
return f'{self.latitude} {self.longitude}'

def is_current(self):
"""True if the Location has a status of Current."""
return self.CURRENT == self.status

def save(self, *args, **kwargs):
super(Location, self).save(*args, **kwargs)
super().save(*args, **kwargs)
# When this instance's status is CURRENT, get all other locations
# related the belong_to_name, and set the status to FORMER.
if self.is_current():
Expand Down
8 changes: 4 additions & 4 deletions name/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ def label(request, name_value):

except Name.DoesNotExist:
return http.HttpResponseNotFound(
'No matching term found - authoritative or variant - for "{0}"'
.format(name_value))
f'No matching term found - authoritative or variant - for "{name_value}"'
)

except Name.MultipleObjectsReturned:
return http.HttpResponseNotFound(
'There are multiple Name objects with the same name: "{0}".'
.format(normalized_name))
f'There are multiple Name objects with the same name: "{normalized_name}".'
)


def detail(request, name_id):
Expand Down
59 changes: 39 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ build-backend = "setuptools.build_meta"
name = "django-name"
description = "Name Authority App for Django."
readme = "README.md"
version = "5.0.0"
version = "6.0.0"
license = {file = 'LICENSE'}
keywords = ["django", "name", "citation"]
requires-python = ">=3.9,<4.0"
requires-python = ">=3.12,<3.15"
authors = [
{ name = "University of North Texas Libraries", email = "mark.phillips@unt.edu" }
]
Expand All @@ -19,7 +19,9 @@ classifiers = [
"Intended Audience :: End Users/Desktop",
"Natural Language :: English",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application"
]
dependencies = [
Expand All @@ -31,32 +33,50 @@ dependencies = [

[project.urls]
Homepage = "https://github.com/unt-libraries/django-name"
Repository = "https://github.com/unt-libraries/django-name"
Repository = "https://github.com/unt-libraries/django-name.git"


[project.optional-dependencies]
codestyle = ["flake8"]
dev = [
"Django==4.2.27",
"django-debug-toolbar==3.8.1",
"mysqlclient==2.0.1",
"Django~=6.1.0",
"django-debug-toolbar~=7.1.0",
"mysqlclient~=2.3.0",
]
test = [
"tox>=3.3.0",
"markdown2>=2.4.0",
"pytest>=7.1.0",
"pytest-django>=4.6.2",
"pytest-cov>=7.0.0",
"psycopg2-binary>=2.9.9",
"tomli>=2.0.1",
"ruff~=0.15.9",
Comment thread
somexpert marked this conversation as resolved.
]

[tool.ruff]
line-length = 99
target-version = "py314"
extend-exclude = ["migrations"]

[tool.ruff.format]
quote-style = "single"

[tool.ruff.lint]
select = ["E", "F", "W"]

[tool.coverage.run]
source = ["name"]
omit = ["*/migrations/*"]
branch = true

[tool.coverage.report]
show_missing = true

[tool.tox]
legacy_tox_ini ='''
[tox]
envlist =
py39-django42-{postgres,mariadb},
py39-flake8,
py314-django61-{postgres,mariadb}
py314-ruff
docs

[testenv]
Expand All @@ -65,22 +85,21 @@ legacy_tox_ini ='''
extras =
test
dev
codestyle
commands =
mariadb: ./runtests.py {posargs} --nolint --ds=tests.settings.test_mariadb
postgres: ./runtests.py {posargs} --nolint --ds=tests.settings.test_postgres
mariadb: ./runtests.py {posargs} --ds=tests.settings.test_mariadb
postgres: ./runtests.py {posargs} --ds=tests.settings.test_postgres

[testenv:py39-django42-mariadb]
commands =
./runtests.py {posargs} --nolint --ds=tests.settings.test_mariadb --cov=name
[testenv:py314-django61-mariadb]
commands =
./runtests.py {posargs} --ds=tests.settings.test_mariadb --cov=name
allowlist_externals = ./runtests.py

[testenv:py39-flake8]
[testenv:py314-ruff]
commands =
./runtests.py --lintonly
allowlist_externals = ./runtests.py
ruff check .

[testenv:docs]
skip_install = true
deps = Sphinx>=4.0
changedir = docs
commands = {envbindir}/sphinx-build -W -b html . {envtmpdir}/html
Expand Down
Loading
Loading