mirror of
https://github.com/Instagram/LibCST.git
synced 2025-12-23 10:35:53 +00:00
* 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 <zsol.zsol@gmail.com> |
||
|---|---|---|
| .. | ||
| commands | ||
| tests | ||
| visitors | ||
| __init__.py | ||
| _cli.py | ||
| _codemod.py | ||
| _command.py | ||
| _context.py | ||
| _dummy_pool.py | ||
| _runner.py | ||
| _testing.py | ||
| _visitor.py | ||