Static Code Analysis
Check Python types without executing the project
ty-check is an offline Python type-checking node using ty.
overview
What ty-check does
Type-check Python source with Astral ty and emit diagnostics as GitLab Code Quality JSON. Static analysis only; no code is executed and no packages are installed.
Return GitLab Code Quality JSON with check_name, description, severity, fingerprint and line-column locations. A clean check returns an empty array. Type findings are successful data through --exit-zero; configuration or runtime failures produce no output.
Repository pyproject.toml tool.ty settings and ty.toml are respected; the optional python-version input overrides the configured target. The image has no Python interpreter or installed project dependencies. Bundled typeshed covers the standard library; third-party imports can be unresolved. Source is neither executed nor modified.
Packaged version: 0.0.84. Upstream license: MIT. The ty release repository points to the linked Ruff commit for its Rust compiler source.
source github.com/astral-sh/ruff/tree/11aaa39f84c0c44bdfb4c9cc21e4038c6f74c00a
use cases
Where ty-check fits
Check return annotations
Locate return values that conflict with declared types.
Find argument mismatches
Report incompatible argument types at their source positions.
Target a Python version
Use the python-version port to override the repository target.
reference
ty-check inputs and flags
| Name | Type | Flag | Description |
|---|---|---|---|
| source | FOLDER | --source | Folder of Python source, optionally with pyproject.toml [tool.ty] or ty.toml. Third-party packages are not installed, so their imports report unresolved-import. |
| python-version | STRING | --python-version | Optional target Python version such as 3.12; defaults to project config or ty's default. |
Showing key inputs. ty-check exposes 2 inputs in total.
example
Run ty-check
/app/run.sh --source ./source --python-version 3.12 ./outputguidance
Choosing ty-check
Use ty-check to investigate Python type mismatches. Ruff lint rules and Black formatting answer different questions. This pre-1.0 compiler can change diagnostic coverage between releases; the packaged release is ty 0.0.84.
faq
ty-check questions
related
More Static Code Analysis tools
bandit
Python source in, JSON security findings out.
gitleaks
Detect hardcoded secrets in git repos and plain directories.
gosec
Go AST security scanner for credentials, crypto, and injection.
guarddog
A package coordinate in, indicator hits out.
malcontent-scan
A package coordinate in, behavior findings out.
osv-malicious
A package coordinate in, malware advisory rows out.
Run ty-check yourself
The saved synthetic verifier confirmed invalid-return-type at line 2 and invalid-argument-type at line 4 in typed.py. These are verifier-confirmed locations, not a retained complete native diagnostics array. The command shows the container entrypoint with example paths.
Facts on this page come from the live Trickest tool library.