[Pulp-dev] Type hinting in Pulp 3

Brian Bouterse bbouters at redhat.com
Mon Jun 19 20:00:45 UTC 2017


I think adding type hints to docstrings is a fine thing to do if any given
developer wants to. I don't think we should have a policy requiring it or
prohibiting it.

Note that the PEP states these type hints are for static analysis not
runtime type checking. Besides the pep's stance on that, I don't think
CPython supports runtime type checking based on these types. Since vim and
PyCharm support the static analysis already, if it were to be used, we
would derive the value it creates right away.

On Mon, Jun 19, 2017 at 3:20 PM, Daniel Alley <dalley at redhat.com> wrote:

> For what it's worth, Pycharm does support PEP 484 type hinting.
>
> https://www.jetbrains.com/help/pycharm/type-hinting-in-pycharm.html
> https://blog.jetbrains.com/pycharm/2015/11/python-3-5-
> type-hinting-in-pycharm-5/
>
> There are also projects like MyPy which behave like static analyzers.
>
> It is theoretically possible to continue supporting Python 3.3-3.4 if we
> were to put all of the type annotations into .pyi stub files, but I
> personally dislike that idea strongly because it would result in a lot of
> duplication.
>
> On Mon, Jun 19, 2017 at 2:55 PM, David Davis <daviddavis at redhat.com>
> wrote:
>
>> Recently we switched to using Google style docstrings. I was looking
>> through the docs and saw that it supported type hinting
>> (see function_with_types_in_docstring vs function_with_pep484_type_anno
>> tations):
>>
>> http://sphinxcontrib-napoleon.readthedocs.io/en/latest/examp
>> le_google.html
>>
>> Unless I am mistaken, declaring functions using type hinting seems like
>> no extra effort than declaring types in our docstring. I am wondering now
>> might be a good time to consider using type hinting given that Pulp 3 is
>> still fairly new?
>>
>> For more information about type hinting, check out PEP484:
>>
>> https://www.python.org/dev/peps/pep-0484/
>>
>> One concern I have about type hinting though is its newness. It’s only
>> been around since Python 3.5 which also means Pulp 3 would have to require
>> 3.5+. And it doesn’t look like there are many tools that leverage type
>> hinting currently.
>>
>> Thoughts?
>>
>> David
>>
>> _______________________________________________
>> Pulp-dev mailing list
>> Pulp-dev at redhat.com
>> https://www.redhat.com/mailman/listinfo/pulp-dev
>>
>>
>
> _______________________________________________
> Pulp-dev mailing list
> Pulp-dev at redhat.com
> https://www.redhat.com/mailman/listinfo/pulp-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/pulp-dev/attachments/20170619/99f839c7/attachment.htm>


More information about the Pulp-dev mailing list