Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Pre commit #28

Merged
merged 6 commits into from
Jun 29, 2024
Merged
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
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion django_ltree/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
default_app_config = 'django_ltree.apps.DjangoLtreeConfig'
default_app_config = "django_ltree.apps.DjangoLtreeConfig"
1 change: 0 additions & 1 deletion django_ltree/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from django.db.models import fields
from .fields import PathField

from django_ltree.fields import PathField

__all__ = ("NLevel",)

Expand Down
3 changes: 0 additions & 3 deletions django_ltree/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -53,5 +52,3 @@ def guess_the_label_size(path_size: int, combination_size: int) -> int:
label_size += 1

return label_size


2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/taxonomy/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class TaxonomyConfig(AppConfig):
name = 'taxonomy'
name = "taxonomy"
24 changes: 15 additions & 9 deletions tests/taxonomy/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
),
]
2 changes: 0 additions & 2 deletions tests/test_path_value.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import pytest

from django_ltree.fields import PathValue


Expand Down