ruff

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

lintquarto supports two ruff-based code rewriting commands:

For read-only linting, see the ruff linting 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:    ```

ruff-format

Use this command to format Python code blocks in a Quarto document.

lintquarto -f ruff-format -p general_example.qmd
==========================================================
Running ruff-format...
==========================================================
1 file reformatted

New file:

---
title: "Example"
---

This file contains some issues for the linter to identify.

```{python}
very_long_line = (
    "This long string exceeds the maximum allowed characters per line."
)
```

There's some more issues below...

```{python}
def add_numbers(a, b):
    return a + b


add_numbers(3, 5)

import sys
```

ruff-check-fix

Use this command to automatically apply Ruff’s available fixes for supported lint violations.

lintquarto -f ruff-check-fix -p general_example.qmd

New file:

---
title: "Example"
---

This file contains some issues for the linter to identify.

```{python}
very_long_line = "This long string exceeds the maximum allowed characters per line."
```

There's some more issues below...

```{python}
def add_numbers(a, b):
    return a + b

add_numbers(3, 5)
```

It will also print to console with messages about the remaining issues that couldn’t be automatically fixed.