Skip to content

Commit

Permalink
Updated to resolve bugs, properly handle RHS
Browse files Browse the repository at this point in the history
  • Loading branch information
sternj committed Oct 10, 2024
1 parent e439e8c commit f7d87a9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions hypothesis-python/src/hypothesis/extra/ghostwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,13 +809,13 @@ def __init__(self):
self.potentially_modified = set()
def visit_Assign(self, node: ast.Assign):
for target in node.targets:
if not isinstance(node, ast.Name):
if not isinstance(target, ast.Name):
# the only other things on the LHS
# can be a Subscript or an Attribute
bv = BaseNameVisitor()
bv.visit(target)
self.potentially_modified.add(bv.base_name)

self.visit(node.value)
def visit_Call(self, node: ast.Call):
# Might overlap with above method,
# but since we're using a set that's okay
Expand Down Expand Up @@ -872,8 +872,10 @@ def _write_call(
subtypes of `except_`, which will be handled in an outer try-except block.
"""
params_dd = _get_params(func)
if copy_args:
if copy_args is None:
potentially_modified = potentially_modified_vars(ast.parse(inspect.getsource(func)).body[0], set(params_dd.keys()))
elif copy_args is True:
potentially_modified = set(params_dd.keys())
else:
potentially_modified = set()
args = ", ".join(
Expand Down

0 comments on commit f7d87a9

Please sign in to comment.