-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to communicate the philosophy of type annotations in Python? #8
Comments
Thank you so much Carol for kicking off this discussion! It's super important. I think sometimes we fall into the trap of thinking that proposals to change Python in order to allow for more ergonomic type annotations are "changing Python just for the typing people" and are harmful to non-typing users. I think this is actually backwards and it's important to reframe this tension. Typing is here to stay, and sooner or later people who start without type annotations (which is great!) will need to read annotated code, too. If we can make type annotations simpler, more ergonomic, better "fit" into the language, and easier to read, this doesn't just benefit active users of typing -- it perhaps has the most benefit for non-users of typing who still have to read annotated code in other peoples' libraries! So I think the idea I've heard suggested that we need to "split" the language so typed Python can add syntax without affecting untyped Python is not the right direction. We all have to read each others' code, so the thing that benefits everyone, users of types and non-users of types, is to better integrate and streamline type annotations (without ever requiring them, which should go without saying.) |
Having some evidence for the benefits of annotation would be helpful in convincing projects to adopt it. Many Python projects are very strong on the testing front partially because of the lack of static type checking, but it also means that the benefits of adding annotations are less evident. In numpydoc types are specified inline; I think we'd benefit from having those be grabbed from annotations instead. @carljm Fully agree with your sentiment above: "sooner or later..." — keeping it simple is beneficial for all Python users, preserving one of Python's best features: its ease of readability. |
Newer developer sees a type annotation
|
TODO: SciPy sprint for Carpentries lesson re: typing esp. tensors as a compelling use case; code quality; reproducibility; scaling. Reach out to Turing Way too. |
Thanks Carol for starting a discussion here! I'm interested in getting the ball rolling on some centralized documentation for the Python type system, which ideally could also include some opening or introductory pages that discuss things you just mentioned like (1) how to read documentation, (2) why someone might want to use type annotations, why this is particularly helpful for coding at scale, etc. Right now it's a bit difficult to find any source of truth for learning about the type system outside of finding disjoint pieces scattered across PEPs, or picking a type checker and going to read their website. If we can get a documentation source that the larger Python community has contributed to and agrees on, I could see this providing a lot of value to new and existing users of types in the language. I recall there was a suggestion during the summit to get this started as a subdirectory of the typing repository, where we can incrementally iterate, then potentially moving this to somewhere discoverable alongside other python documentation. Thoughts? I also plan to start some discussion on this in the typing sig mailing list. |
Run Sphinx initialize to set up structure for Python typing documentation. See typing-sig discussion: https://mail.python.org/archives/list/[email protected]/thread/4E7V7MVO4FQVYPVELMCAYFEIYJRXDSY2/ Python docs community issue: python/docs-community#8
AFAICS, this was started in |
Note the specific section linked is specifically aimed at library authors considering whether to ship type hints to their users via PEP 561. We should add more docs to typing.readthedocs.io to address more user profiles. |
A question from the Typing summit:
How to communicate the philosophy of type annotations in Python?
There's a nice community around typing that is responsive to ideas and thoughts.
The text was updated successfully, but these errors were encountered: