pytype

Google’s static type checker.

PyPI View on PyPI GitHub View on GitHub Conda View on Conda

Example Quarto .qmd file:

1:     ---
2:     title: "Example"
3:     ---
4:     
5:     This file contains some issues for the linter (static type checker) to identify.
6:     
7:     ```{python}
8:     def add_numbers(a: int, b: int) -> int:
9:         return a + b
10:    
11:    add_numbers(3, "5")
12:    ```
13:    
14:    There's some more issues below...
15:    
16:    ```{python}
17:    add_numbers(1, 4)
18:    
19:    add_numbers("apples", 8)
20:    ```

Run pytype using lintquarto

lintquarto -l pytype -p typecheck_example.qmd
=============================================================

Running pytype...

=============================================================

ninja: Entering directory `.pytype'

[1/1] check typecheck_example

FAILED: /home/runner/work/lintquarto/lintquarto/docs/pages/tools/.pytype/pyi/typecheck_example.pyi 

/opt/hostedtoolcache/Python/3.13.5/x64/bin/python -m pytype.main --imports_info /home/runner/work/lintquarto/lintquarto/docs/pages/tools/.pytype/imports/typecheck_example.imports --module-name typecheck_example --platform linux -V 3.13 -o /home/runner/work/lintquarto/lintquarto/docs/pages/tools/.pytype/pyi/typecheck_example.pyi --analyze-annotated --nofail --quick /home/runner/work/lintquarto/lintquarto/docs/pages/tools/examples/typecheck_example.qmd

Python versions > 3.12 are not yet supported.

ninja: build stopped: subcommand failed.

Computing dependencies

Analyzing 1 sources with 0 local dependencies

Leaving directory '.pytype'