pyright

Microsoft’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 pyright using lintquarto

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

Running pyright...

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

/home/runner/work/lintquarto/lintquarto/docs/pages/tools/examples/typecheck_example.qmd

  /home/runner/work/lintquarto/lintquarto/docs/pages/tools/examples/typecheck_example.qmd:11:16 - error: Argument of type "Literal['5']" cannot be assigned to parameter "b" of type "int" in function "add_numbers"

    "Literal['5']" is not assignable to "int" (reportArgumentType)

  /home/runner/work/lintquarto/lintquarto/docs/pages/tools/examples/typecheck_example.qmd:19:13 - error: Argument of type "Literal['apples']" cannot be assigned to parameter "a" of type "int" in function "add_numbers"

    "Literal['apples']" is not assignable to "int" (reportArgumentType)

2 errors, 0 warnings, 0 informations