Closed tjsmart closed 2 years ago
Thank you @tjsmart for the contribution!
Seems that Python 3.6 still needs some work.
Curious if the build failure in 3.6 relates to https://github.com/mkorpela/overrides/issues/89.
In python3.6 inspecting the signature of a builtin throws a value error:
$ python
Python 3.6.9 (default, Jun 29 2022, 11:45:57)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import inspect
>>> inspect.signature(int.bit_length)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/inspect.py", line 3065, in signature
return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
File "/usr/lib/python3.6/inspect.py", line 2815, in from_callable
follow_wrapper_chains=follow_wrapped)
File "/usr/lib/python3.6/inspect.py", line 2273, in _signature_from_callable
skip_bound_arg=skip_bound_arg)
File "/usr/lib/python3.6/inspect.py", line 2097, in _signature_from_builtin
raise ValueError("no signature found for builtin {!r}".format(func))
ValueError: no signature found for builtin <method 'bit_length' of 'int' objects>
In python3.9 (presumably similar for other python3.7+), it retrieves the correct signature:
$ python
Python 3.9.7 (v3.9.7:1016ef3790, Aug 30 2021, 16:39:15)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import inspect
>>> inspect.signature(int.bit_length)
<Signature (self, /)>
Ideally, we would be able to retrieve the signature correctly in 3.6. I'm not sure how to do that, but I'm happy to help take a look into that.
Alternatively, (less ideal solution) user's of 3.6 would need to specify check_signature=False
which is the current workaround. But at least we gain the benefit of signature checking for 3.7+.
@mkorpela, any suggestions on how to proceed?
Pass the signature check if ValueError is thrown from inspect. Then test both cases, where override is valid and faulty. Also test Conditionally (if Python 3.6 else if greater) for this specific case.
Thank you for the contribution. I try to get this released this week.
Thanks @mkorpela!
First off, thank you for this awesome package!
This PR, intends to resolve a minor bug I describe below. I originally encountered the issue while attempting to use overrides with a class from PySide6 (Qt framework package).
But luckily I was able to reproduce the issue more simply using a builtin:
For some reason, unknown to me, not all methods in python have a module. It sort of makes sense for a builtin method like
int.bit_length
. But I don't know why it happens for other packages (such as PySide6).I think the solution I proposed is self explanatory but please let me know if I should include more details.
FYI, this is my first contribution to an open source project. Please, let me know if I missed any checks!