Commit graph

1099 commits

Author SHA1 Message Date
Josie Eshkenazi
666247a192
[release] Bump LibCST to new release 0.3.6 (#300)
* 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>
2020-05-28 13:53:26 -07:00
jimmylai
b9d4629f91
[scope] remove iter call to be efficient (#302)
Co-authored-by: Jimmy Lai <jimmylai@fb.com>
2020-05-28 09:07:30 -07:00
lrjball
1a66b41fe9
Fixed typo in the file name (precent > percent) (#301)
* 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
2020-05-27 17:15:27 -07:00
Zsolt Dollenstein
f32389a126
Fix StopIteration exception during scope analysis (#298)
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.
2020-05-27 16:39:30 -07:00
Josie Eshkenazi
746226528b
Add NamedTuple to dataclass conversion codemod (#299)
Add NamedTuple to dataclass conversion codemod.
2020-05-27 09:16:17 -04:00
Jimmy Lai
3c5aa26839 [release] Bump LibCST to new release 0.3.4 2020-05-12 11:35:55 -07:00
Pradeep Kumar Srinivasan
bfcc456087 Add argument for ignoring existing annotations.
This will allow us to override existing types based on the stub.
2020-05-11 17:41:16 -07:00
Zsolt Dollenstein
93a389b8d9 Handle non-import attribute accesses gracefully 2020-04-28 09:43:25 -07:00
Zsolt Dollenstein
6f6223d8ab fix type error 2020-04-28 09:33:41 -07:00
Zsolt Dollenstein
53d4cfaca4 simplify code based on review comments 2020-04-28 09:33:41 -07:00
Zsolt Dollenstein
c992d2d01d Add dotted imports support in get_qualified_names 2020-04-28 09:33:41 -07:00
Carl Meyer
940647e8c9
Merge pull request #289 from jimmylai/formatting_error
[codemod] add integration test for show errors from formatter subprocess call
2020-04-23 16:57:13 -06:00
Jimmy Lai
675e91db8d [codemod] show errors from formatter subprocess call 2020-04-23 13:13:26 -07:00
Carl Meyer
e5c80dfbd8
Merge pull request #288 from jimmylai/formatting_error
[codemod] show errors from formatter subprocess call
2020-04-23 12:47:30 -06:00
Jimmy Lai
e5abaa8598 [codemod] show errors from formatter subprocess call 2020-04-23 11:20:20 -07:00
Zsolt Dollenstein
477a03e3a8
[ScopeProvider] Expose more granular Assignments and Accesses for dotted imports (#284) 2020-04-21 10:27:47 +01:00
Roy Williams
30cb9f3c6a s/remove/discard 2020-04-09 13:56:45 -07:00
Roy Williams
834b5b989e Support <3.7 2020-04-09 13:56:45 -07:00
Roy Williams
dc782f116a Fix "Too many open files" errors when running on large repo on OSX
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
```
2020-04-09 13:56:45 -07:00
jkarres
621d9a949a typo fix 2020-04-05 10:50:10 -07:00
Jimmy Lai
4f060e7cd1 [release] Bump LibCST to new release 0.3.4 2020-03-27 11:08:29 -07:00
Jimmy Lai
0dc39950f9 [AddImportsVisitor] generate deterministic add import output by sorting the sets. 2020-03-26 09:33:29 -07:00
Pradeep Kumar Srinivasan
1b9a52b074 Apply annotations from stub.
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.
2020-03-23 09:16:37 -07:00
Tim Hatch
d2b86be3c7
Merge pull request #261 from thatch/syntax-3.0
Support Python 3 syntax back to 3.0
2020-03-20 07:05:00 -07:00
Zsolt Dollenstein
a65c67d4df
Add codemod command for removing unused imports (#266) 2020-03-20 11:10:52 +00:00
jimmylai
6c48a93a5a Use inline ::. 2020-03-19 07:56:19 -07:00
jimmylai
196f8c8d28 [docs] improve readability per reader's feedback 2020-03-19 07:56:19 -07:00
Jimmy Lai
dee174d5f8 [typing] add missing type annotations 2020-03-19 07:41:19 -07:00
jimmylai
cce934acca Fix typo in README.rst
Co-Authored-By: Carl Meyer <carl@oddbird.net>
2020-03-18 17:49:35 -07:00
jimmylai
a7cdabdefd [docs] fix Pyre setup steps formatting in README 2020-03-18 17:49:35 -07:00
Jimmy Lai
f612604c04 RemovedNodeVisitor should not remove imports when references exist. 2020-03-16 07:46:11 -07:00
Tim Hatch
62fd4e5de3 Change annotation to make type checker happy 2020-03-12 08:45:18 -07:00
Tim Hatch
f961f7e70c Shorter name for KNOWN_PYTHON_VERSION_STRINGS 2020-03-12 08:45:18 -07:00
Tim Hatch
dc9dcfe507 Update README to specify 3.0+ versions work 2020-03-12 08:45:18 -07:00
Tim Hatch
8053cdbc6e [parsing 3.1] with multiple items 2020-03-12 08:45:18 -07:00
Tim Hatch
0bde0ce60c [parsing 3.3] disallow u-prefix strings from 3.0 to 3.2 2020-03-12 08:45:18 -07:00
Tim Hatch
f17bde3fe2 [parsing 3.3] yield from (PEP 380) 2020-03-12 08:45:18 -07:00
Tim Hatch
21ca166c15 [parsing 3.3] Unpacking generalizations (PEP 448) 2020-03-12 08:45:18 -07:00
Tim Hatch
a65cb06f3a [parsing 3.3] async def (PEP 492) 2020-03-12 08:45:18 -07:00
Tim Hatch
9d0a2be845 [parsing 3.3] Matrix multiply (PEP 465) 2020-03-12 08:45:18 -07:00
Tim Hatch
2a3703ec0a Simplify allowed python_versions, add 3.3 2020-03-12 08:45:18 -07:00
Tim Hatch
5b83c638d6 Add ability to test at a specific version 2020-03-12 08:45:18 -07:00
Tim Hatch
0c7d8b42ba Plumb through future_imports 2020-03-12 08:45:18 -07:00
Tim Hatch
522eb5ee0c Add detecting future imports to config.
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.
2020-03-12 08:45:18 -07:00
Jimmy Lai
ea8619ade5 [CI] Use the latest LibCST source code in Pyre check 2020-03-12 08:26:07 -07:00
Tim Hatch
c7d26794cb
Merge pull request #260 from Instagram/jimmylai-patch-2
Add `--preserve-pythonpath` option to `pyre check` in README.
2020-03-06 14:35:45 -08:00
jimmylai
91e7bb739c
Add --preserve-pythonpath option to pyre check in README. 2020-03-06 22:16:42 +00:00
Jimmy Lai
7a534cfa32 [pyre] use --preserve-pythonpath to enable Pyre to read from site-packages/ 2020-03-06 21:42:46 +00:00
Tim Hatch
b31cf0cc7e
Merge pull request #256 from thatch/issue249
Better validate `except` without a space after it.
2020-03-05 07:19:53 -08:00
Tim Hatch
196a4f611e
Merge pull request #257 from thatch/issue250
Improve KeyError message for missing metadata
2020-03-05 07:18:53 -08:00