Scratch dictionary being prematurely emptied in codemod
Open
- Dominant language
- Python
- Stars
- 1.9k
- Forks
- 229
- PR merge metrics
- No merged PRs in 30d
Description
Running a codemod command like:
`python3 -m libcst.tool codemod --module="x" ensure_import_present.EnsureImportPresentCommand PATH`
results in:
```
self.context.scratch["module"],
KeyError: 'module'
```
I see the scratch dict is being [replaced](https://github.com/Instagram/LibCST/blob/47e5ea15e1c92358f3c7da6af11ac46fb80ba78d/libcst/codemod/_cli.py#L251) with an empty one before anything happens with the context object.
The codemod works when I hard code the scratch dict
Is this a bug or am I missing something here?
Contributor guide
Assessment
This issue has not been assessed yet.