ruff

Modern, ultra-fast linter that implements checks from Flake8 and some other popular plugins.

Running lintquarto -l ruff will run ruff check, a read-only linter. For ruff-based code rewriting commands (ruff format and ruff check --fix), please see the ruff formatter page.

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 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:    ```

Run ruff using lintquarto

lintquarto -l ruff -p general_example.qmd
==========================================================

Running ruff...

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

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 | # -

   |



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

   |



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 7 errors.

[*] 1 fixable with the `--fix` option.


Notes

Excluded checks

The check unused-noqa RUF100 is disabled by default due to conflicts with the manner in which lintquarto acts, leading to false positives if this check is enabled. More details on this decision can be found in this GitHub issue.

The check implicit-namespace-package INP001 is also disabled by default due to the majority of quarto documents not having an __init__.py file in their directory. More details on this can be found in this GitHub issue.

The check undocumented-public-module D100 is also disabled as Quarto files are not modules.