Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Nijat Khanbabayev <[email protected]>
  • Loading branch information
NeejWeej committed Jan 13, 2025
1 parent 4bcf5cd commit 3af6145
Show file tree
Hide file tree
Showing 2 changed files with 934 additions and 1 deletion.
14 changes: 13 additions & 1 deletion csp/impl/types/instantiation_type_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,20 @@ def _add_scalar_value(self, arg, in_out_def):
def _is_scalar_value_matching_spec(self, inp_def_type, arg):
if inp_def_type is typing.Any:
return True
if UpcastRegistry.instance().resolve_type(inp_def_type, type(arg), raise_on_error=False) is inp_def_type:
if inp_def_type is typing.Callable or (
hasattr(inp_def_type, "__origin__") and CspTypingUtils.get_origin(inp_def_type) is collections.abc.Callable
):
return callable(arg)
resolved_type = UpcastRegistry.instance().resolve_type(inp_def_type, type(arg), raise_on_error=False)
if resolved_type is inp_def_type:
return True
elif (
CspTypingUtils.is_generic_container(inp_def_type)
and CspTypingUtils.get_orig_base(inp_def_type) is resolved_type
):
return True
# if UpcastRegistry.instance().resolve_type(inp_def_type, type(arg), raise_on_error=False) is inp_def_type:
# return True
if CspTypingUtils.is_union_type(inp_def_type):
types = inp_def_type.__args__
for t in types:
Expand Down
Loading

0 comments on commit 3af6145

Please sign in to comment.