From d477f91cbca6614fad3f8ae12f961df3e92519cb Mon Sep 17 00:00:00 2001 From: rechen Date: Fri, 26 Jun 2020 12:31:28 -0700 Subject: [PATCH] Do a PyPI release for a parser fix. For https://github.com/google/pytype/issues/608. I fixed a pyi parser issue about two weeks ago, and we need to do a release so that typeshed can use the fix. I don't feel confident releasing at head (too many findings to click through to check if there are any new crashes, obvious bugs, etc.), so what I plan to do is to temporarily roll back the change that generates the vast majority of the new findings, release on PyPI, and then reapply that change. PiperOrigin-RevId: 318522426 --- CHANGELOG | 6 ++++++ pytype/__version__.py | 2 +- pytype/analyze.py | 9 +-------- pytype/tests/test_classes.py | 2 ++ pytype/tests/test_cmp.py | 1 + pytype/vm.py | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index af0f5cd23..c35bf9d51 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +Version 2020.06.28 +* Treat objects as True in a boolean context, unless explicitly overridden. +* If cls is the class argument of Foo.__new__, treat `cls is Foo` as ambiguous. +* Add basic support for third-party flax dataclasses. +* Autodetect number of jobs with --jobs auto. + Version 2020.06.01 * Update typeshed pin to commit 5fe6a5b from May 18. * Support callback protocols. diff --git a/pytype/__version__.py b/pytype/__version__.py index 8086a7800..5887b4dcf 100644 --- a/pytype/__version__.py +++ b/pytype/__version__.py @@ -1,2 +1,2 @@ # pylint: skip-file -__version__ = '2020.06.01' +__version__ = '2020.06.26' diff --git a/pytype/analyze.py b/pytype/analyze.py index 43e2adb3a..72791fa62 100644 --- a/pytype/analyze.py +++ b/pytype/analyze.py @@ -12,7 +12,6 @@ from pytype import function from pytype import metrics from pytype import output -from pytype import special_builtins from pytype import state as frame_state from pytype import vm from pytype.overlays import typing_overlay @@ -176,8 +175,6 @@ def maybe_analyze_method(self, node, val, cls=None): else: for f in method.iter_signature_functions(): node, args = self.create_method_arguments(node, f) - if f.is_classmethod and cls: - args = self._maybe_fix_classmethod_cls_arg(node, cls, f, args) node, _ = self.call_function_with_args(node, val, args) return node @@ -230,11 +227,7 @@ def analyze_method_var(self, node0, name, var, cls=None): def bind_method(self, node, name, methodvar, instance_var): bound = self.program.NewVariable() for m in methodvar.Data(node): - if isinstance(m, special_builtins.ClassMethodInstance): - m = m.func.data[0] - is_cls = True - else: - is_cls = (m.isinstance_InterpreterFunction() and m.is_classmethod) + is_cls = False bound.AddBinding(m.property_get(instance_var, is_cls), [], node) return bound diff --git a/pytype/tests/test_classes.py b/pytype/tests/test_classes.py index 963eda595..d29036090 100644 --- a/pytype/tests/test_classes.py +++ b/pytype/tests/test_classes.py @@ -165,6 +165,7 @@ class Foo(object): def bar(cls) -> None: ... """) + @test_base.skip("Temporary rollback") def test_factory_classmethod(self): ty = self.Infer(""" class Foo(object): @@ -180,6 +181,7 @@ class Foo: def factory(cls: Type[_TFoo], *args, **kwargs) -> _TFoo: ... """) + @test_base.skip("Temporary rollback") def test_classmethod_return_inference(self): ty = self.Infer(""" class Foo(object): diff --git a/pytype/tests/test_cmp.py b/pytype/tests/test_cmp.py index 229bc45e3..41124ffa0 100644 --- a/pytype/tests/test_cmp.py +++ b/pytype/tests/test_cmp.py @@ -155,6 +155,7 @@ class Foo: def __new__(cls: Type[_TFoo], *args, **kwargs) -> _TFoo: ... """) + @test_base.skip("Temporary rollback") def test_class_factory(self): # The assert should not block inference of the return type, since cls could # be a subclass of Foo diff --git a/pytype/vm.py b/pytype/vm.py index 731ca96dd..ee2166bb0 100644 --- a/pytype/vm.py +++ b/pytype/vm.py @@ -1604,7 +1604,7 @@ def _is_classmethod_cls_arg(self, var): return False func = self.frame.func.data - if func.is_classmethod or func.name.rsplit(".")[-1] == "__new__": + if func.name.rsplit(".")[-1] == "__new__": is_cls = not set(var.data) - set(self.frame.first_posarg.data) return is_cls return False