GeezerVison is showing github.com — Add type annotations to clinic.py · Issue #104050 · python/cpython
Add type annotations to clinic.py #104050DescriptionFeature or enhancement
Gradually add type hints to clinic.py.
Pitch
Adding type hints to clinic.py will make it easier to debug, fix bugs, do code review, add new features, and triage. IMO, the churn is worth the effort in the long run.
Previous discussion
Since adding typing to the CPython code base has been a slightly controversial topic (obviously controversial for Lib/), I created a topic on Discourse and asked for feedback. So far, I have not received any discouragements :)
Linked PRs
Reacted by Alex Waygood, Kirill Podoprigora and Ken Jin Activityerlend-aasland commented on May 1, 2023 ContributorAuthor More actions Since I've been ignorant to typing until now, I'd like to give this a shot myself; it'll be a nice opportunity to learn some new tricks.
EDIT:
Don't take this too serious; I don't want to block anybody from contributing. Please fire up PRs if you want (I appreciate if you tag me, though!) Reacted by Jelle Zijlstra, sunmy2019, Jacob Nilsson and Ken Jin sobolevn commented on May 3, 2023 Reacted by Erlend E. Aasland hauntsaninja commented on May 4, 2023 A good place to start is by switching the instance fields in CConverter to use variable annotations. This is the cause of most of the existing mypy complaints.
As you add types, the type checker will become more useful. Once you've gotten a number of types in, I recommend upgrading to mypy --check-untyped-defs, and then possibly mypy --strict.
I'm biased, but I think mypy docs are a generally useful reference: https://mypy.readthedocs.io/en/latest/cheat_sheet_py3.html Reacted by Erlend E. Aasland Reacted by Erlend E. Aasland erlend-aasland commented on May 12, 2023 ContributorAuthor More actions As recommended by @AlexWaygood, we should probably start by adding a minimal type check to the CI. (We really don't want to increase CI minutes too much.) In the beginning, perhaps an allow-list is the most manageable path forward. When that list starts to grow, we can consider switching to using a deny-list instead. Thoughts? PRs welcome :) AlexWaygood commented on May 12, 2023 Here's a PR to add a mypy check in CI, checking only the Tools/clinic directory: #104421. The check completed in 20 seconds (and will only run on PRs that touch files in Tools/clinic/), so I doubt it will increase our use of CI minutes too much! Reacted by Erlend E. Aasland Reacted by Erlend E. Aasland added a commit that references this issue on Jul 29, 2023gh-104050: Argument clinic: enable mypy's `--warn-return-any` setting (… AlexWaygood commented on Jul 29, 2023 44 merged PRs later, and clinic is now 100% fully typed! 🚀 Reacted by Erlend E. Aasland erlend-aasland commented on Jul 29, 2023 ContributorAuthor More actions A big thanks to everyone involved! 🎉❤️ Reacted by Alex Waygood and sobolevn
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|