From 389824659eaaa7461582245e92f779e68af7616f Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 12 Apr 2016 09:52:31 -0700 Subject: [PATCH] WIP - do not merge - see #1363 --- mypy/checkexpr.py | 2 ++ mypy/test/data/check-expressions.test | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/mypy/checkexpr.py b/mypy/checkexpr.py index 40e78fcceeb40..dd2df683be23d 100644 --- a/mypy/checkexpr.py +++ b/mypy/checkexpr.py @@ -627,6 +627,8 @@ def check_arg(self, caller_type: Type, original_caller_type: Type, callee_type: Type, n: int, m: int, callee: CallableType, context: Context, messages: MessageBuilder) -> None: """Check the type of a single argument in a call.""" + ## if isinstance(caller_type, Instance) and caller_type.type.fallback_to_any: + ## return if isinstance(caller_type, Void): messages.does_not_return_value(caller_type, context) elif isinstance(caller_type, DeletedType): diff --git a/mypy/test/data/check-expressions.test b/mypy/test/data/check-expressions.test index 80803e1751cf8..db5a9d003cdfa 100644 --- a/mypy/test/data/check-expressions.test +++ b/mypy/test/data/check-expressions.test @@ -1382,3 +1382,15 @@ dict(undefined) [builtins fixtures/dict.py] [out] main:1: error: Name 'undefined' is not defined + +[case testDictInContext] +# XXX This doesn't test for the right thing. +from typing import Any, Dict +Base = None # type: Any + +class Derived(Base): + def to_dict(self) -> Dict[str, Any]: + return dict(self) # fails without the hack +dict(Derived()) # fails without the hack +dict(Base()) # Always ok +[builtins fixtures/dict.py]