From python-plugin
Deep guidance for mypy strict static typing. Use when configuring `[tool.mypy]`, debugging type errors, picking between `cast` / `assert isinstance` / TypeGuard, writing protocols vs ABCs, handling third-party libraries without stubs, dealing with pydantic plugin, silencing follow-imports for path-injected modules, or migrating an untyped codebase. Pairs with the unified `python` skill — load this one when the question is specifically about mypy.
How this skill is triggered — by the user, by Claude, or both
Slash command
/python-plugin:python-mypyThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Strict mode is the default. Every project starts at `strict = true` and
Strict mode is the default. Every project starts at strict = true and
adds per-module overrides only with a written reason.
[tool.mypy]
python_version = "3.11"
strict = true
files = ["src", "scripts", "hooks"]
explicit_package_bases = true
namespace_packages = true
[[tool.mypy.overrides]]
module = ["legacy.untyped.*"]
ignore_missing_imports = true
follow_imports = "skip"
strict = true enables--disallow-untyped-defs — every function annotated.--disallow-any-generics — list, dict must be parameterized.--no-implicit-optional — Optional[T] must be explicit.--warn-unused-ignores — dead # type: ignore flagged.--warn-return-any — function declared to return T can't actually
return Any.Any-leaking call sitesWrap third-party returns:
data: dict[str, Any] = json.loads(text)
return data
The local annotation pins the type so the function doesn't trip
warn-return-any.
For pydantic / msgspec models that mypy can't infer, install the
matching plugin (pydantic ships pydantic.mypy).
types-<package>.ignore_missing_imports = true. Don't blanket-disable globally.If a module mutates sys.path to find a sibling package, mypy can't
resolve it. Two mitigations:
mypy_path in [tool.mypy] to the same dirs the runtime
bootstrap finds.import-untyped and using
follow_imports = "skip" for that package.castassert isinstance(x, T) — runtime check, mypy narrows.if x is not None: — narrows Optional[T] to T.match statements with type patterns.TypeGuard[T] for custom predicates.cast(T, x) is a last resort; prefer narrowing.
Use dmypy run (or the mypy-type-checker VS Code extension's
preferDaemon: true) to keep type state warm between checks. Cuts
incremental check time from seconds to milliseconds.
Run python -m mypy (no args — [tool.mypy].files controls scope).
Single job, no matrix needed.
npx claudepluginhub cjhowe-us/marketplace --plugin python-pluginProvides a checklist for code reviews covering functionality, security, performance, maintainability, tests, and quality. Use for pull requests, audits, team standards, and developer training.