Skip to content

Commit

Permalink
Support for Attributes and Decorators in _NameUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
andrecsilva committed Sep 15, 2023
1 parent 94dd20e commit fc54cfb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libcst/metadata/scope_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,16 @@ def get_name_for(node: Union[str, cst.CSTNode]) -> Optional[str]:
return node.value
elif isinstance(node, str):
return node
elif isinstance(node, cst.Attribute):
return f"{_NameUtil.get_name_for(node.value)}.{node.attr.value}"
elif isinstance(node, cst.Call):
return _NameUtil.get_name_for(node.func)
elif isinstance(node, cst.Subscript):
return _NameUtil.get_name_for(node.value)
elif isinstance(node, (cst.FunctionDef, cst.ClassDef)):
return _NameUtil.get_name_for(node.name)
elif isinstance(node, cst.Decorator):
return get_full_name_for_node(node.decorator)
return None


Expand Down

0 comments on commit fc54cfb

Please sign in to comment.