Skip to content
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ repos:
# Ruff is a code style and formatter
# It works on files in-place
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.7
rev: v0.15.9
hooks:
- id: ruff-check
name: ruff
Expand All @@ -90,7 +90,7 @@ repos:
# The project's documentation can be found at:
# https://mypy.readthedocs.io/en/stable/index.html
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.1
rev: v1.20.0
hooks:
- id: mypy
exclude: ^tests/.*$
Expand Down
12 changes: 10 additions & 2 deletions oteapi/models/genericconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pydantic.fields import PydanticUndefined

if TYPE_CHECKING: # pragma: no cover
from typing import Any
from typing import Any, cast


class AttrDict(BaseModel, MutableMapping): # noqa: PLW1641
Expand Down Expand Up @@ -103,6 +103,10 @@ def update( # type: ignore[override]
) -> None:
if other and isinstance(other, Mapping):
for key, value in other.items():
if not isinstance(key, str):
raise TypeError(
"Keys must be of type `str`, not " f"`{type(key).__name__}`."
)
setattr(self, key, value)
elif other and isinstance(other, BaseModel):
for key, value in other:
Expand All @@ -117,7 +121,11 @@ def update( # type: ignore[override]
raise ValueError(
"`other` must be an iterable of objects of length two."
)
for key, value in other: # type: ignore[misc]

if TYPE_CHECKING: # pragma: no cover
other = cast(Iterable[tuple[str, Any]], other)

for key, value in other:
setattr(self, key, value)
elif other:
raise TypeError(
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ exclude = [
".codecov.yml",
]

[tool.black]
target-version = ["py310","py311","py312","py313"]

[tool.mypy]
python_version = "3.10"
ignore_missing_imports = true
Expand Down
Loading