From fec59b29cd6929bd4bcbb60945a774ca68bdcfaf Mon Sep 17 00:00:00 2001 From: "neiljp (Neil Pilgrim)" Date: Wed, 1 Nov 2017 20:50:50 -0700 Subject: [PATCH] Tools/mypy: Enforce typed generics in tools/run-mypy. This adds the "--disallow-any=generics" option to run-mypy, which no longer permits: - inheriting from "list"; use "List[sometype]" (or a TypeVar) - generic types with no following square brackets specifying the type (even if initially 'Any') Any (and '...' for Callable) is a lot easier to search for than an absence of square brackets, and should improve overall typing quality. --- tools/run-mypy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/run-mypy b/tools/run-mypy index cc09dd1bf2..93f20b56a3 100755 --- a/tools/run-mypy +++ b/tools/run-mypy @@ -87,7 +87,8 @@ if not python_files: extra_args = ["--check-untyped-defs", "--follow-imports=silent", "--scripts-are-modules", - "-i", "--cache-dir=var/mypy-cache"] + "-i", "--cache-dir=var/mypy-cache", + "--disallow-any=generics"] if args.linecoverage_report: extra_args.append("--linecoverage-report") extra_args.append("var/linecoverage-report")