Skip to content

fix-mutable-params results in AttributeError #251

@drdavella

Description

@drdavella

Description

The fix-mutable-params codemod appears to result in an AttributeError in certain circumstances. This was originally detected while processing this open source project: https://github.com/zulip/zulip

After checking out use the following command to reproduce:

codemodder /PATH/TO/zulip --codemod-include=fix-mutable-params

It will be necessary to come up with a unit test that minimally reproduces the problem and then fix it.

Traceback

 File "/Users/danieldavella/miniconda3/envs/test-python-codemod-package/lib/python3.10/site-packages/libcst/matchers/_visitors.py", line 515, in on_leave
    retval = CSTTransformer.on_leave(self, original_node, updated_node)
  File "/Users/danieldavella/miniconda3/envs/test-python-codemod-package/lib/python3.10/site-packages/libcst/_visitors.py", line 71, in on_leave
    updated_node = leave_func(original_node, updated_node)
  File "/Users/danieldavella/codemodder-python/src/core_codemods/fix_mutable_params.py", line 180, in leave_FunctionDef
    body=updated_node.body.with_changes(body=new_body),
  File "/Users/danieldavella/miniconda3/envs/test-python-codemod-package/lib/python3.10/site-packages/libcst/_nodes/base.py", line 325, in with_changes
    return replace(self, **changes)
  File "/Users/danieldavella/miniconda3/envs/test-python-codemod-package/lib/python3.10/dataclasses.py", line 1453, in replace
    return obj.__class__(**changes)
  File "<string>", line 6, in __init__
  File "/Users/danieldavella/miniconda3/envs/test-python-codemod-package/lib/python3.10/site-packages/libcst/_nodes/base.py", line 117, in __post_init__
    self._validate()
  File "/Users/danieldavella/miniconda3/envs/test-python-codemod-package/lib/python3.10/site-packages/libcst/_nodes/statement.py", line 390, in _validate
    if small_stmt.semicolon is None:
AttributeError: 'SimpleStatementLine' object has no attribute 'semicolon'

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions