Skip to content

Commit

Permalink
chore(utils): raise error in case of missing module when evaluating t…
Browse files Browse the repository at this point in the history
…ypehints
  • Loading branch information
kszucs committed Sep 11, 2024
1 parent 5a24ac9 commit 644eb4c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion koerce/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ def equals(self, other: AsBuiltin) -> bool:
return self.type_ == other.type_

def describe(self, value, reason) -> str:
return f"`{value!r}` cannot be coerced to builtin type {self.type_!r}"
return f"`{value!r}` cannot be coerced to type {self.type_!r}"

@cython.cfunc
def match(self, value, ctx: Context):
Expand Down
3 changes: 2 additions & 1 deletion koerce/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class properties.
Mapping of parameter or attribute name to type hint.
"""
if isinstance(obj, dict):
assert module is not None
if module is None:
raise TypeError("`module` must be provided to evaluate type hints")
obj = FakeType(module=module, annotations=obj)
mod = sys.modules.get(module, None)
globalns = getattr(mod, "__dict__", None)
Expand Down

0 comments on commit 644eb4c

Please sign in to comment.