##// END OF EJS Templates
Check for empty signature return value
krassowski -
Show More
@@ -1,4 +1,4 b''
1 from inspect import signature
1 from inspect import signature, Signature
2 from typing import (
2 from typing import (
3 Any,
3 Any,
4 Callable,
4 Callable,
@@ -336,6 +336,7 b' class _IdentitySubscript:'
336
336
337 IDENTITY_SUBSCRIPT = _IdentitySubscript()
337 IDENTITY_SUBSCRIPT = _IdentitySubscript()
338 SUBSCRIPT_MARKER = "__SUBSCRIPT_SENTINEL__"
338 SUBSCRIPT_MARKER = "__SUBSCRIPT_SENTINEL__"
339 UNKNOWN_SIGNATURE = Signature()
339
340
340
341
341 class GuardRejection(Exception):
342 class GuardRejection(Exception):
@@ -589,10 +590,15 b' def eval_node(node: Union[ast.AST, None], context: EvaluationContext):'
589 if policy.can_call(func) and not node.keywords:
590 if policy.can_call(func) and not node.keywords:
590 args = [eval_node(arg, context) for arg in node.args]
591 args = [eval_node(arg, context) for arg in node.args]
591 return func(*args)
592 return func(*args)
592 sig = signature(func)
593 try:
594 sig = signature(func)
595 except ValueError:
596 sig = UNKNOWN_SIGNATURE
593 # if annotation was not stringized, or it was stringized
597 # if annotation was not stringized, or it was stringized
594 # but resolved by signature call we know the return type
598 # but resolved by signature call we know the return type
595 if not isinstance(sig.return_annotation, str):
599 not_empty = sig.return_annotation is not Signature.empty
600 not_stringized = not isinstance(sig.return_annotation, str)
601 if not_empty and not_stringized:
596 duck = Duck()
602 duck = Duck()
597 duck.__class__ = sig.return_annotation
603 duck.__class__ = sig.return_annotation
598 return duck
604 return duck
General Comments 0
You need to be logged in to leave comments. Login now