Conversation
- Use `SourceType` in formatting related functions - Defer to `ruff_markdown` when formatting `SourceType::Markdown` - A bunch of `todos` around how to handle errors/etc Tested against a local build of `ruff-vscode` extension modified to declare support for markdown files, pointed at a local build of `ruff` Issue #22640
Typing conformance resultsNo changes detected ✅ |
|
|
|
This looks like a good start to me! It would be a good idea to get Dhruv's review once the todos are resolved too. |
4764eb2 to
abe3115
Compare
|
Todos resolved by adding warnings and return |
ntBre
left a comment
There was a problem hiding this comment.
Makes sense to me, just two nits! It might be cool to have a screenshot or brief recording in the PR summary in lieu of a normal test plan.
abe3115 to
96a237e
Compare
|
Addressed feedback, added quick screen recording to summary |
There was a problem hiding this comment.
This looks good.
Is the intention to skip Jupyter Notebooks for the initial version as currently it won't work? To make it work, you'd need to add "markdown" cell syncing in
ruff/crates/ruff_server/src/server.rs
Lines 195 to 204 in cdbe553
Edit: It isn't supported from the CLI either so I'm assuming that it's planned as a follow-up instead.
| } else if let Some(LanguageId::Markdown) = language_id | ||
| && formatter_settings.is_some() | ||
| { | ||
| tracing::debug!("Included path via Markdown language ID: {}", path.display()); | ||
| false |
There was a problem hiding this comment.
Can you say why there's an additional check for whether formatter_settings.is_some() or not? Or is it because to check whether preview mode is enabled or not?
There was a problem hiding this comment.
This was primarily to include Markdown files when formatting, but exclude them when linting (where the linter settings would be provided and formatter settings would be None).
|
Since we aren't formatting the Markdown style itself (only Python code blocks embedded in Markdown documents) formatting within notebook cells is not on the roadmap. I think it would be interesting to see if there are ecosystem cases where notebooks actually contain Markdown cells with embedded Python code blocks, and if they expect that ruff would format those embedded code blocks. |
* main: (45 commits) [ty] Fix wrong inlay hints for overloaded function arguments (astral-sh#23179) [ty] Respect `@no_type_check` when combined with other decorators (astral-sh#23177) [ty] Use type context when inferring constructor argument types (astral-sh#23139) [`airflow`] Add ruff rules to catch deprecated attribute access from context key for Airflow 3.0 (`AIR301`) (astral-sh#22850) Support formatting `pycon` markdown code blocks (astral-sh#23112) Markdown formatting in LSP (astral-sh#23063) Instruct Claude to use comments more sparingly (astral-sh#23181) [`flake8-gettext`] Fix false negatives for plural argument of ngettext (`INT001`, `INT002`, `INT003`) (astral-sh#21078) [ty] Invoking goto-def on parentheses of a class constructor call takes you too constructor method [ty] Make goto definition on class constructor always go to class definition [ty] Assign lower completions ranking to deprecated functions and classes (astral-sh#23089) [ty] Fix parameter references across files via keyword args (astral-sh#23012) [ty] Exclude enclosing class for base completions (astral-sh#23141) [`pyupgrade`] Fix syntax error on string with newline escape and comment (`UP037`) (astral-sh#22968) [ty] Improve documentation for `expect_single_definition` method (astral-sh#23175) [ty] Configure check mode for all projects Add `home-assistant` to ecosystem projects (astral-sh#23132) Add tabbed shell completion documentation (astral-sh#23169) Bump typing conformance-suite pin (astral-sh#23174) [ty] Fix invalid diagnostic location for a sub-call to a specialized ParamSpec (astral-sh#23036) ...
Yeah, that seems reasonable. I do realize that now as there wouldn't be too many examples of notebooks with markdown cells containing Python code in it 😅 |
Changes necessary to support markdown formatting in ruff's LSP in vscode: astral-sh/ruff#23063
SourceTypein formatting related functionsruff_markdownwhen formattingSourceType::Markdowntodosaround how to handle errors/etcTested against a local build of
ruff-vscodeextension modified todeclare support for markdown files, pointed at a local build of
ruffDemo:
2026-02-05.13-48-10.mov
Issue #22640