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
{{ message }}
Repository navigation
inspect.signature(bytes.hex) raises ValueError "builtin has invalid signature" #87233
But it feels wrong to claim Ellipsis as the default, because that's not really true. A more principled solution would be to add a Parameter.unrepresentable marker and use that as the default, but that feels like a change we can make only in 3.13, not in the bugfix branches.
My leaning is to apply the fix suggested above in 3.13, and put some hack in stubtest (or other tools that want to inspect signatures) to make it work on earlier versions.
Activity
verhovsky commentedon Jan 29, 2021
On Python 3.9
This is also true for memoryview.hex and bytearray.hex . This happens because
>>> bytes.hex.__text_signature__ '($self, /, sep=<unrepresentable>, bytes_per_sep=1)'when it would make more sense for it to return
'($self, /, sep='', bytes_per_sep=1)'
or at least sep=None
JelleZijlstra commentedon Nov 9, 2023
I am looking at this because I realized it's preventing us from testing some signatures in typeshed.
I got this to work:
But it feels wrong to claim
Ellipsisas the default, because that's not really true. A more principled solution would be to add aParameter.unrepresentablemarker and use that as the default, but that feels like a change we can make only in 3.13, not in the bugfix branches.My leaning is to apply the fix suggested above in 3.13, and put some hack in stubtest (or other tools that want to inspect signatures) to make it work on earlier versions.
JelleZijlstra commentedon Nov 9, 2023
This is basically @sobolevn's idea from https://discuss.python.org/t/ac-null-defaults-prevent-correct-signatures-lets-add-inspect-unrepresentable-to-fix-this/30753/6.
sobolevn commentedon Nov 9, 2023
@serhiy-storchaka said that future
inspect.signatures()is a better solution. But, it is in the works.stubtest: hack for "<unrepresentable>" defaults
stubtest: hack for "<unrepresentable>" defaults (#16433)