quarto-dev / quarto-dev/quarto
Formatting document is inconsistent between ruff and air
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 645
- Forks
- 62
- Avg merge
- 17h 42m
- Merged PRs (30d)
- 13
Description
Originally posted by @juliasilge in https://github.com/quarto-dev/quarto/pull/754#pullrequestreview-3688360799:
I'm supportive of us merging this because it gives us an improvement, but I want to highlight a difference in results between very similar formatters, when you use Format Document.
If you have settings like this:
{
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
},
"[r]": {
"editor.defaultFormatter": "Posit.air-vscode"
},
"[quarto]": {
"editor.defaultFormatter": "quarto.quarto"
}
}
And two .qmd files like this:
---
title: "Untitled"
format: html
---
```{python}
1 + 1
```
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
```{python}
from typing import Iterable
import os
def sum_even_numbers(numbers: Iterable[int]) -> int:
"""Given an iterable of integers, return the sum of all even numbers in the iterable."""
return sum(
num for num in numbers
if num % 2 == 0
)
```
Second one:
---
title: "Untitled"
format: html
---
```{r}
1 + 1
```
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
```{r}
list(foobar, foobar, foobar, foobar, foobar, foobar, foobar, foobar, foobar, foobar, foobar, foobar)
```
- Put your cursor in the
1 + 1code cell - Run Format Document
- In the R file, the other code cell will get formatted, which is what I would argue is the correct behavior
- In the Python file, the other code cell not get formatted, which I think is not right
If you run Format Document from the code cell that needs formatting, the behavior is the same for both; it does format that code cell. The command Quarto: Format Cell also works well for both files.
We can log this problem to follow up on.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the two .qmd examples in VS Code with the listed formatter settings, comparing Format Document from a code cell with Quarto: Format Cell. Trace the document-formatting paths for Python and R to identify why Ruff does not format the other cell; done means the Python document matches the R behavior while both existing commands continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, r, vscode
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100