Skip to content

Commit

Permalink
Pydantic version caused mypy error
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Nov 22, 2024
1 parent f415f55 commit 0dabade
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/aiida/common/pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def MetadataField( # noqa: N802
short_name: str | None = None,
option_cls: t.Any | None = None,
**kwargs,
):
) -> t.Any | None:
"""Return a :class:`pydantic.fields.Field` instance with additional metadata.
.. code-block:: python
Expand All @@ -41,7 +41,7 @@ class Model(BaseModel):
field_info = Field(default, **kwargs)

for key, value in (('priority', priority), ('short_name', short_name), ('option_cls', option_cls)):
if value is not None:
if value is not None and field_info is not None:
field_info.metadata.append({key: value})

return field_info
2 changes: 1 addition & 1 deletion tests/cmdline/groups/test_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Model(BaseModel):
union_type: t.Union[int, float] = Field(title='Union type')
without_default: str = Field(title='Without default')
with_default: str = Field(title='With default', default='default')
with_default_factory: str = Field(title='With default factory', default_factory=lambda: True)
with_default_factory: str = Field(title='With default factory', default_factory=lambda: True) # type: ignore[assignment]


def test_list_options(entry_points):
Expand Down

0 comments on commit 0dabade

Please sign in to comment.