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.
This commit is contained in:
neiljp (Neil Pilgrim) 2017-11-01 20:50:50 -07:00 committed by Tim Abbott
parent 790cd5e7c8
commit fec59b29cd
1 changed files with 2 additions and 1 deletions

View File

@ -87,7 +87,8 @@ if not python_files:
extra_args = ["--check-untyped-defs", extra_args = ["--check-untyped-defs",
"--follow-imports=silent", "--follow-imports=silent",
"--scripts-are-modules", "--scripts-are-modules",
"-i", "--cache-dir=var/mypy-cache"] "-i", "--cache-dir=var/mypy-cache",
"--disallow-any=generics"]
if args.linecoverage_report: if args.linecoverage_report:
extra_args.append("--linecoverage-report") extra_args.append("--linecoverage-report")
extra_args.append("var/linecoverage-report") extra_args.append("var/linecoverage-report")