Commit graph

1099 commits

Author SHA1 Message Date
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
jimmylai
3a7ffafe45
Fix NotEqual position issue (#325)
Co-authored-by: Jimmy Lai <jimmylai@fb.com>
2020-06-29 07:54:32 -07:00
lrjball
2d56ba7a3e
Minor typo in scope_provider.py (#324)
Fixed minor typo ('as'  was repeated)
2020-06-28 17:15:19 -07:00
Josie Eshkenazi
4a928b0e94
Bump to version 0.3.7 (#321) 2020-06-25 11:47:45 -04:00
Josie Eshkenazi
030df0625c
Add codemod RenameCommand (#308)
Add codemod RenameCommand which renames all instances of a local or imported object.
2020-06-25 11:13:35 -04:00
Zsolt Dollenstein
73608adbdb
[ExpressionContextProvider] Make subscript values always have a LOAD context (#319)
Fixes #318.
2020-06-18 08:31:22 -07:00
Shantanu
5992a7d83d
ApplyTypeAnnotationsVisitor: fix default value of keyword only and positional-only args (#314)
* ApplyTypeAnnotationsVisitor: fix default values of keyword only args

* ApplyTypeAnnotationsVisitor: fix default values of positional-only args

Co-authored-by: hauntsaninja <>
2020-06-16 06:58:40 -07:00
jimmylai
c023fa7c4c
[typing] enable Pyre strict mode by default (#313)
Co-authored-by: Jimmy Lai <jimmylai@fb.com>
2020-06-12 18:24:18 -07:00
Josie Eshkenazi
cc7bb9db14
Add maxsplit value in QualifiedName retrieval (#312)
Maxsplit value to account for repeated letters in a QualifiedName
2020-06-11 12:04:10 -04:00
Tim Hatch
dbcb5bed99
Improve default-version selection logic (#306)
* Add Python 3.9 to tox envlist

* Require newer typing_extensions for 3.9

For simplicity, use the new version in all cases.

* Improve default-version selection to work on 3.9

While were at it, improve the code to work with a likely 3.10 by
allowing multiple digits for minor version.
2020-06-10 10:29:58 -07:00
Josie Eshkenazi
228589faa0
Fix stdout being plugged into codemod-ed file (#309) 2020-06-10 12:46:35 -04:00
jimmylai
dcdb04660f
Upgrade Codecov to 2.1.4 (#311) 2020-06-10 09:07:57 -07:00
Josie Eshkenazi
ed1a2ad4d1
Add fb open source required links (#307)
Links to Privacy Policy and Terms of Use in README.rst and docs/index
2020-06-04 14:27:54 -04:00