Skip to content

Commit 602221f

Browse files
committed
Satisfy mypy and specify black's target versions
1 parent cbebfca commit 602221f

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

oteapi/models/genericconfig.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pydantic.fields import PydanticUndefined
1010

1111
if TYPE_CHECKING: # pragma: no cover
12-
from typing import Any
12+
from typing import Any, cast
1313

1414

1515
class AttrDict(BaseModel, MutableMapping): # noqa: PLW1641
@@ -103,6 +103,10 @@ def update( # type: ignore[override]
103103
) -> None:
104104
if other and isinstance(other, Mapping):
105105
for key, value in other.items():
106+
if not isinstance(key, str):
107+
raise TypeError(
108+
"Keys must be of type `str`, not " f"`{type(key).__name__}`."
109+
)
106110
setattr(self, key, value)
107111
elif other and isinstance(other, BaseModel):
108112
for key, value in other:
@@ -117,7 +121,11 @@ def update( # type: ignore[override]
117121
raise ValueError(
118122
"`other` must be an iterable of objects of length two."
119123
)
120-
for key, value in other: # type: ignore[misc]
124+
125+
if TYPE_CHECKING: # pragma: no cover
126+
other = cast(Iterable[tuple[str, Any]], other)
127+
128+
for key, value in other:
121129
setattr(self, key, value)
122130
elif other:
123131
raise TypeError(

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ exclude = [
110110
".codecov.yml",
111111
]
112112

113+
[tool.black]
114+
target-version = ["py310","py311","py312","py313"]
115+
113116
[tool.mypy]
114117
python_version = "3.10"
115118
ignore_missing_imports = true

0 commit comments

Comments
 (0)