
On Mon, 4 Jun 2018 at 17:29, Ivan Pozdeev via Python-Dev < python-dev@python.org> wrote:
On 05.06.2018 3:09, Matthias Bussonnier wrote:
This may even be a bug/feature of IPython,
I see that inspect.signature(timedelta) fails, so if timedelta? says Init signature: timedelta(self, /, *args, **kwargs) Then this may be some IPython internal logic. The timedelta class seem to use __new__ instead of __init__ (not sure why)
Because it's an immutable type.
Ah, yes, thanks.
and __new__ have a meaningful signature, So maybe we should fallback on that during signature inspection.
According to https://stackoverflow.com/questions/4374006/check-for-mutability-in-python , there are no reliable tests for mutability.
Sure, but we can test if the signature of __init__ is (self,/, *args, **kwargs), and if it is, it is useless we can attempt to get the signature from __new__ and show that instead. We do similar things for docstrings, if __init__ have no docstring we look at the class level docstring. -- M