Skip to content

Commit

Permalink
Switch linter and formatter to Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
surenkov committed May 5, 2024
1 parent afa1a5c commit b6bb473
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 40 deletions.
17 changes: 8 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ repos:
- repo: meta
hooks:
- id: check-hooks-apply
- repo: https://github.com/PyCQA/isort
rev: 5.13.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.3
hooks:
- id: isort
args: [ "--settings-path", "./pyproject.toml", "--filter-files" ]
# Run the linter.
- id: ruff
files: "^django_pydantic_field/"
exclude: ^.*\b(\.pytest_cache|\.venv|venv).*\b.*$
- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black
args: [ "--config", "./pyproject.toml" ]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
files: "^django_pydantic_field/"
exclude: ^.*\b(\.pytest_cache|\.venv|venv).*\b.*$
2 changes: 1 addition & 1 deletion django_pydantic_field/_migration_serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import warnings

from .compat.django import *
from .compat.django import * # noqa: F403

DEPRECATION_MSG = (
"Module 'django_pydantic_field._migration_serializers' is deprecated "
Expand Down
2 changes: 1 addition & 1 deletion django_pydantic_field/compat/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def unwrap(cls, value):
origin = GenericContainer.unwrap(value.origin)
metadata = tuple(map(BaseContainer.unwrap, value.metadata))
try:
annotated_args = (origin, *metadata)
annotated_args = (origin, *metadata) # noqa: F841
annotation = te.Annotated[annotated_args]
except TypeError:
annotation = None
Expand Down
2 changes: 1 addition & 1 deletion django_pydantic_field/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
if not PYDANTIC_V1:
raise ImportError("django_pydantic_field.v1 package is only compatible with Pydantic v1")

from .fields import *
from .fields import * # noqa: F403
23 changes: 2 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ coreapi = ["coreapi"]
jsonform = ["django_jsonform>=2.0,<3"]
dev = [
"build",
"black",
"isort",
"ruff",
"mypy",
"pre-commit",
"pytest~=7.4",
Expand Down Expand Up @@ -82,26 +81,8 @@ Documentation = "https://github.com/surenkov/django-pydantic-field"
Source = "https://github.com/surenkov/django-pydantic-field"
Changelog = "https://github.com/surenkov/django-pydantic-field/releases"

[tool.isort]
py_version = 311
profile = "black"
line_length = 120
multi_line_output = 3
include_trailing_comma = true
force_alphabetical_sort_within_sections = true
force_grid_wrap = 0
use_parentheses = true

[tool.black]
target-version = ["py38", "py39", "py310", "py311", "py312"]
[tool.ruff]
line-length = 120
exclude = '''
/(
\.pytest_cache
| \.venv
| venv
)/
'''

[tool.mypy]
plugins = [
Expand Down
7 changes: 2 additions & 5 deletions tests/settings/django_test_settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import dj_database_url
import importlib.util

SECRET_KEY = "1"
SITE_ID = 1
Expand All @@ -19,11 +20,7 @@
"tests.test_app",
]

try:
import django_jsonform # type: ignore[import-untyped]
except ImportError:
pass
else:
if importlib.util.find_spec("django_jsonform") is not None:
INSTALLED_APPS.append("django_jsonform")


Expand Down
1 change: 0 additions & 1 deletion tests/test_app/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import django_pydantic_field.fields
import tests.conftest
import tests.test_app.models
import types
import typing
from django.db import migrations, models

Expand Down
2 changes: 1 addition & 1 deletion tests/test_migration_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
try:
from django_pydantic_field.compat.django import GenericContainer
except ImportError:
from django_pydantic_field._migration_serializers import GenericContainer
from django_pydantic_field._migration_serializers import GenericContainer # noqa

if sys.version_info < (3, 9):
test_types = [
Expand Down

0 comments on commit b6bb473

Please sign in to comment.