Add typing to _tools/gen_exports.py#2738
Merged
jakkdl merged 2 commits intopython-trio:masterfrom Aug 6, 2023
Merged
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #2738 +/- ##
========================================
Coverage 98.90% 98.91%
========================================
Files 113 113
Lines 16669 16797 +128
Branches 3021 3070 +49
========================================
+ Hits 16487 16615 +128
- Misses 125 126 +1
+ Partials 57 56 -1
|
TeamSpen210
approved these changes
Aug 5, 2023
jakkdl
approved these changes
Aug 6, 2023
|
|
||
|
|
||
| def is_function(node): | ||
| def is_function(node: ast.AST) -> TypeGuard[ast.FunctionDef | ast.AsyncFunctionDef]: |
Member
There was a problem hiding this comment.
style: Since there's a bunch of ast.FunctionDef | ast.AsyncFunctionDef I created a TypeAlias for it, and while it does make the signatures a bit easier to parse I'm not even sure myself it's worth it.
trio/_tools/gen_exports.py
Outdated
| def get_public_methods(tree): | ||
| def get_public_methods( | ||
| tree: ast.AST, | ||
| ) -> Generator[ast.FunctionDef | ast.AsyncFunctionDef, None, None]: |
Member
There was a problem hiding this comment.
nit: Iterator instead of Generator means you don't have to specify None, None
Closed
41 tasks
Member
|
Note that this file currently isn't typechecked at all in CI, since we only run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds type annotations to
_tools/gen_exports.pyI would love feedback and any comments on how this could be improved to be more accurate.