<p dir="ltr"><br>
On 5 Jun 2015 23:34, "Thomas Güttler" <<a href="mailto:guettliml@thomas-guettler.de">guettliml@thomas-guettler.de</a>> wrote:<br>
><br>
><br>
><br>
> Am 05.06.2015 um 10:38 schrieb Andrew Barnert:<br>
>><br>
>> On Jun 5, 2015, at 00:21, Thomas Güttler <<a href="mailto:guettliml@thomas-guettler.de">guettliml@thomas-guettler.de</a>> wrote:<br>
>>><br>
>>><br>
>>>> Am 05.06.2015 um 08:19 schrieb Stephen Hansen:<br>
>>>>><br>
>>>>> On Thu, Jun 4, 2015, at 11:01 PM, Andrew Barnert via Python-ideas wrote:<br>
>>>>> On Jun 4, 2015, at 22:36, Thomas Güttler <<a href="mailto:guettliml@thomas-guettler.de">guettliml@thomas-guettler.de</a>><br>
>>>>> wrote:<br>
>>>>>><br>
>>>>>><br>
>>>>>> It would be great to have better type hinting in IDEs.<br>
>>>>><br>
>>>>><br>
>>>>> Is PEP 484 not sufficient for this purpose?<br>
>>>><br>
>>>><br>
>>>> It's really not.<br>
>>>><br>
>>>> For one thing, PEP 484 isn't going to result in the standard library<br>
>>>> being hinted all up (though I assume someone may make stubs). But<br>
>>>> really, the specific issue that the OP is running into is because of the<br>
>>>> signature of logging.warn --  msg, *args, **kwargs.<br>
>>><br>
>>><br>
>>> I am using logger.warn() not logging.warn().<br>
>>><br>
>>> The question is: How to know which kind of duck "logger" is?<br>
>><br>
>><br>
>> That is _exactly_ what PEP 484 addresses.<br>
><br>
><br>
> Now I read it and it does exactly what I was looking for.</p>
<p dir="ltr">>> If `logging.getLogger` is annotated or stubbed to specify that it returns a `logging.Logger` (which it will be),<br>
><br>
> > then a static type checker (whether MyPy or a competing checker or custom code in the IDE)<br>
> > can trivially infer that `logger` is a `logging.Logger`.<br>
><br>
> Unfortunately we still use Python2.7, but maybe it is time for change ...</p>
<p dir="ltr">The typeshed project provides stubs for both Python 2 & 3:<a href="https://github.com/JukkaL/typeshed"> </a><a href="https://github.com/JukkaL/typeshed">https</a><a href="https://github.com/JukkaL/typeshed">://</a><a href="https://github.com/JukkaL/typeshed">github.com</a><a href="https://github.com/JukkaL/typeshed">/</a><a href="https://github.com/JukkaL/typeshed">JukkaL</a><a href="https://github.com/JukkaL/typeshed">/</a><a href="https://github.com/JukkaL/typeshed">typeshed</a></p>
<p dir="ltr">Type hinting your own code where appropriate would be easier in Python 3 (since you can use inline type hints)</p>
<p dir="ltr">> Just one thing left:<br>
><br>
> > **If** `logging.getLogger` is annotated ....<br>
><br>
> What is the policy of the standard library? Will there be type hints<br>
> for methods like logging.getLogger() in the standard library in the future?</p>
<p dir="ltr">The standard library won't be getting native annotations any time soon, but the typeshed annotations are expected to fill the gap.</p>
<p dir="ltr">> Since it is quite easy to add them, will patches be accepted?</p>
<p dir="ltr">Contributions to the typeshed stubs would be preferable.</p>
<p dir="ltr">Cheers,<br>
Nick.</p>