ruff

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

Ruff runs as a code formatter, but it’s linter will not report every issue that can be fixed by its formatter. Several stylistic issues are handled silently by the formatter and are not surfaced as lint errors. This means Ruff’s linter is intentionally more restricted in scope than it’s formatter.

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

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

examples/general_example.py:19:1: E402 Module level import not at top of file

   |

17 | add_numbers(3, 5)

18 |

19 | import sys

   | ^^^^^^^^^^ E402

20 | # -

   |



examples/general_example.py:19:8: F401 [*] `sys` imported but unused

   |

17 | add_numbers(3, 5)

18 |

19 | import sys

   |        ^^^ F401

20 | # -

   |

   = help: Remove unused import: `sys`



Found 2 errors.

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