-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Google sync #1610
Merged
Merged
Google sync #1610
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I realized that I'd like to use assert_type in tests =) This also gives us a chance to see what creating overlays will be like. So far, it looks more pleasant than the current iteration. A follow-up change will add error logging. PiperOrigin-RevId: 619624704
This differs from the current context in a few ways that I hope will make it easier to work with: * Everywhere it's passed around, it's the first argument, not the last, so that we don't have a required ctx getting in the way of adding default values to parameters. * The _ctx attribute is private, to make the anti-pattern of grabbing it off a random object easier to spot and avoid. * abstract provides a ContextType protocol so that we don't lose all typing. PiperOrigin-RevId: 619711085
Minor cosmetic changes to make the code easier to read: * Remove `ctx.root_node` from calls where it is the default value * Add a kwargs dict for recursive calls to `constant_to_var` * Likewise, add an inner function to elide some calls to `constant_to_value` from `constant_to_var` * Add some helpers and aliases to get lines below 80 characters or reduce repetitive boilerplate PiperOrigin-RevId: 619715903
Adds a `convert.pytd_cls_to_instance_var` to convert a class to an abstract instance directly, rather than wrap it and then immediately unwrap it in `constant_to_var`. PiperOrigin-RevId: 619720198
* abstract.BaseValue and rewrite.abstract.BaseValue had different names for the instance->pytd method (to_pytd_instance() vs to_pytd_instance_type()). I decided that I didn't particularly like either, since they both suggest that the method creates a "pytd instance," whatever that would be, so I renamed the method to to_pytd_type_of_instance(). * Removes all attributes from types.BaseValue except to_pytd_type_of_instance. The ctx can be saved on the pretty printer instead, and all of the other attributes were used in a single pretty printer method, print_as_expected_type. print_as_expected_type is closely coupled with the implementation details of abstract/ anyway, so I changed it to assume that it was receiving an abstract.BaseValue instead of a types.BaseValue. PiperOrigin-RevId: 619745053
The converter has `self.ctx`, we do not need to pass one in. PiperOrigin-RevId: 619783308
PiperOrigin-RevId: 619793368
Separates out methods for primitive and pytd constants. and pulls out a few helper functions to make the code a little more readable. PiperOrigin-RevId: 619802920
* Adds some pytd->abstract conversion methods, with dummy implementations. * Renames abstract.BaseClass to abstract.SimpleClass. I'll first try converting pytd classes to SimpleClasses (no lazy loading). We can add a PyTDClass later if the performance hit is too dire. * Adds an abstract.PyTDFunction class with a dummy implementation of call_with_mapped_args. * Moves PythonConstant from base.py to classes.py so it can subclass BaseInstance. * Uses the real context.Context in abstract tests. Keeping a separate FakeContext was quickly proving to be too painful. PiperOrigin-RevId: 620063057
This bug is preventing us from updating typeshed. PiperOrigin-RevId: 620076790
…[X]`. PiperOrigin-RevId: 620301169
Also adds `rewrite.abstract.internal` for internal datatypes that get stored on the VM stack. PiperOrigin-RevId: 620303642
* Fixes a crash caused by not being able to find a base class in the MRO. * Takes the "self" annotation into account when looking for the class that defined a particular signature. PiperOrigin-RevId: 620314819
* Adds a barebones implementatation of pytd_type_to_value that handles the most common case (ClassType) and a couple of trivial cases, and raises NotImplementedError for everything else. * Moves abstract singletons into an abstract.Singletons dataclass. I went with 'singles' as the attribute name in the context because we're going to be using ctx.singles.Any everywhere and I wanted to keep it short. PiperOrigin-RevId: 620329505
* Adds a Signature.from_pytd constructor and uses it to implement pytd_function_to_value. * Finishes implementing Signature.__repr__ so we can test from_pytd. * Exposes errorlog.pretty_printer and renames some of the pretty printer methods. When I was using the pretty printer in Signature.__repr__, I realized that trying to remember what it meant to print "as an actual type" vs. "as an expected type" was making my head hurt. I changed the printer to follow a similar naming scheme to output.py (print_type, print_type_of_instance), which I find easier to understand. PiperOrigin-RevId: 620382246
PiperOrigin-RevId: 620386999
* Adds basic implementation of conversion from pytd.Class to abstract.SimpleClass. * Adds a convert cache so that we don't run into infinite recursion when converting class members that refer back to the class. * Adds BaseValue.instantiate() and Union.instantiate(). PiperOrigin-RevId: 621000655
Adds LIST_APPEND, SET_ADD and MAP_ADD, internal opcodes that add a single element to an accumulator when compiling a comprehension. PiperOrigin-RevId: 621279498
PiperOrigin-RevId: 621301149
… of unused imports info file from `--imports_info=`. This list can be useful for build systems like Bazel to improve incremental build performance. PiperOrigin-RevId: 621318067
Also groups the opcodes in frame.py into logical sections. PiperOrigin-RevId: 621332384
* Adds a new load_abstract.AbstractLoader class and moves the pieces of convert.py that don't deal directly with pytd->abstract conversion into the new class. * Refactors the code around the context a bit to pass through the options and (pytd) loader from analyze.py. PiperOrigin-RevId: 621335728
Fixes #1609. PiperOrigin-RevId: 621642379
PiperOrigin-RevId: 621643011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.