The comment preserving logic introduced in #392 assumed that in an ImportFrom node, ImportAliases have a comma property (except for the last one). That's only true if the ImportFrom node is parsed from actual source, but isn't necessarily true if it's constructed manually.
* Add failing test cases
* mark *Def names as STORE
* Update libcst/metadata/expression_context_provider.py
Co-authored-by: Jimmy Lai <yurinai@gmail.com>
* Fix lint
* Visit annotations and params
* Fix and extend tests
Co-authored-by: Jimmy Lai <yurinai@gmail.com>
* Read install requirements from requirements.txt
* read extras_require from requirements-dev.txt
* add requirements-dev.txt to MANIFEST.in
* apply fixes for new version of Black and Flake8
* don't upgrade Pyre
* re-format
* fix: SaveMachedNode now matches with trailing empty wildcards
Note that SaveMatchedNode was already matching leading empty wildcards, however it's value is incorect due to #337. This is why the test for the leading wildcards are failing, and will be so until #355 is merged.
This fixes#336.
* fix: _matches_zero_nodes type declaration
Since the stdout/err is being captured from this invocation, using the noninteractive flag will make the output much more readable and avoid special characters for terminal pretty-printing.
Fixes enclosed arguments like `c.d` in `x.y(c.d()).z()` were badly being
resolved as `x.y` instead.
This also clarifies the intent in `infer_accesses()` so it no longer shadows
variable `name` and also fixes the case where no node is actually found
in the scope.
## Summary
The pyre stub for the tokenizer module had a syntax error.
Fixing it removes other pyre errors.
## Test Plan
```
pyre check
```
Co-authored-by: Germán Méndez Bravo <kronuz@fb.com>
## Summary
When importing things like `import os.path` and using it as `os.path.join("a", "b").lower()`,
references ended up being in the `["os"]` assignment instead of `["os.path"]`.
This fixes the problem by updating the dotted names generator in the scope provider·
## Test Plan
```
tox -e py37
```
Co-authored-by: Germán Méndez Bravo <kronuz@fb.com>
* [RemoveUnusedImports] Support string type annotations
This PR adds support for detecting imports being used by string type
annotations, as well as imports suppressed by comments.
It breaks up the existing visitor into multiple smaller, single-purpose
visitors, and composes them together.
* fix: improve validation for ImportAlias and Try statements
For `Try` statements we ensure that the bare except, if present, is at the last position.
For ImportAlias we ensure that the imported name is valid.
Fixes#287
* Apply suggestions from code review
Add missing periods.
* Apply suggestions from code review
Add missing periods.
* Update libcst/_nodes/tests/test_import.py
Co-authored-by: jimmylai <yurinai@gmail.com>