From e6abf083801e326949455d828ae5b7e469d75464 Mon Sep 17 00:00:00 2001 From: AhmadF Date: Sun, 13 Oct 2019 22:56:38 +0330 Subject: [PATCH 1/2] Record Speical Any as precise in report generation --- mypy/stats.py | 3 ++- test-data/unit/reports.test | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/mypy/stats.py b/mypy/stats.py index 6abcfd334da8..5efff42be7a9 100644 --- a/mypy/stats.py +++ b/mypy/stats.py @@ -332,7 +332,8 @@ def type(self, t: Optional[Type]) -> None: return if isinstance(t, AnyType) and is_special_form_any(t): - # This is not a real Any type, so don't collect stats for it. + # If there is an error in special form definition. it will override TYPE_PRECISE + self.record_line(self.line, TYPE_PRECISE) return if isinstance(t, AnyType): diff --git a/test-data/unit/reports.test b/test-data/unit/reports.test index 0aa0ce0c8c8f..68bbb180f984 100644 --- a/test-data/unit/reports.test +++ b/test-data/unit/reports.test @@ -422,3 +422,39 @@ async def some_function(x) -> None: l 1 0 0 0 0 0 0 ----------------------------------------------------------------------------------------------------------------- Total 1 1 0 0 0 0 0 + +[case testSpecialAnyHtmlReport] +# cmd: mypy --html-report report n.py +[file n.py] +from typing import Callable + +SourceToDisplay = Callable[[int], int] +DisplayToSource = Callable[[int], int] + +[file report/mypy-html.css] +[file report/index.html] +[outfile report/html/n.py.html] + + + + + + +

n

+ + + + + + +
n.py
1
+2
+3
+4
+
from typing import Callable
+
+SourceToDisplay = Callable[[int], int]
+DisplayToSource = Callable[[int], int]
+
+ + From 9e0e60d77153cdca008b604653c88b7d8b459778 Mon Sep 17 00:00:00 2001 From: AhmadF Date: Wed, 30 Oct 2019 09:13:04 +0330 Subject: [PATCH 2/2] Update TODO comment --- mypy/stats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/stats.py b/mypy/stats.py index 5efff42be7a9..43dde75d185a 100644 --- a/mypy/stats.py +++ b/mypy/stats.py @@ -332,7 +332,7 @@ def type(self, t: Optional[Type]) -> None: return if isinstance(t, AnyType) and is_special_form_any(t): - # If there is an error in special form definition. it will override TYPE_PRECISE + # TODO: What if there is an error in special form definition? self.record_line(self.line, TYPE_PRECISE) return