Am 01.12.21 um 13:36 schrieb Paul Moore:
On Wed, 1 Dec 2021 at 12:08, Sebastian Rittau <srit...@rittau.biz> wrote:

Please note that users of you library usually won't care that the library uses 
type hints. It's more important that there are type hints for the API, which 
can also be supplied using a stub file.
I tried that route, but I was informed that if I do that, mypy will
not check my stubs against the source code. Which means that there's
no easy way of testing that the stubs are correct - is that accurate?

mypy includes a "stubtest" tool that compares a stub to introspected runtime data. We use it in typeshed as part of the CI process and it's a very powerful tool to help keeping stubs up-to-date and correct.


PS I appreciate the links you posted to various typing forums, but IMO
the most critical missing resource is a central set of typing
documentation that includes examples, FAQs and best practices as well
as reference materials.

Completely agree. This is what typing.readthedocs.io is supposed to become, but time constraints mean that it's very incomplete at the moment.

PPS Sorry if this sounds negative. TBH, I'd quite happily not use
typing if I didn't want to and stay quiet. A lot of the frustration I
see being expressed here (including my own) seems to come from the
fact that it's so difficult to actually take that sort of "I can
ignore it if I don't use it" attitude, whether that's because of
community pressure, tool requirements, or whatever.

I completely understand this pressure, especially for library authors. Providing high quality stubs and the best user experience is not easy. But I believe that referring people to typeshed can help. While we of course prefer high quality stubs or type annotations shipped with the package in question, typeshed can provide a fairly low barrier of entry for projects that don't have the resources to maintain type annotations themselves. It can also be used as an "incubator", where stubs are created and improved iteratively, until they are deemed ready for inclusion in an upstream package.

 - Sebastian

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/3Z7MCNNQUH3S5IWXA5MXVAUKPYYWKFZO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to