Static Analysis
Type checkers inspect code without running it. They can catch mistakes such as passing a string where a function expects an integer, or accessing a field that no longer exists.
Mountaineer generates frontend types from your Python controllers but does not bundle a Python type checker. Configure checks for both languages to catch errors across that boundary.
Add type checks to CI early. It is easier to fix a missing annotation or a mismatched function call while you are working on that code.
Python
We currently recommend ty, Astral's Python type checker. It's fast, integrates cleanly with uv, and works well in CI once your project paths are scoped in pyproject.toml.
uv add --dev ty
Then add a basic configuration to your pyproject.toml:
[tool.ty.src]
include = ["my_app"]
Then, to run against your project:
uv run ty check
Typescript
Use TypeScript's compiler, tsc, to check frontend types without building the application. Install it in your views project:
npm install typescript --save-dev
Set the checks in tsconfig.json. The strict family checks types, while the final two options also check return paths and switch fallthrough:
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
}
}
| Parameter | Description |
|---|---|
| strict | Enables all strict type-checking options. Setting this to true is the easiest way to ensure you're using TypeScript's strictest settings. |
| noImplicitAny | Raises error on expressions and declarations with an implied any type. |
| strictNullChecks | When enabled, null and undefined are not in the domain of every type. |
| strictFunctionTypes | Ensures functions' parameters are correctly typed. |
| strictBindCallApply | Enforce stricter checking of the bind, call, and apply methods on functions. |
| strictPropertyInitialization | Ensures class properties are initialized in the constructor. |
| noImplicitReturns | Report error when not all code paths in function return a value. |
| noFallthroughCasesInSwitch | Prevent fall-through cases in switch statements. |
Then, to run against your project:
{
"scripts": {
"typecheck": "tsc --noEmit"
}
}
npm run typecheck