diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..1f43544 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,10 @@ +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.5.0 + hooks: + # Run the linter. + - id: ruff + args: [--fix] + # Run the formatter. + - id: ruff-format diff --git a/django_ltree/__init__.py b/django_ltree/__init__.py index 2a28f90..e3b0191 100644 --- a/django_ltree/__init__.py +++ b/django_ltree/__init__.py @@ -1 +1 @@ -default_app_config = 'django_ltree.apps.DjangoLtreeConfig' +default_app_config = "django_ltree.apps.DjangoLtreeConfig" diff --git a/django_ltree/functions.py b/django_ltree/functions.py index 6d51c4a..f449085 100644 --- a/django_ltree/functions.py +++ b/django_ltree/functions.py @@ -2,7 +2,6 @@ from django.db.models import fields from .fields import PathField -from django_ltree.fields import PathField __all__ = ("NLevel",) diff --git a/django_ltree/paths.py b/django_ltree/paths.py index 0372b4f..d53e6c4 100644 --- a/django_ltree/paths.py +++ b/django_ltree/paths.py @@ -28,7 +28,6 @@ def __next__(self): if path not in self.skip_paths: return path - @staticmethod def guess_the_label_size(path_size: int, combination_size: int) -> int: # The theoritical limit for this at the time of writing is 2_538_557_185_841_324_496 (python 3.12.2) @@ -53,5 +52,3 @@ def guess_the_label_size(path_size: int, combination_size: int) -> int: label_size += 1 return label_size - - diff --git a/tests/conftest.py b/tests/conftest.py index af05ff6..2d9a97b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,7 +13,7 @@ def pytest_sessionstart(session): "NAME": "ltree_test", "HOST": os.environ.get("DJANGO_DATABASE_HOST", "database"), "USER": os.environ.get("DJANGO_DATABASE_USER", "postgres"), - "PASSWORD": os.environ.get("DJANGO_DATABASE_PASSWORD", "") + "PASSWORD": os.environ.get("DJANGO_DATABASE_PASSWORD", ""), } }, ROOT_URLCONF="tests.urls", diff --git a/tests/taxonomy/apps.py b/tests/taxonomy/apps.py index cdbd4f0..ecb836e 100644 --- a/tests/taxonomy/apps.py +++ b/tests/taxonomy/apps.py @@ -2,4 +2,4 @@ class TaxonomyConfig(AppConfig): - name = 'taxonomy' + name = "taxonomy" diff --git a/tests/taxonomy/migrations/0001_initial.py b/tests/taxonomy/migrations/0001_initial.py index 165cc6c..2267f9c 100644 --- a/tests/taxonomy/migrations/0001_initial.py +++ b/tests/taxonomy/migrations/0001_initial.py @@ -7,23 +7,29 @@ class Migration(migrations.Migration): - initial = True - dependencies = [ - ] + dependencies = [] operations = [ migrations.CreateModel( - name='Taxonomy', + name="Taxonomy", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('path', django_ltree.fields.PathField(unique=True)), - ('name', models.TextField()), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("path", django_ltree.fields.PathField(unique=True)), + ("name", models.TextField()), ], options={ - 'ordering': ('path',), - 'abstract': False, + "ordering": ("path",), + "abstract": False, }, ), ] diff --git a/tests/test_path_value.py b/tests/test_path_value.py index acc4543..ca0a5ee 100644 --- a/tests/test_path_value.py +++ b/tests/test_path_value.py @@ -1,5 +1,3 @@ -import pytest - from django_ltree.fields import PathValue