* Bump LibCST to new release 0.3.6
* Increase version number
* Some more fixes to include in CHANGELOG
* Update CHANGELOG.md
Co-authored-by: jimmylai <yurinai@gmail.com>
Co-authored-by: jimmylai <yurinai@gmail.com>
* Fixed typo in the file name (precent > percent)
Noticed the typo when using `python -m libcst.tool list`, hopefully this fix won't break backwards compatibility!
* fixed typo in test as well
During scope analysis all attribute accesses are collected for matching on
import names. The matching code (specifically `_gen_dotted_names`) was not
prepared for all types of expressions. In particular, complex expressions like
`foo[0].bar.baz()` caused a `StopIteration` exception when `_gen_dotted_names`
calls itself recursively. The nested call doesn't yield any values, and so
calling `next()` on it raises.
This commit fixes these types of errors.
It appears we're running out of file handles when running on large repo on OSX due to waiting until all files have been
processed to join/close the subprocesses.
This PR joins/closes them as they finish, resolving the issue.
```
$ python3 -m libcst.tool codemod {codemod_name} {direectory}
Calculating full-repo metadata...
Executing codemod...
Codemodding {file}
Traceback (most recent call last):
File "/Users/rwilliams/src/go/src/github.com/lyft/python-lyft-ingest/venv/lib/python3.6/site-packages/libcst/codemod/_cli.py", line 253, in _parallel_exec_process_stub
OSError: [Errno 24] Too many open files: '{file}'
Failed to codemod {file}
19.80s 24% complete, 01m 02s estimated for 741 files to go...Traceback (most recent call last):
File "/opt/lyft/brew/Cellar/python36/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/opt/lyft/brew/Cellar/python36/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/rwilliams/src/go/src/github.com/lyft/python-lyft-ingest/venv/lib/python3.6/site-packages/libcst/tool.py", line 833, in <module>
main(os.environ.get("LIBCST_TOOL_COMMAND_NAME", "libcst.tool"), sys.argv[1:])
File "/Users/rwilliams/src/go/src/github.com/lyft/python-lyft-ingest/venv/lib/python3.6/site-packages/libcst/tool.py", line 828, in main
return lookup.get(args.action or None, _invalid_command)(proc_name, command_args)
File "/Users/rwilliams/src/go/src/github.com/lyft/python-lyft-ingest/venv/lib/python3.6/site-packages/libcst/tool.py", line 581, in _codemod_impl
repo_root=config["repo_root"],
File "/Users/rwilliams/src/go/src/github.com/lyft/python-lyft-ingest/venv/lib/python3.6/site-packages/libcst/codemod/_cli.py", line 720, in parallel_exec_transform_with_prettyprint
process.start()
File "/opt/lyft/brew/Cellar/python36/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/process.py", line 105, in start
self._popen = self._Popen(self)
File "/opt/lyft/brew/Cellar/python36/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/context.py", line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "/opt/lyft/brew/Cellar/python36/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/context.py", line 277, in _Popen
return Popen(process_obj)
File "/opt/lyft/brew/Cellar/python36/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/opt/lyft/brew/Cellar/python36/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/popen_fork.py", line 65, in _launch
parent_r, child_w = os.pipe()
OSError: [Errno 24] Too many open files
```
Basically move the apply_annotations code from Pyre.
Make it a ContextAwareTransformer named ApplyTypeAnnotationsVisitor. Use GatherImportsVisitor to collect imports. Add a static method `add_stub_to_context` so that users can schedule a stub whose types are to be applied later. Use `assertCodemod` and `data_provider` in the tests. Add documentation. Remove fixmes.
Several of the python 2 features are gated on these in addition to
version (like `with_statement`), and a refactoring tool like Bowler
commonly needs this information anyway.