From c94563f946c63723739f408354e2af0cc35005dc Mon Sep 17 00:00:00 2001 From: Tiago Nobrega Date: Mon, 25 Nov 2024 15:49:06 -0300 Subject: [PATCH 1/2] chore(lint): get around a Pydantic 2.10.x type bug Both mypy and pyright complain that the "field.default_factory()" call has too few arguments, even though its type is typing.Callable[[], Any]. It should be fixed soon, and in the meantime we can ignore the spurious error. Ref: https://github.com/pydantic/pydantic/issues/10945 --- craft_application/services/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/craft_application/services/config.py b/craft_application/services/config.py index 319f9fbf..c0d57312 100644 --- a/craft_application/services/config.py +++ b/craft_application/services/config.py @@ -135,7 +135,7 @@ def get_raw(self, item: str) -> Any: self._cache[item] = field.default return field.default if field.default_factory is not None: - default = field.default_factory() + default = field.default_factory() # type: ignore[call-arg] self._cache[item] = default return default From b0fce29c57ef9b48aa518beab47cd8968ef0bcd3 Mon Sep 17 00:00:00 2001 From: Tiago Nobrega Date: Mon, 25 Nov 2024 16:23:15 -0300 Subject: [PATCH 2/2] fixup! chore(lint): get around a Pydantic 2.10.x type bug --- craft_application/services/config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/craft_application/services/config.py b/craft_application/services/config.py index c0d57312..6b8c4e48 100644 --- a/craft_application/services/config.py +++ b/craft_application/services/config.py @@ -135,6 +135,7 @@ def get_raw(self, item: str) -> Any: self._cache[item] = field.default return field.default if field.default_factory is not None: + # TODO: remove the type ignore after pydantic/pydantic#10945 is fixed default = field.default_factory() # type: ignore[call-arg] self._cache[item] = default return default