Commit graph

325 commits

Author SHA1 Message Date
Jimmy Lai
94fe0bfa3f handle ComprehensionScope in QualifiedName 2019-10-11 12:37:50 -07:00
Jennifer Taylor
ba471909c4 Generalize codegen cleanup step and apply it to all codegen.
I noticed that the typed visitors codegen was creating messy types such as Union[SingleType]. We have a clean-up for Union[SingleType] snuck into gen_matcher_classes. So, lets remove that snuck-in clean-up from gen_matcher_classes and apply it globally to all codegen. This makes its purpose a lot more obvious, while helping decouple necessary codegen from prettifying/simplifying transforms. It also cleans up typed visitors, so that's a bonus.
2019-10-11 12:29:23 -07:00
Jennifer Taylor
76dbfd65b9 Explicitly define hash and equality for matchers.
This makes matcher equality and hash equivalent to the way LibCST nodes behave. Not only does this make us more consistent, but it also fixes a bug where matcher decorators could not be used with a matcher that initialized a sequence type as a list.
2019-10-11 11:46:06 -07:00
Jennifer Taylor
bad27b68a2 Enforce immutability with special matchers. 2019-10-11 11:46:06 -07:00
Benjamin Woodruff
194a930f64 Make BaseMetadataProvider[T] covariant over T
Because we'd consider `BaseMetadataProvider[int]` to be a subtype of
`BaseMetadataProvider[object]`, it should be covariant over its
typevar, rather than invariant.

This isn't entirely correct because we have a mutable data structure
(`_computed`) that depends on the typevar, and pyre points this out
(though with a really confusing error message). However, it's not
correct to say that `BaseMetadataProvider` is invariant either, so I
think this is the lesser evil.

I don't think it's practical to redesign this API to avoid the variance
issue, so I'm ignoring the new type error that results from this change.

I think this may resolve some of the issues we've seen internally with
D17820032.
2019-10-10 18:08:44 -07:00
Jennifer Taylor
435ffc4bca Clean up on-call specification leftover from open-sourcing. 2019-10-10 18:07:14 -07:00
Jennifer Taylor
ba64cb9d4e Remove useless internal-only noqa. 2019-10-09 21:51:56 -07:00
Jennifer Taylor
4948c6a5f5 Add missing license header to matchers generator file. 2019-10-09 21:51:56 -07:00
Jimmy Lai
3965e4601b [doc] add docstring to QualifiedName 2019-10-09 11:32:08 -07:00
Jimmy Lai
5f8f5c5624 address review feedback form #94 2019-10-08 15:48:59 -07:00
Jimmy Lai
b690c591e5 [doc] add Scope Analysis tutorial 2019-10-08 15:48:59 -07:00
Jimmy Lai
9e7a9879ea [doc] fix expression context usage in scope api and explain access don't handle simple string typing access 2019-10-08 15:48:59 -07:00
Jimmy Lai
dea7c20794 add warning box to clarify Scope metadata only handles local variable 2019-10-08 15:48:59 -07:00
Jimmy Lai
9f8e69b1b3 [doc] use libcst.metadata for referencing metadata classes and add docstring for Scope magic functions 2019-10-08 15:48:59 -07:00
Jimmy Lai
c9dc3bfa70 address review feedback in #94 2019-10-08 15:48:59 -07:00
Jimmy Lai
13637b7d58 add docs for Assignments and Accesses 2019-10-08 15:48:59 -07:00
Jimmy Lai
855232e24f test Access.referents and Assignment.references 2019-10-08 15:48:59 -07:00
Jimmy Lai
65cc4d23bd add test case for Assignments and Accesses 2019-10-08 15:48:59 -07:00
Jimmy Lai
392426d6bd add Scope.record_access and Access.record_assignment 2019-10-08 15:48:59 -07:00
Jimmy Lai
ee14c48e46 add Scope.assignments and Scope.accesses 2019-10-08 15:48:59 -07:00
Jimmy Lai
7a2d0048c7 add deprecation message to Assignment.accesses 2019-10-08 15:48:59 -07:00
Jimmy Lai
120fd04ce2 rename Assignment.accesses as Assignment.references and add Accesses/Assignments 2019-10-08 15:48:59 -07:00
Christopher Hunt
6520d25816 Fix visitor helper function name pattern in docs 2019-10-04 21:40:52 -07:00
Jimmy Lai
c92bc02d8c rewrite ExpressionContextProvider to handle nested List/Tuple and Attribute 2019-10-04 15:16:55 -07:00
Jennifer Taylor
08b6657db2 Bump version to 0.2.0, update changelog. 2019-10-04 13:13:30 -07:00
Jennifer Taylor
8a8ea4b27b Upgrade Pyre to 0.32.
This fixes a TODO, removes several ignore statements and most importantly, addresses a massive speed regression triggered by importing matchers.
2019-10-04 11:05:37 -07:00
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