Am 30.11.21 um 13:39 schrieb Oscar Benjamin:
Others have mentioned the pressure on libraries to adopt typing and
I've certainly noticed this with SymPy. I think type hints could be
good for SymPy for internal use but it seems that a lot of users want
it for external reasons that I don't always understand but that also
seems to come partly from editors as well.

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.

Some people apparently want to add type hints that look completely
useless to me like
     def f() -> Union[MyClass, Any]
As I understand it this does not give any meaningful information to a
type checker but it apparently makes vscode work better:
https://github.com/sympy/sympy/pull/22180#discussion_r718917577

We have several resources that can help with questions like these:

 * https://github.com/python/typing/discussions is a forum for
   questions about typing.
 * The forum also has a separate section where users can ask for
   reviews of type annotations, for example in stub files.
 * https://gitter.im/python/typing is a chat for typing-related questions.

We are also working on a documentation hub at https://typing.readthedocs.io/, but there is not much to see at the moment.

There are other open "issues" like this for SymPy where the
presumption is that not having type hints is now to be considered a
deficiency of the library regardless of whether the hints have any
benefit for internal use. I don't object to adding the hints but it's
a huge amount of work that someone would have to do and I don't want
to add useless/inaccurate hints temporarily (as some have suggested to
do).

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. This is usually quite a bit easier than typing an existing code base. Alternatively, just adding type annotations to the public API, but not using type checking yourself, can be useful for your users.

 - 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/PUV2ODPSN27JN6SXLVUSY3O54G7H2ONB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to