Page MenuHomeSoftware Heritage
Paste P714

unbound type variables
ActivePublic

Authored by vlorentz on Jul 3 2020, 4:14 PM.
KT = TypeVar("KT")
VT = TypeVar("VT")
def freeze_optional_dict(
d: Union[None, Dict[KT, VT], ImmutableDict[KT, VT]]
# ^swh/model/model.py:49: error: Type variable "swh.model.model.KT" is unbound
# swh/model/model.py:49: note: (Hint: Use "Generic[KT]" or "Protocol[KT]" base class to bind "KT" inside a class)
# swh/model/model.py:49: note: (Hint: Use "KT" in function signature to bind "KT" inside a function)
# swh/model/model.py:49: error: Type variable "swh.model.model.VT" is unbound
# swh/model/model.py:49: note: (Hint: Use "Generic[VT]" or "Protocol[VT]" base class to bind "VT" inside a class)
# swh/model/model.py:49: note: (Hint: Use "VT" in function signature to bind "VT" inside a function)
) -> Optional[ImmutableDict[KT, VT]]:
if isinstance(d, dict):
return ImmutableDict(d)
else:
return d