mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-18 18:45:07 +00:00
![renovate[bot]](/assets/img/avatar_default.png)
This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [mdformat-mkdocs](https://redirect.github.com/kyleking/mdformat-mkdocs) ([changelog](https://redirect.github.com/kyleking/mdformat-mkdocs/releases)) | `==3.1.1` -> `==4.0.0` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>kyleking/mdformat-mkdocs (mdformat-mkdocs)</summary> ### [`v4.0.0`](https://redirect.github.com/KyleKing/mdformat-mkdocs/releases/tag/v4.0.0) [Compare Source](https://redirect.github.com/kyleking/mdformat-mkdocs/compare/v3.1.1...v4.0.0) #### What's Changed - fix!: add newline after title for consistency with MKDocs style by [@​KyleKing](https://redirect.github.com/KyleKing) in [https://github.com/KyleKing/mdformat-mkdocs/pull/44](https://redirect.github.com/KyleKing/mdformat-mkdocs/pull/44) **Full Changelog**: https://github.com/KyleKing/mdformat-mkdocs/compare/v3.1.1...v4.0.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/astral-sh/ruff). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS41OC4xIiwidXBkYXRlZEluVmVyIjoiMzkuNTguMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiaW50ZXJuYWwiXX0=--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com> Co-authored-by: Kyle King <KyleKing@users.noreply.github.com>
112 lines
3.8 KiB
Markdown
112 lines
3.8 KiB
Markdown
# Features
|
|
|
|
This section provides a detailed overview of the features provided by the Ruff Language Server.
|
|
|
|
## Diagnostic Highlighting
|
|
|
|
Provide diagnostics for your Python code in real-time.
|
|
|
|
<img
|
|
src="https://astral.sh/static/GIF/v0.4.5/violation_hx.gif"
|
|
alt="Editing a file in Helix"
|
|
/>
|
|
|
|
## Dynamic Configuration
|
|
|
|
The server dynamically refreshes the diagnostics when a configuration file is changed in the
|
|
workspace, whether it's a `pyproject.toml`, `ruff.toml`, or `.ruff.toml` file.
|
|
|
|
The server relies on the file watching capabilities of the editor to detect changes to these files.
|
|
If an editor does not support file watching, the server will not be able to detect
|
|
changes to the configuration file and thus will not refresh the diagnostics.
|
|
|
|
<img
|
|
src="https://astral.sh/static/GIF/v0.4.5/config_reload_vscode.gif"
|
|
alt="Editing a `pyproject.toml` configuration file in VS Code"
|
|
/>
|
|
|
|
## Formatting
|
|
|
|
Provide code formatting for your Python code. The server can format an entire document or a specific
|
|
range of lines.
|
|
|
|
The VS Code extension provides the `Ruff: Format Document` command to format an entire document.
|
|
In VS Code, the range formatting can be triggered by selecting a range of lines, right-clicking, and
|
|
selecting `Format Selection` from the context menu.
|
|
|
|
<img
|
|
src="https://astral.sh/static/GIF/v0.4.5/format_vscode.gif"
|
|
alt="Formatting a document in VS Code"
|
|
/>
|
|
|
|
## Code Actions
|
|
|
|
Code actions are context-sensitive suggestions that can help you fix issues in your code. They are
|
|
usually triggered by a shortcut or by clicking a light bulb icon in the editor. The Ruff Language
|
|
Server provides the following code actions:
|
|
|
|
- Apply a quick fix for a diagnostic that has a fix available (e.g., removing an unused import).
|
|
- Ignore a diagnostic with a `# noqa` comment.
|
|
- Apply all quick fixes available in the document.
|
|
- Organize imports in the document.
|
|
|
|
<img
|
|
src="https://astral.sh/static/GIF/v0.4.5/code_action_hx.gif"
|
|
alt="Applying a quick fix in Helix"
|
|
/>
|
|
|
|
You can even run these actions on-save. For example, to fix all issues and organize imports on save
|
|
in VS Code, add the following to your `settings.json`:
|
|
|
|
```json
|
|
{
|
|
"[python]": {
|
|
"editor.codeActionsOnSave": {
|
|
"source.fixAll.ruff": "explicit",
|
|
"source.organizeImports.ruff": "explicit"
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
### Fix Safety
|
|
|
|
Ruff's automatic fixes are labeled as "safe" and "unsafe". By default, the "Fix all" action will not
|
|
apply unsafe fixes. However, unsafe fixes can be applied manually with the "Quick fix" action.
|
|
Application of unsafe fixes when using "Fix all" can be enabled by setting `unsafe-fixes = true` in
|
|
your Ruff configuration file.
|
|
|
|
See the [Ruff fix documentation](https://docs.astral.sh/ruff/linter/#fix-safety) for more details on
|
|
how fix safety works.
|
|
|
|
## Hover
|
|
|
|
The server can provide the rule documentation when focusing over a NoQA code in the comment.
|
|
Focusing is usually hovering with a mouse, but can also be triggered with a shortcut.
|
|
|
|
<img
|
|
src="https://astral.sh/static/GIF/v0.4.5/hover_vscode.gif"
|
|
alt="Hovering over a noqa code in VS Code"
|
|
/>
|
|
|
|
## Jupyter Notebook
|
|
|
|
Similar to Ruff's CLI, the Ruff Language Server fully supports Jupyter Notebook files with all the
|
|
capabilities available to Python files.
|
|
|
|
!!! note
|
|
|
|
Unlike [`ruff-lsp`](https://github.com/astral-sh/ruff-lsp) and similar to the Ruff's CLI, the
|
|
native language server requires user to explicitly include the Jupyter Notebook files in the set
|
|
of files to lint and format. Refer to the [Jupyter Notebook discovery](https://docs.astral.sh/ruff/configuration/#jupyter-notebook-discovery)
|
|
section on how to do this.
|
|
|
|
<img
|
|
src="https://astral.sh/static/GIF/v0.4.5/ipynb_editing_vscode.gif"
|
|
alt="Editing multiple Jupyter Notebook cells in VS Code"
|
|
/>
|
|
|
|
<img
|
|
src="https://astral.sh/static/GIF/v0.4.5/ipynb_range_format_vscode.gif"
|
|
alt="Formatting a selection within a Jupyter Notebook cell in VS Code"
|
|
/>
|