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 #1040

Merged
merged 14 commits into from Nov 2, 2021
Merged

Google sync #1040

merged 14 commits into from Nov 2, 2021

Conversation

rchen152
Copy link
Contributor

@rchen152 rchen152 commented Nov 2, 2021

No description provided.

martindemello and others added 14 commits November 2, 2021 14:23
Allows setting up a dependency tree before checking a file. Python files in the
dependency tree are analysed in order, and the corresponding pyi files
generated. The pythonpath for all files is set to the root of the dependency tree.

Also converts one test file as a more extended test of the new functionality.

PiperOrigin-RevId: 406256121
Error.message contains Error._message, _details, and _traceback combined.
So copy_from() passing in one error's message attribute as another's _message
attribute caused a lot of information to be duplicated.

PiperOrigin-RevId: 406272568
The skip in overlays/typing_overlay.py was only needed until the
typed_ast-based pyi parser went live, which happened months ago.

Once a type annotation is added to the long list in pytd/slots.py, pytype
analysis completes in a negligible amount of time.

PiperOrigin-RevId: 406371373
Such aliases aren't currently common enough for this to be a problem, but an
upcoming bug fix that adds a bunch of aliases exposes these issues:
* In LateType resolution, we need to first check if the entire late type is a
  module name before assuming it's a module attribute.
* convert._create_module needs to strip only the module prefix; taking off
  everything before the last dotted part is wrong for nested classes.
* The pyi parser shouldn't allow imports like 'from x import typing' to change
  the meaning of 'from typing import ...'.
* The pyi parser was rewriting __builtin__ to builtins too aggressively; we
  only want to get rid of imports like "import __builtin__"; lines like "import
  builtins as __builtin__" should not be changed.
* The pytd printer needs to handle the case when it is passed a partially
  resolved ast in which modules are still represented as NamedType, not Module.
* Also in the pytd printer, we were accidentally outputting "from x import y as
  y" when we meant to just output "from x import y".
* serialize_ast needs to undo the pytd printer's application of module aliases.
  (It would be better if serialize_ast could just use the existing ast rather
  than printing and reparsing it, but fixing that is a much bigger endeavor.)

PiperOrigin-RevId: 406413484
…g check.

We have some logic that checks whether a TypeVar rename is ok, but it would
emit [not-supported-yet] when trying to compare two bounded/constrained
TypeVars against each other. The matcher is able to handle this case now, so do
the comparison instead of complaining.

PiperOrigin-RevId: 406424691
pytype/pyi:parser_test is still timing out. It seems to be a single test in
particular that's very slow, so pulling that test out into its own file to
ensure that nothing else gets put into the same shard as it seems to work.

PiperOrigin-RevId: 406433991
The vm subclass now lives in tracer_vm.py, not analyze.py.

PiperOrigin-RevId: 406867564
This kicks in whenever an enum class has its own `__init__` or `__new__` that adds attributes to members, and that enum is used in an annotation or other context that causes a canonical member to be created.

PiperOrigin-RevId: 406868258
* Recognize LateTypes as modules in the pytd printer. Otherwise, it's
  inconsistent whether an aliased import gets printed as an import or an alias.
* Also in the pytd printer, add a heuristic for figuring out which prefix of a
  dotted NamedType is the module name. If we don't do this, we generate illegal
  imports containing class names for pb2 nested classes.
* Fix a bug where pytype crashed on an empty Awaitable type. Improving pyi
  output exposes this bug by precisely typing code in which types were
  previously all Any.

PiperOrigin-RevId: 406869267
Currently, pytype adds "x: module" constants to pyi files, and all attributes
on builtins.module are typed as Any, so accessing whatever_module.x.attribute
always produces Any. This is fixed by instead adding "import x" statements and
changing the pyi parser to always generate aliases for import statements.

This is a very large change because of all the changes to test output and the
places we need to plumb through --gen-stub-imports so that the pyi parser sees
it. The actually interesting changes are in:
* pytype/output.py
* pytype/pyi/modules.py
* pytype/pytd/printer.py
* pytype/pytd/pytd_visitors.py

PiperOrigin-RevId: 406940492
This is to unblock python/typeshed#6221.
Also see #786.

PiperOrigin-RevId: 407168815
PiperOrigin-RevId: 407176581
@google-cla google-cla bot added the cla: yes label Nov 2, 2021
@rchen152 rchen152 merged commit 24e396b into master Nov 2, 2021
@rchen152 rchen152 deleted the google_sync branch November 2, 2021 22:04
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