Skip to content
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 27 commits into from
Apr 4, 2024
Merged

Google sync #1610

merged 27 commits into from
Apr 4, 2024

Conversation

rchen152
Copy link
Contributor

@rchen152 rchen152 commented Apr 3, 2024

No description provided.

rchen152 and others added 27 commits April 3, 2024 15:06
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
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
* 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
… 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
For #499. Together with
#1608, this should fix the issue.

PiperOrigin-RevId: 621638737
Fixes #1609.

PiperOrigin-RevId: 621642379
@rchen152 rchen152 merged commit dac9453 into main Apr 4, 2024
22 checks passed
@rchen152 rchen152 deleted the google_sync branch April 4, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants