stubber.codemod.utils

Module Contents

Classes

ScopeableMatcherTransformer

MatcherDecoratableTransformer that can be reused with different scopes.

Functions

shallow_copy_function(→ types.FunctionType)

Create a shallow copy of the given function.

stubber.codemod.utils.shallow_copy_function(func: Any) types.FunctionType

Create a shallow copy of the given function.

The returned function is unbound and does not copy attributes defined on the function.

Parameters:

func (Any) –

Return type:

types.FunctionType

class stubber.codemod.utils.ScopeableMatcherTransformer

Bases: libcst.matchers.MatcherDecoratableTransformer

MatcherDecoratableTransformer that can be reused with different scopes.

scope_matcher: libcst.matchers.BaseMatcherNode | None
_build_scoped_meth(method_name: str, scope_matcher: libcst.matchers.BaseMatcherNode)

Build unbound scoped method from parent class.

Parameters:
  • method_name (str) –

  • scope_matcher (libcst.matchers.BaseMatcherNode) –

with_scope(scope_matcher: libcst.matchers.BaseMatcherNode) libcst.matchers.MatcherDecoratableTransformer

Construct a copy of this matcher with visitors scoped to scope_matcher.

Parameters:

scope_matcher (libcst.matchers.BaseMatcherNode) –

Return type:

libcst.matchers.MatcherDecoratableTransformer