From de1294d71ce5427129122ed2d16a108679ed53f2 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 14 Oct 2016 14:16:13 -0700 Subject: [PATCH] WIP: unify [] and [1] to list[int] rather than object --- mypy/join.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mypy/join.py b/mypy/join.py index c88ed2b7e58f..dcf28e9e2d86 100644 --- a/mypy/join.py +++ b/mypy/join.py @@ -289,6 +289,13 @@ def join_instances(t: Instance, s: Instance) -> Type: return Instance(t.type, args) else: # Incompatible; return trivial result object. + if t.args and len(t.args) == len(s.args): + if len(t.args) == 1: + if isinstance(t.args[0], (NoneTyp, UninhabitedType)): + return s + if isinstance(s.args[0], (NoneTyp, UninhabitedType)): + return t + return Instance(t.type, [AnyType()]*len(t.args)) # XXX Questionable return object_from_instance(t) elif t.type.bases and is_subtype_ignoring_tvars(t, s): return join_instances_via_supertype(t, s)