From 351e39107eb932b0a1a4311c491c46f7b887dedd Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Tue, 10 Sep 2024 10:46:00 +0200 Subject: [PATCH] update pre-commit --- .pre-commit-config.yaml | 8 ++++---- pyproject.toml | 6 +++--- src/extendable_pydantic/main.py | 6 +++--- src/extendable_pydantic/utils.py | 2 +- tests/test_forward_refs.py | 1 + tests/test_generics_inheritance.py | 1 + tests/test_inheritance.py | 1 + tests/test_relation.py | 1 + 8 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ee45465..76bfd0b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,24 +2,24 @@ default_language_version: python: python3 repos: - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 24.8.0 hooks: - id: black - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.252 + rev: v0.6.4 hooks: - id: ruff args: - --fix - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 hooks: - id: check-toml - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/myint/docformatter - rev: v1.5.1 + rev: v1.7.5 hooks: - id: docformatter args: ["--in-place", "--wrap-summaries=88"] diff --git a/pyproject.toml b/pyproject.toml index b43d8c3..99b2c38 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,7 @@ exclude_lines = [ ] [tool.ruff] -select = [ +lint.select = [ "E", # pycodestyle errors "W", # pycodestyle warnings "F", # pyflakes @@ -74,11 +74,11 @@ select = [ "C", # flake8-comprehensions "B", # flake8-bugbear ] -ignore = [ +lint.ignore = [ "E501", # line too long, handled by black ] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] "tests/test_forward_refs.py" = ["F821"] diff --git a/src/extendable_pydantic/main.py b/src/extendable_pydantic/main.py index d41a23e..4d960bd 100644 --- a/src/extendable_pydantic/main.py +++ b/src/extendable_pydantic/main.py @@ -104,9 +104,9 @@ def _resolve_submodel_fields( for field_name, field_info in cast(BaseModel, cls).model_fields.items(): new_type = resolve_annotation(field_info.annotation, registry) if not all_identical(field_info.annotation, new_type): - cast(BaseModel, cls).model_fields[ - field_name - ] = FieldInfo.merge_field_infos(field_info, annotation=new_type) + cast(BaseModel, cls).model_fields[field_name] = ( + FieldInfo.merge_field_infos(field_info, annotation=new_type) + ) to_rebuild = True if to_rebuild: delattr(cls, "__pydantic_core_schema__") diff --git a/src/extendable_pydantic/utils.py b/src/extendable_pydantic/utils.py index 42afd68..447c676 100644 --- a/src/extendable_pydantic/utils.py +++ b/src/extendable_pydantic/utils.py @@ -45,7 +45,7 @@ def all_identical(left: Optional[Any], right: Optional[Any]) -> bool: return True -def resolve_annotation( +def resolve_annotation( # noqa: C901 type_: Any, registry: Optional[ExtendableClassesRegistry] = None ) -> Any: """Return type with all occurrences of subclass of `ExtendableModelMeta` keys diff --git a/tests/test_forward_refs.py b/tests/test_forward_refs.py index 8141e19..4dcf2ff 100644 --- a/tests/test_forward_refs.py +++ b/tests/test_forward_refs.py @@ -1,4 +1,5 @@ """Test forward refs resolution.""" + from typing import List, Optional from pydantic import BaseModel, ConfigDict diff --git a/tests/test_generics_inheritance.py b/tests/test_generics_inheritance.py index 7c1f015..bea6490 100644 --- a/tests/test_generics_inheritance.py +++ b/tests/test_generics_inheritance.py @@ -1,4 +1,5 @@ """Test generics model inheritance.""" + from typing import Generic, List, TypeVar, Optional try: diff --git a/tests/test_inheritance.py b/tests/test_inheritance.py index 6b75291..4a716aa 100644 --- a/tests/test_inheritance.py +++ b/tests/test_inheritance.py @@ -1,4 +1,5 @@ """Test model inheritance.""" + from typing import List, Optional try: diff --git a/tests/test_relation.py b/tests/test_relation.py index 1faaae6..1e8a199 100644 --- a/tests/test_relation.py +++ b/tests/test_relation.py @@ -1,4 +1,5 @@ """Test relations.""" + from pydantic.main import BaseModel from extendable_pydantic import ExtendableModelMeta