From 157e9e005d22045db80dd58fbfd6bfe5d16a684e Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 2 Oct 2021 16:10:02 +0900 Subject: [PATCH] fix(11090): skip translate_dict_call when type alias dict call --- mypy/semanal.py | 2 +- test-data/unit/check-type-aliases.test | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mypy/semanal.py b/mypy/semanal.py index 49c24cde0447..b5dcf93499ed 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -3786,7 +3786,7 @@ def visit_call_expr(self, expr: CallExpr) -> None: expr.analyzed = PromoteExpr(target) expr.analyzed.line = expr.line expr.analyzed.accept(self) - elif refers_to_fullname(expr.callee, 'builtins.dict'): + elif isinstance(expr.callee, RefExpr) and expr.callee.fullname == 'builtins.dict': expr.analyzed = self.translate_dict_call(expr) elif refers_to_fullname(expr.callee, 'builtins.divmod'): if not self.check_fixed_args(expr, 2, 'divmod'): diff --git a/test-data/unit/check-type-aliases.test b/test-data/unit/check-type-aliases.test index 2701858895d1..e0ae71c9e95f 100644 --- a/test-data/unit/check-type-aliases.test +++ b/test-data/unit/check-type-aliases.test @@ -659,3 +659,14 @@ reveal_type(w) # N: Revealed type is "__main__.Out.In" reveal_type(x) # N: Revealed type is "__main__.Out.In.Inner" reveal_type(y) # N: Revealed type is "__main__.Out.In.Inner" reveal_type(z) # N: Revealed type is "__main__.Out.In" + +[case testTypeAliasDictNoVarAnnotatedError] +from typing import Dict +D = Dict[str, str] +d = D() +[builtins fixtures/dict.pyi] + +[case testTypeAliasListNoVarAnnotatedError] +from typing import List +L = List[str] +l = L()