LibCST/libcst
Steven Troxler 595d8c3948
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 <zsol.zsol@gmail.com>
2022-01-25 09:37:36 -08:00
..
_nodes Proxy both parentheses in some pattern matching nodes (#626) 2022-01-25 11:02:08 +00:00
_parser Fix all type errors (#579) 2022-01-05 18:13:01 +00:00
codegen Remove tox references (#588) 2022-01-06 21:09:27 -05:00
codemod Add support for methods with func type comment excluding self/cls (#622) 2022-01-25 09:37:36 -08:00
helpers Support relative imports in AddImportsVisitor. (#585) 2022-01-08 10:18:10 +00:00
matchers [WIP] Support Parenthesized With Statements (#584) 2022-01-07 12:21:58 -08:00
metadata Fix all type errors (#579) 2022-01-05 18:13:01 +00:00
testing Fix all type errors (#579) 2022-01-05 18:13:01 +00:00
tests add slots to base classes, @add_slots takes bases into account (#605) 2022-01-16 14:14:32 +00:00
__init__.py Implement PEP-634 - Match statement (#568) 2021-12-30 10:00:51 +00:00
_add_slots.py add slots to base classes, @add_slots takes bases into account (#605) 2022-01-16 14:14:32 +00:00
_batched_visitor.py Fix license headers (#560) 2021-12-28 11:55:18 +00:00
_exceptions.py Fix license headers (#560) 2021-12-28 11:55:18 +00:00
_flatten_sentinel.py Fix license headers (#560) 2021-12-28 11:55:18 +00:00
_maybe_sentinel.py Fix license headers (#560) 2021-12-28 11:55:18 +00:00
_metadata_dependent.py Fix license headers (#560) 2021-12-28 11:55:18 +00:00
_position.py Fix all type errors (#579) 2022-01-05 18:13:01 +00:00
_removal_sentinel.py Fix license headers (#560) 2021-12-28 11:55:18 +00:00
_tabs.py Fix license headers (#560) 2021-12-28 11:55:18 +00:00
_type_enforce.py Fix all type errors (#579) 2022-01-05 18:13:01 +00:00
_typed_visitor.py [WIP] Support Parenthesized With Statements (#584) 2022-01-07 12:21:58 -08:00
_typed_visitor_base.py Fix all type errors (#579) 2022-01-05 18:13:01 +00:00
_types.py Fix license headers (#560) 2021-12-28 11:55:18 +00:00
_visitors.py Fix license headers (#560) 2021-12-28 11:55:18 +00:00
py.typed support mypy using py.typed 2019-09-16 13:49:08 -07:00
tool.py Fix license headers (#560) 2021-12-28 11:55:18 +00:00