Run type checking against the project.
(c: Context, opts: str = "")
| 107 | # TODO: hoist up into invocations.checks once proven/needed elsewhere |
| 108 | @task |
| 109 | def typecheck(c: Context, opts: str = "") -> None: |
| 110 | """ |
| 111 | Run type checking against the project. |
| 112 | """ |
| 113 | # For now it seems easiest to just run a series of checks on the subtrees |
| 114 | # instead of forcing mypy to think about all the "duplicate" files across |
| 115 | # test vs integration vs main codebase (think _util.py or test fixtures) |
| 116 | # See also the exclude= key in pyproject.toml/mypy.ini. |
| 117 | root = Path(__file__).parent |
| 118 | exclude = ("sites", "docs", "build", "tests") |
| 119 | for path in root.iterdir(): |
| 120 | if path.name in exclude: |
| 121 | continue |
| 122 | if not path.is_dir() and path.suffix != ".py": |
| 123 | continue |
| 124 | if path.is_dir(): |
| 125 | if path.name.startswith("."): |
| 126 | continue |
| 127 | if not list(path.rglob("**/*.py")): |
| 128 | continue |
| 129 | c.run(f"mypy {opts} {path}", pty=True, echo=True) |
| 130 | |
| 131 | |
| 132 | ns = Collection( |