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: ```
basedpyright
Community fork of pyright with extra checks.
Example Quarto .qmd file:
Run basedpyright using lintquarto
lintquarto -l basedpyright -p typecheck_example.qmd==========================================================
Running basedpyright...
==========================================================
/home/runner/work/lintquarto/lintquarto/docs/pages/tools/examples/typecheck_example.qmd:11:1 - warning: Result of call expression is of type "int" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
::warning file=/home/runner/work/lintquarto/lintquarto/docs/pages/tools/examples/typecheck_example.qmd,line=11,col=1::Result of call expression is of type "int" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
/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)
::error file=/home/runner/work/lintquarto/lintquarto/docs/pages/tools/examples/typecheck_example.qmd,line=11,col=16::Argument of type "Literal['5']" cannot be assigned to parameter "b" of type "int" in function "add_numbers"%0A "Literal['5']" is not assignable to "int" (reportArgumentType)
/home/runner/work/lintquarto/lintquarto/docs/pages/tools/examples/typecheck_example.qmd:17:1 - warning: Result of call expression is of type "int" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
::warning file=/home/runner/work/lintquarto/lintquarto/docs/pages/tools/examples/typecheck_example.qmd,line=17,col=1::Result of call expression is of type "int" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
/home/runner/work/lintquarto/lintquarto/docs/pages/tools/examples/typecheck_example.qmd:19:1 - warning: Result of call expression is of type "int" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
::warning file=/home/runner/work/lintquarto/lintquarto/docs/pages/tools/examples/typecheck_example.qmd,line=19,col=1::Result of call expression is of type "int" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
/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)
::error file=/home/runner/work/lintquarto/lintquarto/docs/pages/tools/examples/typecheck_example.qmd,line=19,col=13::Argument of type "Literal['apples']" cannot be assigned to parameter "a" of type "int" in function "add_numbers"%0A "Literal['apples']" is not assignable to "int" (reportArgumentType)
::error::2 errors
2 errors, 3 warnings, 0 notes