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> |
||
|---|---|---|
| .. | ||
| _nodes | ||
| _parser | ||
| codegen | ||
| codemod | ||
| helpers | ||
| matchers | ||
| metadata | ||
| testing | ||
| tests | ||
| __init__.py | ||
| _add_slots.py | ||
| _batched_visitor.py | ||
| _exceptions.py | ||
| _flatten_sentinel.py | ||
| _maybe_sentinel.py | ||
| _metadata_dependent.py | ||
| _position.py | ||
| _removal_sentinel.py | ||
| _tabs.py | ||
| _type_enforce.py | ||
| _typed_visitor.py | ||
| _typed_visitor_base.py | ||
| _types.py | ||
| _visitors.py | ||
| py.typed | ||
| tool.py | ||