<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, 4 Jun 2018 at 17:29, Ivan Pozdeev via Python-Dev <<a href="mailto:python-dev@python.org">python-dev@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
On 05.06.2018 3:09, Matthias Bussonnier wrote:<br>
<blockquote type="cite">
<div dir="ltr">This may even be a bug/feature of IPython,
<div><br>
</div>
<div>I see that inspect.signature(timedelta) fails, so if <span style="font-family:monospace,monospace">timedelta? says</span></div>
<div><span style="color:rgb(34,34,34);font-family:monospace,monospace;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Init
signature: timedelta(self, /, *args, **kwargs)</span></div>
<div><span style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Then
this may be some IPython internal logic. The timedelta class
seem to use __new__ instead of __init__ (not sure why)</span></div>
</div>
</blockquote>
<p>Because it's an immutable type.</p></div></blockquote><div>Ah, yes, thanks. </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">
<blockquote type="cite">
<div dir="ltr">
<div><span style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">
and __new__ have a meaningful signature, </span><br>
</div>
<div><span style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">So
maybe we should fallback on that during signature
inspection.</span></div>
<div><span style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br>
</span></div>
</div>
</blockquote>
<p>According to
<a class="m_-5298358443040669888moz-txt-link-freetext" href="https://stackoverflow.com/questions/4374006/check-for-mutability-in-python" target="_blank">https://stackoverflow.com/questions/4374006/check-for-mutability-in-python</a>
,<br>
there are no reliable tests for mutability.</p></div></blockquote><div>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. </div><div>-- </div><div>M</div><div><br></div><div> </div></div></div>