Commit graph

1099 commits

Author SHA1 Message Date
Jennifer Taylor
27b5a1d286 Improve removing nodes from parents in LibCST.
Add a RemoveFromParent() function as a convenience to returning RemovalSentinel.REMOVE.
Introduce a `deep_remove()` on CSTNode analogous to `deep_replace()` but for removing.
2019-10-02 15:43:48 -07:00
Jennifer Taylor
2383bea74b Export ProviderT so it can be used to type METADATA_DEPENDENCIES. 2019-10-02 15:15:18 -07:00
Jennifer Taylor
9fa2612673 Implement deep_replace helper on CSTNode. 2019-10-02 14:00:20 -07:00
Jimmy Lai
7b96b070ca Organize document menu as three parts: introduction, tutorial and reference 2019-10-02 12:26:35 -07:00
Jennifer Taylor
32037efab9 Add a tutorial for matchers. 2019-10-01 15:28:58 -07:00
Jennifer Taylor
e8c19a983c Fix issue with matchers that combine both @call and @visit decorators. 2019-10-01 15:28:58 -07:00
Jennifer Taylor
90ec997687 Fix warning in docs creation relating to scope provider. 2019-10-01 15:28:58 -07:00
Jennifer Taylor
e2868f703b Add documentation to matchers. 2019-10-01 15:28:58 -07:00
Jennifer Taylor
271566bdbf Add a .remove() method to CSTNode as a convenience to returning RemovalSentinel.REMOVE 2019-10-01 15:28:58 -07:00
Jimmy Lai
1488126df5 fix import asname support in get_qualified_names_for and add tests/docs 2019-10-01 14:24:20 -07:00
Jimmy Lai
826765bd93 add QualifiedNameProvider 2019-10-01 14:24:20 -07:00
Jimmy Lai
0948108dce add binder link to notebook tutorial page 2019-10-01 13:41:29 -07:00
Jimmy Lai
cd25f15ff7 consolidate metadata imports 2019-10-01 13:40:24 -07:00
Jimmy Lai
fc2d8f8697 avoid redefine builtin function range 2019-09-30 14:38:25 -07:00
Jimmy Lai
9945a9b970 merge isinstance calls to be more simple and fast 2019-09-30 14:38:25 -07:00
Jimmy Lai
6680c2d05f add nested function/class test cases and documents to Qualified Name Metadata 2019-09-30 12:03:19 -07:00
Jimmy Lai
1bdce26bf3 add QualifiedNameSource.BUILTIN and address review comments 2019-09-30 12:03:19 -07:00
Jimmy Lai
50b3c61794 add docs of get_qualified_names_for 2019-09-30 12:03:19 -07:00
Jimmy Lai
9fcf84cf2c add QualifiedName and QualifiedNameSource enum 2019-09-30 12:03:19 -07:00
Jimmy Lai
881348df27 add get_fully_qualified_names_for tests for subscript and SimpleString typing 2019-09-30 12:03:19 -07:00
Jimmy Lai
e24ca294b6 use LocalScope in ScopeVisitor._new_scope to simplify typing 2019-09-30 12:03:19 -07:00
Jimmy Lai
894a0f7424 add local assignment (non-import assignment) supports to get_fully_qualified_names_for 2019-09-30 12:03:19 -07:00
Jimmy Lai
3123691788 add helper Scope.get_fully_qualified_names_for 2019-09-30 12:03:19 -07:00
jimmylai
4ad2139c8c Add metadata provider to future in README. 2019-09-27 13:55:26 -07:00
Jennifer Taylor
dd99a424dc Add future section, based on questions received. 2019-09-27 13:55:26 -07:00
Jennifer Taylor
42760505bf Clarify LibCST license.
Make explicit in the LICENSE and README files the exact files that are not licensed under MIT since being forked. These files already have license information in their headers, but it is always good to be explicit at the top level as well. Also include a copy of the licenses in the LICENSE file to conform with requirements.
2019-09-27 13:55:26 -07:00
Jennifer Taylor
85417b957d Initial export of matchers into LibCST. 2019-09-27 11:39:11 -07:00
Jimmy Lai
f2303cecd3 remove accidentally committed files. 2019-09-26 17:39:16 -07:00
Jimmy Lai
4cde536678 add more test cases to ParentNodeProviderTest 2019-09-26 17:39:16 -07:00
Jimmy Lai
db6092dffd add docs of ParentNodeProvider 2019-09-26 17:39:16 -07:00
Jimmy Lai
132549db56 add parent node metadata provider 2019-09-26 17:39:16 -07:00
Jimmy Lai
643acd7771 remove redundant constructor 2019-09-26 17:39:16 -07:00
Jennifer Taylor
1d483ef787 Fix deep_clone behavior regarding BaseLeaf nodes.
We used _visit_and_replace_children to implement deep_clone, which was already
bad since it relied on the implicit behavior of _visit_and_replace_children to
make a copy on visit. If we fix that behavior in the future, deep_Clone would
have broken. However, its even more broken, because nodes that subclass from
BaseLeaf define their _visit_and_replace_children as returning self. So, not
only is this a bad coupling, but its also broken. Implement deep_clone properly
here.
2019-09-25 12:36:33 -07:00
Jennifer Taylor
de1db7f0f6 Add a test to verify that deep_clone works. 2019-09-25 12:36:33 -07:00
Jennifer Taylor
93ed095c9e Fix non-unique tree generated by LibCST in some circumstances.
When parsing, we don't always fill in defaults unless we have a good reason to. That, coupled with the fact that we use dataclasses that allow you to set a default on creation instead of runtime construction means that we accidentally aliased a whole bunch of SimpleWhitespace nodes. Fix that by switching to the datalasses field() method which allows runtime evaluation. We do this by creating a simple (untyped, unfortunately) helper on CSTNode which makes for easier creation.
2019-09-25 12:36:33 -07:00
Jennifer Taylor
a6bdc9d03d Add test case for uniqueness of resulting tree when parsing. 2019-09-25 12:36:33 -07:00
Jennifer Taylor
1a1d1cfd11 Fix prompt-toolkit version discrepancy somehow uncovered by pyre upgrade. 2019-09-25 12:04:33 -07:00
Jennifer Taylor
fb4785cfa1 Bump pyre version to 0.0.30.
This introduces a few new gotchas (namely attribute access and a bug with
Union[Callable]), but it also removes a whole host of pyre-fixmes and gets us
updated to a release of pyre that came out after May.
2019-09-25 12:04:33 -07:00
Jennifer Taylor
3f5dc1e632 Bump version to 0.1.3. 2019-09-18 16:51:32 -07:00
Mark Vismonte
a4b0527457 Add type to init in tutorial 2019-09-18 13:44:50 -07:00
Jennifer Taylor
fc430343b5 Fix internal underscore convention.
Standardize on the convention that private modules (those we don't expect people to directly import) are prefixed with an underscore. Everything under a directory/module that has an underscore is considered private, unless it is re-exported from a non-underscored module. Most things are exported from libcst directly, but there are a few things in libcst.tool, libcst.codegen and libcst.metadata that are namedspaced as such.
2019-09-17 13:52:42 -07:00
Jimmy Lai
21e155e0aa [doc] use png file and fix typo 2019-09-16 19:53:22 -07:00
Jimmy Lai
02a831ff27 [doc] fix some typos and add simple Scope Provider introduction 2019-09-16 19:53:22 -07:00
Jimmy Lai
b4851a60a1 [doc] add scope introduction and examples 2019-09-16 19:53:22 -07:00
Jimmy Lai
ec68bdb147 update import paths in Jupyter notebook 2019-09-16 19:53:22 -07:00
Jimmy Lai
213b335cd5 move metadata providers its data structures to libcst.metadata 2019-09-16 19:53:22 -07:00
Jimmy Lai
d55a8bc060 update author in Sphinx conf.py 2019-09-16 19:53:22 -07:00
Jimmy Lai
612cbb0a9e add docstring to ScopeProvider 2019-09-16 19:53:22 -07:00
Jimmy Lai
966ab81a36 add ScopeProvider document 2019-09-16 19:53:22 -07:00
Jennifer Taylor
dcf27644b5 Add support for Python 3.5
There were only grammar changes between 3.5 and 3.6, which are pretty trivial to put in. So, do that trivial bit and get us completely covered for production Python 3 versions. This could use better testing, but it is good enough as-is and we can address issues with GitHub's issue tracker.
2019-09-16 15:57:59 -07:00