(original) (raw)
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? saysInit 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