You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the existing issues and didn't find my bug already reported there
I have checked that my bug is still present in the latest release
Typeguard version
4.4.1
Python version
3.13.0
What happened?
In check_signature_compatible(), Typeguard calls inspect.signature(), which can fail with ValueError if the signature cannot be determined for some reason. Typeguard should catch that error and probably ignore/skip the problematic signature check. Currently the exception falls through to the calling code:
Traceback (most recent call last):
[...]
File "/data/src/converters/pb2.py", line 157, in _populate_entry_pb2
def _populate_entry_pb2(
...<30 lines>...
)
File "/usr/local/lib/python3.13/site-packages/typeguard/_functions.py", line 137, in check_argument_types
check_type_internal(value, annotation, memo)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/typeguard/_checkers.py", line 946, in check_type_internal
checker(value, origin_type, args, memo)
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/typeguard/_checkers.py", line 837, in check_protocol
check_signature_compatible(subject, origin_type, attrname)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/typeguard/_checkers.py", line 651, in check_signature_compatible
subject_sig = inspect.signature(getattr(subject, attrname))
File "/usr/local/lib/python3.13/inspect.py", line 3340, in signature
return Signature.from_callable(obj, follow_wrapped=follow_wrapped,
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
globals=globals, locals=locals, eval_str=eval_str)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/inspect.py", line 3066, in from_callable
return _signature_from_callable(obj, sigcls=cls,
follow_wrapper_chains=follow_wrapped,
globals=globals, locals=locals, eval_str=eval_str)
File "/usr/local/lib/python3.13/inspect.py", line 2578, in _signature_from_callable
return _signature_from_builtin(sigcls, obj,
skip_bound_arg=skip_bound_arg)
File "/usr/local/lib/python3.13/inspect.py", line 2364, in _signature_from_builtin
raise ValueError("no signature found for builtin {!r}".format(func))
ValueError: no signature found for builtin <method 'add' of 'google._upb._message.RepeatedCompositeContainer' objects>
How can we reproduce the bug?
Since datetime.timedelta seems to have a similar problem with inspect.signature, the issue can be reproduced like this:
Things to check first
I have searched the existing issues and didn't find my bug already reported there
I have checked that my bug is still present in the latest release
Typeguard version
4.4.1
Python version
3.13.0
What happened?
In
check_signature_compatible()
, Typeguard callsinspect.signature()
, which can fail withValueError
if the signature cannot be determined for some reason. Typeguard should catch that error and probably ignore/skip the problematic signature check. Currently the exception falls through to the calling code:How can we reproduce the bug?
Since
datetime.timedelta
seems to have a similar problem withinspect.signature
, the issue can be reproduced like this:The text was updated successfully, but these errors were encountered: