From b0b8c8093a05a45ae15c410e4a577ca0de87a5c9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Aug 2026 21:43:12 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.15.16 → v0.16.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.15.16...v0.16.1) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 94e0cb1..e90b13e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.15.16 + rev: v0.16.1 hooks: # Run the linter. - id: ruff From 1a75927a28118b6c9292d19de4655d1866bcb091 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Aug 2026 21:43:19 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/django_ltree/apps.py | 2 +- src/django_ltree/fields.py | 10 ++++------ src/django_ltree/functions.py | 5 ++--- src/django_ltree/managers.py | 4 +++- src/django_ltree/models.py | 3 ++- src/django_ltree/paths.py | 2 +- src/django_ltree/querysets.py | 4 ++-- tests/conftest.py | 1 + tests/taxonomy/migrations/0001_initial.py | 3 +-- tests/test_label.py | 2 +- tests/test_model.py | 2 -- tests/test_path_field.py | 5 ++--- tests/test_register.py | 2 +- 13 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/django_ltree/apps.py b/src/django_ltree/apps.py index 81b2278..fbd0922 100644 --- a/src/django_ltree/apps.py +++ b/src/django_ltree/apps.py @@ -7,5 +7,5 @@ class DjangoLtreeConfig(AppConfig): def ready(self): from . import checks as checks - from . import lookups as lookups from . import functions as functions + from . import lookups as lookups diff --git a/src/django_ltree/fields.py b/src/django_ltree/fields.py index efbc16e..ace3dd8 100644 --- a/src/django_ltree/fields.py +++ b/src/django_ltree/fields.py @@ -1,11 +1,11 @@ from collections import UserList +from collections.abc import Iterable + from django import forms from django.core.validators import RegexValidator from django.db.models.fields import TextField from django.forms.widgets import TextInput -from collections.abc import Iterable - path_label_validator = RegexValidator( r"^(?P[a-zA-Z0-9_-]+)(?:\.[a-zA-Z0-9_-]+)*$", "A label is a sequence of alphanumeric characters and underscores separated by dots.", @@ -23,7 +23,7 @@ def __init__(self, value): elif isinstance(value, Iterable): value = [str(v) for v in value] else: - raise ValueError("Invalid value: {!r} for path".format(value)) + raise ValueError(f"Invalid value: {value!r} for path") super().__init__(initlist=value) @@ -89,9 +89,7 @@ def get_prep_value(self, value): return str(PathValue(value)) def to_python(self, value): - if value is None: - return value - elif isinstance(value, PathValue): + if value is None or isinstance(value, PathValue): return value return PathValue(value) diff --git a/src/django_ltree/functions.py b/src/django_ltree/functions.py index f449085..a959ca7 100644 --- a/src/django_ltree/functions.py +++ b/src/django_ltree/functions.py @@ -1,7 +1,6 @@ -from django.db.models import Transform -from django.db.models import fields -from .fields import PathField +from django.db.models import Transform, fields +from .fields import PathField __all__ = ("NLevel",) diff --git a/src/django_ltree/managers.py b/src/django_ltree/managers.py index ce8f5de..ebfe099 100644 --- a/src/django_ltree/managers.py +++ b/src/django_ltree/managers.py @@ -1,5 +1,7 @@ -from django.db import models from typing import TYPE_CHECKING + +from django.db import models + from django_ltree.paths import PathGenerator from .querysets import TreeQuerySet diff --git a/src/django_ltree/models.py b/src/django_ltree/models.py index 64863cd..f78e6fe 100644 --- a/src/django_ltree/models.py +++ b/src/django_ltree/models.py @@ -1,6 +1,7 @@ -from django.db import models from typing import Any +from django.db import models + from .fields import PathField, PathValue from .managers import TreeManager diff --git a/src/django_ltree/paths.py b/src/django_ltree/paths.py index b8c1524..a654de2 100644 --- a/src/django_ltree/paths.py +++ b/src/django_ltree/paths.py @@ -1,5 +1,5 @@ -import string import math +import string from itertools import product from .fields import PathValue diff --git a/src/django_ltree/querysets.py b/src/django_ltree/querysets.py index 8c70861..4be8ccd 100644 --- a/src/django_ltree/querysets.py +++ b/src/django_ltree/querysets.py @@ -1,7 +1,7 @@ -from django.db import models - from typing import TYPE_CHECKING +from django.db import models + if TYPE_CHECKING: from .models import TreeModel diff --git a/tests/conftest.py b/tests/conftest.py index 2d9a97b..bd74b55 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ import os + import django from django.conf import settings diff --git a/tests/taxonomy/migrations/0001_initial.py b/tests/taxonomy/migrations/0001_initial.py index 2267f9c..7c9ae3b 100644 --- a/tests/taxonomy/migrations/0001_initial.py +++ b/tests/taxonomy/migrations/0001_initial.py @@ -1,8 +1,7 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.24 on 2019-09-11 12:31 -from __future__ import unicode_literals from django.db import migrations, models + import django_ltree.fields diff --git a/tests/test_label.py b/tests/test_label.py index ed1f991..bf4c3b1 100644 --- a/tests/test_label.py +++ b/tests/test_label.py @@ -9,5 +9,5 @@ def test_label_generation(): def test_automatic_name_creation(): from taxonomy.models import Taxonomy - for i in range(0, 1000): + for i in range(1000): Taxonomy.objects.create_child(name=i) diff --git a/tests/test_model.py b/tests/test_model.py index bee4a99..9be2b45 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -1,8 +1,6 @@ import pytest - from taxonomy.models import Taxonomy - TEST_DATA = [ {"name": "Bacteria"}, {"name": "Plantae"}, diff --git a/tests/test_path_field.py b/tests/test_path_field.py index 9bd539f..3dbbe63 100644 --- a/tests/test_path_field.py +++ b/tests/test_path_field.py @@ -1,10 +1,9 @@ import pytest - from django.core.exceptions import ValidationError -from django_ltree.fields import PathValue - from taxonomy.models import Taxonomy +from django_ltree.fields import PathValue + @pytest.mark.parametrize( ["path", "valid"], diff --git a/tests/test_register.py b/tests/test_register.py index e475622..7591025 100644 --- a/tests/test_register.py +++ b/tests/test_register.py @@ -1,5 +1,5 @@ +from django_ltree import functions, lookups from django_ltree.fields import PathField -from django_ltree import lookups, functions def test_registered_lookups():