Commit graph

661 commits

Author SHA1 Message Date
Zsolt Dollenstein
10d6451067
bump version to 0.3.12 (#398) 2020-10-01 15:49:02 +01:00
Zsolt Dollenstein
1d22a29d18
fix RemoveImportsVisitor crash when ImportAlias is inserted without comma (#397)
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.
2020-10-01 10:50:04 +01:00
Caleb Donovick
34c1826c18
Provide STORE for {Class,Function}Def.name in ExpressionContextProvider (#394)
* 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>
2020-09-29 09:45:50 -07:00
Zsolt Dollenstein
efe0fdbf31
bump version to 0.3.11 (#395) 2020-09-28 09:28:07 -07:00
Zsolt Dollenstein
0a4d1e4985
Removing an import alias with a trailing standalone comment should preserve the comment (#392)
* failing test case

* implement fix

* fix linters
2020-09-24 14:31:39 -07:00
Batuhan Taskaya
6ae25834bb
Implement TypeOf matcher (#384)
* Implement TypeOf matcher

* Satisfy the type checker

* Expand the test case

* Fix the annotation of _raw_options

* Add documentation...
2020-09-10 11:09:59 -07:00
Jimmy Lai
6a02e2e995
[CI] add Fixit to tox -e lint (#386) 2020-09-09 17:33:49 -07:00
Jimmy Lai
3e63f914e5
[README] update Codecov badge (#382) 2020-09-06 09:29:12 +01:00
Jimmy Lai
7ca738bf39
Upgrade dev tools (Black/Flake8/isort) and read install requirements from requirements.txt (#380)
* 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
2020-08-31 10:44:55 -07:00
Jimmy Lai
748ae71909
[docs] add source code links to each class/function (#378) 2020-08-20 17:15:21 -07:00
Jimmy Lai
dc6e7ba6f7
[metadata] update return type of ParentNodeProvider to be CSTNode (#377) 2020-08-17 15:09:13 -07:00
Germán Méndez Bravo
6f9a12c538
Bump to version 0.3.10 (#376)
(cherry picked from commit aa1f7ced5d55ff059868964f26e0621a7afd5332)
2020-08-17 10:58:14 -07:00
Germán Méndez Bravo
6f915ab39b
Literal could be imported from typing_extensions too (#375)
Co-authored-by: Germán Méndez Bravo <kronuz@fb.com>
2020-08-14 15:32:12 -07:00
Germán Méndez Bravo
825931acd6
Fix test_annotation_access test case. (#374)
Co-authored-by: Germán Méndez Bravo <kronuz@fb.com>
2020-08-14 15:25:59 -07:00
Germán Méndez Bravo
c935fcb5ab
Merge pull request #373 from Instagram/annotation-access
Handle string annotations in ScopeProvider
2020-08-14 15:03:35 -07:00
Germán Méndez Bravo
fa15c980ef Handle string annotations in ScopeProvider 2020-08-14 14:59:22 -07:00
Germán Méndez Bravo
eda30f4e6f
Merge pull request #370 from Instagram/gather-exports
Handle more cases for __all__
2020-08-14 12:48:25 -07:00
Germán Méndez Bravo
d948a60e84 Handle more cases for __all__
(cherry picked from commit 95c7a5d5c50c72b835e10e49b7d5a0af327b7278)
2020-08-14 12:00:53 -07:00
Germán Méndez Bravo
81136d27f0
Merge pull request #372 from Instagram/annotation-access
Annotation access
2020-08-14 11:55:10 -07:00
Zsolt Dollenstein
cee0cc4b78
replace matchers with explicit visitation in gatherers (#366) 2020-08-14 18:43:41 +01:00
Germán Méndez Bravo
85761b2582 Add is_annotation subtype for Access inreferences.
Access references with this type come from an annotation.

(cherry picked from commit 39427eaabce9dff949ccc3545fc4a5d7a2d10930)
2020-08-14 08:22:48 -07:00
Sebastian Kreft
e43ef3e204
fix: SaveMachedNode now matches with trailing empty wildcards (#356)
* 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
2020-08-13 21:19:14 -07:00
Sebastian Kreft
3ada79ebcb
fix: correctly extract wildcard matchers (#355)
* fix: correctly extract wildcard matchers

Fixes #337 and #338

* refactor: use data classes instead of bare tuples
2020-08-13 18:50:36 -07:00
Shannon Zhu
0c09c9dfbb
Call pyre query with noninteractive logging (#371)
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.
2020-08-13 16:52:02 +01:00
Sebastian Kreft
b4e04eae63
fix: spaces around walrus operator are not required (#368)
Fixes #367
2020-08-12 14:55:11 +01:00
Tim Hatch
771d5e14b7
Include missing test data in install (#365) 2020-08-11 17:44:16 -07:00
Germán Méndez Bravo
867f85e164
Merge pull request #364 from Kronuz/Kronuz-patch-version
Bump to version 0.3.9
2020-08-07 11:37:18 -07:00
Germán Méndez Bravo
27be9b1417
Merge pull request #363 from Kronuz/Kronuz-patch-pyre-2
Fix pyre error: kwonlydefaults is Optional
2020-08-07 11:34:37 -07:00
Germán Méndez Bravo
7fdae6ce6d Bump to version 0.3.9 2020-08-07 11:29:33 -07:00
Germán Méndez Bravo
b4032a3232 Fix pyre error: kwonlydefaults is Optional 2020-08-07 11:15:21 -07:00
Germán Méndez Bravo
120123fab6
Merge pull request #362 from Instagram/Kronuz-patch-variable_pollution
Fix enclosing attribute for attributes in call arguments
2020-08-07 08:31:45 -07:00
Germán Méndez Bravo
3e66bdd957 Fix enclosing attribute for attributes in call arguments
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.
2020-08-07 08:17:08 -07:00
Jimmy Lai
2e788a25dc
[doc] use cst node in ensure_type in best practice doc (#361) 2020-08-05 12:57:37 -07:00
Germán Méndez Bravo
17bde3b3aa
Fix pyre syntax error in tokenizer stub (#360)
## 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>
2020-08-04 17:33:55 -07:00
Germán Méndez Bravo
2e8a0c6df7
Fix dotted names (#358)
## 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>
2020-08-04 17:33:22 -07:00
Germán Méndez Bravo
ffc4c93c82
Fix syntax error in .pyre_configuration.example (#359)
Missing a comma
2020-08-04 16:42:52 -07:00
Jimmy Lai
afdf74694b
Add tox to requirements-dev.txt and fixed a typo in README (#357) 2020-08-04 14:44:26 -07:00
Zsolt Dollenstein
6a5e7394c0
[RemoveUnusedImports] Support string type annotations (#353)
* [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.
2020-07-31 15:54:39 +01:00
Hồ Đức Hiếu
f8fdc00aeb
Update README.rst (#351)
* Update README.rst

Add href link of MIT licensed

* Update README.rst

* Update README.rst

Co-authored-by: Jimmy Lai <yurinai@gmail.com>
2020-07-28 12:05:55 -07:00
Jimmy Lai
eb761c2c67
[scope] add scope for ImportAlias (#350) 2020-07-28 08:58:59 -07:00
jimmylai
0870e41a79
[scope] add scope for ClassDef.name node (#349)
Co-authored-by: Jimmy Lai <jimmylai@fb.com>
2020-07-24 11:25:09 -07:00
luciawlli
857fcc7bd8
Merge pull request #348 from Instagram/luciali_release
[release] Bump LibCST to new release 0.3.8
2020-07-22 17:04:19 -07:00
Lucia Li
cf51c73c09 [release] Bump LibCST to new release 0.3.8 2020-07-22 16:33:38 -07:00
Sebastian Kreft
a9177e27bc
fix: allow ParenthesizedWhitespace before params in FuncDef (#342)
* fix: allow ParenthesizedWhitespace before params in FuncDef

Fixes #303

* fix: run codegen
2020-07-15 12:59:38 -07:00
Sebastian Kreft
f36eacb132
fix: improve validation for ImportAlias and Try statements (#340)
* 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>
2020-07-13 19:32:33 -07:00
jimmylai
7208012c98
insert imports after module docstring (#343)
Co-authored-by: Jimmy Lai <jimmylai@fb.com>
2020-07-13 19:16:09 -07:00
Maggie Moss
7219efcd3f
[Pyre] Handle type subscripts when applying annotations. (#335)
* [Pyre] Handle type subscripts when applying annotations.

* Fix lint.

* Use matchers syntax instead of isinstance
2020-07-13 17:31:48 -07:00
Zsolt Dollenstein
9d3bb11eb8
Only remove trailing comma if the last alias is removed (#334) 2020-07-09 16:37:56 +01:00
Josie Eshkenazi
8523852d05
FullRepoManager cache property (#330)
Add public cache property to FullRepoManager
2020-07-06 11:15:50 -04:00
Josie Eshkenazi
6a5f71c6b4
Optional args for tox commands (#327) 2020-06-30 15:40:46 -04:00