Skip to content

Commit

Permalink
fix: Don't strip too many parentheses around a call node
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy authored Oct 17, 2022
1 parent 2be135d commit bb5c5e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/griffe/agents/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,8 +1094,8 @@ def _get_sub_value(node: NodeSub) -> str:

def _get_subscript_value(node: NodeSubscript) -> str:
subscript = _get_value(node.slice)
if isinstance(subscript, str):
subscript = subscript.strip("()")
if isinstance(subscript, str) and subscript.startswith("(") and subscript.endswith(")"):
subscript = subscript[1:-1]
return f"{_get_value(node.value)}[{subscript}]"


Expand Down
1 change: 1 addition & 0 deletions tests/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def test_default_value_from_nodes(default):
"o[x,y]",
"o[x:y]",
"o[x:y,z]",
"o[x, y(z)]",
],
)
def test_building_value_from_nodes(expression):
Expand Down

0 comments on commit bb5c5e7

Please # to comment.