Skip to content

Don't return code actions for non-Python documents#23905

Merged
MichaReiser merged 2 commits intoastral-sh:mainfrom
tmimmanuel:fix/no-code-actions-for-non-python-files
Mar 13, 2026
Merged

Don't return code actions for non-Python documents#23905
MichaReiser merged 2 commits intoastral-sh:mainfrom
tmimmanuel:fix/no-code-actions-for-non-python-files

Conversation

@tmimmanuel
Copy link
Contributor

Summary

  • Add early return in the code action handler for non-Python documents (e.g., markdown), matching the existing guard pattern in lint::check() and fix::fix_all()
  • The server was incorrectly returning source.fixAll.ruff and source.organizeImports.ruff actions for files like .md

Closes #23861

Test plan

  • Added unit tests in code_action.rs:
    • no_code_actions_for_markdown — verifies empty response for .md files
    • code_actions_for_python — verifies non-empty response for .py files
cargo test -p ruff_server -- code_action::tests

@amyreese amyreese added the server Related to the LSP server label Mar 12, 2026
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@MichaReiser MichaReiser enabled auto-merge (squash) March 13, 2026 13:04
auto-merge was automatically disabled March 13, 2026 13:10

Head branch was pushed to by a user without write access

@tmimmanuel
Copy link
Contributor Author

Thanks @MichaReiser
I noticed there was fmt error and fixed. Could you enable auto-merge once more again?

@astral-sh-bot
Copy link

astral-sh-bot bot commented Mar 13, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser enabled auto-merge (squash) March 13, 2026 13:23
@MichaReiser MichaReiser merged commit 4b7b65e into astral-sh:main Mar 13, 2026
42 checks passed
carljm added a commit that referenced this pull request Mar 13, 2026
* main: (94 commits)
  Fix shell injection via `shell=True` in subprocess calls (#23894)
  [ty] Refactor `relation.rs` to store state on a struct rather than passing around 7 arguments every time we recurse (#23837)
  Don't return code actions for non-Python documents (#23905)
  [ty] Make the default database truly statically infallible (#23929)
  [ty] Add `Download` button to ty playground which creates a zip export (#23478)
  [ty] Respect `kw_only` overwrites in dataclasses (#23930)
  [ty] Clarify in diagnostics that `from __future__ import annotations` only stringifies type annotations (#23928)
  [ty]  Add a `Copy Markdown` button to playground (#23002)
  [ty] Fix folding range classification of lines starting with `#` (#23831)
  [ty] Fix folding ranges for notebooks (#23830)
  [ty] fix too-many-cycle panics when inferring literal type loop variables (#23875)
  Add `RegularCallableTypeOf` and `into_regular_callable` in `ty_extensions` (#23909)
  [ty] treat properties as full structural types (#23925)
  [ty] Avoid duplicated work during multi-inference (#23923)
  [ty]: make `possibly-missing-attribute` ignored by default
  [ty]: split out `possibly-missing-submodule` from `possibly-missing-attribute`
  Update astral-sh/setup-uv action to v7.5.0 (#23922)
  [ty] Show truthiness in ConstraintSet display and simplify falsy error message (#23913)
  Bump 0.15.6 (#23919)
  [ty] Narrow type context during collection literal inference (#23844)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

server Related to the LSP server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server announces code actions for markdown files

3 participants