-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for methods with func type comment excluding self/cls (#622)
* Add support for methods with func type comment excluding self/cls PEP 484 doesn't really specify carefully how function type comments should work on methods, but since usually the type of `self` / `cls` is automatic, most use cases choose to only annotate the other arguments. As a result, this commit modifies our codemod so that non-static methods can specify either all the arguments, or all but one of them. We'll correctly zip together the inline and func-type-comment types either way, typically getting no type for `cls` or `self`. We accomplish this by using matchers to trigger the visit method for FunctionDef rather than using visit_FunctionDef, which gives us enough context to determine when a function def is a regular function versus a method (plus also matching the decorators against `@staticmethod`, so that we trigger the normal function logic in that case). Co-authored-by: Zsolt Dollenstein <[email protected]>
- Loading branch information
Showing
2 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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