Skip to content

Commit

Permalink
Do a PyPI release for a parser fix.
Browse files Browse the repository at this point in the history
For #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
  • Loading branch information
rchen152 committed Jun 26, 2020
1 parent a35c05f commit d477f91
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
6 changes: 6 additions & 0 deletions 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.
Expand Down
2 changes: 1 addition & 1 deletion pytype/__version__.py
@@ -1,2 +1,2 @@
# pylint: skip-file
__version__ = '2020.06.01'
__version__ = '2020.06.26'
9 changes: 1 addition & 8 deletions pytype/analyze.py
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions pytype/tests/test_classes.py
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
1 change: 1 addition & 0 deletions pytype/tests/test_cmp.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pytype/vm.py
Expand Up @@ -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
Expand Down

0 comments on commit d477f91

Please sign in to comment.