1: ---
2: title: "Example"
3: ---
4:
5: This file contains some issues for the linter to identify.
6:
7: ```{python}
8: very_long_line = "This long string exceeds the maximum allowed characters per line."
9: ```
10:
11: There's some more issues below...
12:
13: ```{python}
14: def add_numbers(a, b):
15: return a + b
16:
17: add_numbers(3, 5)
18:
19: import sys
20: ```
ruff
Modern, ultra-fast linter that implements checks from Flake8 and some other popular plugins.
lintquarto uses ruff as a read-only linter by running ruff check on a temporary Python version of your .qmd files. It does not support extra commands from ruff like ruff check --fix (which automatically applies some fixes) or ruff format (a code formatter). This means the Ruff checks you see in lintquarto will not cover every issue that could be fixed by the formatter, because Ruff’s linter is intentionally more restricted in scope than its formatter and several stylistic issues are handled silently by the formatter rather than reported as lint errors.
Supporting automatic fixes for .qmd files (lintquarto issue #93) would require safely mapping Ruff’s edits on the temporary .py file back into the original .qmd source, which is non-trivial, so lintquarto currently focuses on reporting issues without modifying your Quarto documents.
Example Quarto .qmd file:
Run ruff using lintquarto
lintquarto -l ruff -p general_example.qmd============================================================= Running ruff... ============================================================= D100 Missing docstring in public module --> examples/general_example.qmd:1:1 E501 Line too long (84 > 79) --> examples/general_example.qmd:8:80 | 6 | # - 7 | # %% [python] 8 | very_long_line = "This long string exceeds the maximum allowed characters per line." # noqa: E305 | ^^^^^ 9 | # - 10 | # - | RUF100 [*] Unused `noqa` directive (non-enabled: `E305`) --> examples/general_example.qmd:8:87 | 6 | # - 7 | # %% [python] 8 | very_long_line = "This long string exceeds the maximum allowed characters per line." # noqa: E305 | ^^^^^^^^^^^^ 9 | # - 10 | # - | help: Remove unused `noqa` directive ANN201 Missing return type annotation for public function `add_numbers` --> examples/general_example.qmd:14:5 | 12 | # - 13 | # %% [python] 14 | def add_numbers(a, b): # noqa: E302,E305,E501 | ^^^^^^^^^^^ 15 | return a + b | help: Add return type annotation D103 Missing docstring in public function --> examples/general_example.qmd:14:5 | 12 | # - 13 | # %% [python] 14 | def add_numbers(a, b): # noqa: E302,E305,E501 | ^^^^^^^^^^^ 15 | return a + b | ANN001 Missing type annotation for function argument `a` --> examples/general_example.qmd:14:17 | 12 | # - 13 | # %% [python] 14 | def add_numbers(a, b): # noqa: E302,E305,E501 | ^ 15 | return a + b | ANN001 Missing type annotation for function argument `b` --> examples/general_example.qmd:14:20 | 12 | # - 13 | # %% [python] 14 | def add_numbers(a, b): # noqa: E302,E305,E501 | ^ 15 | return a + b | RUF100 [*] Unused `noqa` directive (unused: `E501`; non-enabled: `E302`, `E305`) --> examples/general_example.qmd:14:25 | 12 | # - 13 | # %% [python] 14 | def add_numbers(a, b): # noqa: E302,E305,E501 | ^^^^^^^^^^^^^^^^^^^^^^ 15 | return a + b | help: Remove unused `noqa` directive E402 Module level import not at top of file --> examples/general_example.qmd:19:1 | 17 | add_numbers(3, 5) 18 | 19 | import sys | ^^^^^^^^^^ 20 | # - | F401 [*] `sys` imported but unused --> examples/general_example.qmd:19:8 | 17 | add_numbers(3, 5) 18 | 19 | import sys | ^^^ 20 | # - | help: Remove unused import: `sys` Found 10 errors. [*] 3 fixable with the `--fix` option.