Skip to content

Commit

Permalink
update pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lmignon committed Sep 10, 2024
1 parent a7ebbbc commit 351e391
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ exclude_lines = [
]

[tool.ruff]
select = [
lint.select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
# "I", # isort
"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"]

Expand Down
6 changes: 3 additions & 3 deletions src/extendable_pydantic/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__")
Expand Down
2 changes: 1 addition & 1 deletion src/extendable_pydantic/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/test_forward_refs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test forward refs resolution."""

from typing import List, Optional

from pydantic import BaseModel, ConfigDict
Expand Down
1 change: 1 addition & 0 deletions tests/test_generics_inheritance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test generics model inheritance."""

from typing import Generic, List, TypeVar, Optional

try:
Expand Down
1 change: 1 addition & 0 deletions tests/test_inheritance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test model inheritance."""

from typing import List, Optional

try:
Expand Down
1 change: 1 addition & 0 deletions tests/test_relation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test relations."""

from pydantic.main import BaseModel

from extendable_pydantic import ExtendableModelMeta
Expand Down

0 comments on commit 351e391

Please sign in to comment.