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

Merged
merged 42 commits into from Jun 23, 2020
Merged

Google sync #607

merged 42 commits into from Jun 23, 2020

Conversation

rchen152
Copy link
Contributor

No description provided.

martindemello and others added 30 commits June 23, 2020 14:13
…to self.

This fixes false positives when we mutate a container with multiple annotated
types, e.g.

  def foo(l1: List[int], l2: List[str], b):
    if b:
      x = l1
      y = 3
    else:
      x = l2
      y = "foo"
    x.append(y)

PiperOrigin-RevId: 316177667
I was playing around with this new feature and noticed a couple of bugs:
* An element type that is annotated as Any should stay as Any.
* from_annotation needed to be set in a couple of additional places.

PiperOrigin-RevId: 316208219
PiperOrigin-RevId: 316504732
PiperOrigin-RevId: 316507034
See b/159041279 for a bit more about this.

PiperOrigin-RevId: 316514137
PiperOrigin-RevId: 316514740
* Removes obsolete and not directly actionable TODOs.
* Resolves a TODO for memoizing a method.
* Converts other TODOs from TODO(person) to TODO(bug).

PiperOrigin-RevId: 316515198
There's no need to raise an error here.

PiperOrigin-RevId: 316515728
* Adds a bug for one TODO.
* Removes another and leaves an informational comment instead.

PiperOrigin-RevId: 316518934
Removed several TODOs as being obsolete, or overly complicated for the
benefit they would provide.

Converted some TODOs to bugs or comments in the code:
- matcher.py
- CMakeLists.txt
- mixin.py

PiperOrigin-RevId: 316526842
* Implementing the node TODO led to failing tests, so I removed it.
* I couldn't figure out what "Record these:" meant.
* Removed the TODO for aliases and instead documented how they're handled.

PiperOrigin-RevId: 316528462
PiperOrigin-RevId: 316530837
Also fixes a linter error.

PiperOrigin-RevId: 316533249
PiperOrigin-RevId: 316535617
These are by-and-large small cleanups, so a single bug suffices.

PiperOrigin-RevId: 316539007
PiperOrigin-RevId: 316547125
PiperOrigin-RevId: 316547257
PiperOrigin-RevId: 316549161
"pivot" seems like a reasonable name to me.

PiperOrigin-RevId: 316557183
PiperOrigin-RevId: 316559066
PiperOrigin-RevId: 316561475
I resolved a TODO to keep only one copy of pytd/typeshed_test and
pyi/parse_typeshed_test by deleting the latter. Based on the file history,
pytd/typeshed_test is the one that is actively maintained.

I removed all the other TODOs as likely not worth doing, especially since we
want to eventually replace this parser.

PiperOrigin-RevId: 316565341
PiperOrigin-RevId: 316565368
PiperOrigin-RevId: 316578011
PiperOrigin-RevId: 316578057
Also added two relatively complex examples under bugs/ and suppressed the warning for the unused "dep" import because it's annoying to have to remember to readd it every time i want to test a bug with a dependency.

PiperOrigin-RevId: 316593129
PiperOrigin-RevId: 316729481
Solumin and others added 12 commits June 23, 2020 14:54
PiperOrigin-RevId: 316742617
PiperOrigin-RevId: 316751830
* Makes the annotation always take precedence over any inferred type in stubs.
* Stores annotations that are declared on instance attributes. This allows
  type-checking against annotations declared in __init__ or __new__.

PiperOrigin-RevId: 316777060
PiperOrigin-RevId: 317002471
Imported names now only create a binding if they are aliased. The alias has
subkind import and is connected to imported name (not its definition!) via
*aliases* edge. The imported name is connected to the corresponding definition
via *ref/imports* edge.

See testdata/imports.py for an example.

Note that from-imports are currently restricted to submodules, importing
anything else e.g.

  from sys import version

does not produce a ref.

Another limitation has to do with subpackages, both

  import foo.bar.boo

and

  from foo.bar import boo

do not produce refs for neither foo nor foo.bar.

PiperOrigin-RevId: 317156912
For example

  from sys import path

will now correctly reference sys.path.

PiperOrigin-RevId: 317157234
For now, this feature is hidden behind yet another flag,
--check-parameter-types.

I also did a bit of cleanup: removed an unnecessary lint version directive and
extraneous arguments to a super() call, fixed a method signature so it matched
the superclass signature, and changed a check for the existence of annotations
to a more precise check for the existence of parameter annotations.

PiperOrigin-RevId: 317216325
This is a little different from what b/113372317 asks for but in the same
spirit: if you don't allow `def f(x: int = 0.0): ...`, why would you allow
`def f(x: int): x = 0.0`? Plus, now that we're enforcing annotations strictly
everywhere else, it would be confusing to be lenient here.
PiperOrigin-RevId: 317218197
#604)

This allows `any()` to return early without needing to iterate over the entire list.

Resolves #604

PiperOrigin-RevId: 317701319
This adds the possibility to autodetect the number of jobs based on the number of available CPU cores on the host system using `pytype --jobs auto`. This allows for a usage similar to [`pytest-xdist`](https://github.com/pytest-dev/pytest-xdist#speed-up-test-runs-by-sending-tests-to-multiple-cpus) which can be useful when using `pytype` in scripts that might run on different systems.

Resolves #605

PiperOrigin-RevId: 317924811
PiperOrigin-RevId: 317925038
@rchen152 rchen152 merged commit 7f6df73 into master Jun 23, 2020
@rchen152 rchen152 deleted the google_sync branch June 23, 2020 22:25
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

6 participants