Skip to content
Back to skills

Ruff Knowledge Patch

ASecurity

Ruff

  • 25 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added September 5, 2026
developmentpythonrustgogitbackendsecurity

Works with

  • cli

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill ruff-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ruff Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ruff Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-ruff-knowledge-patch/badge)](https://www.skillsdirectory.com/skills/nevaberry-ruff-knowledge-patch)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ruff-knowledge-patch
description: Ruff
version: "0.17.6"
license: MIT
metadata:
  author: Nevaberry
---


# Ruff compatibility guidance

Load this skill when updating Ruff configuration, migrating rule selectors or
suppression comments, reviewing autofixes, formatting Python or Markdown,
or maintaining editor and report integrations.
The references retain rule-specific conditions, preview status, and examples.

## Reference index

| Reference | Topics |
| --- | --- |
| [Migration and configuration](references/migration-and-configuration.md) | Defaults, deprecated rules, selectors, Python targets, discovery, configuration settings |
| [Formatting and syntax](references/formatting-and-syntax.md) | Formatter style, Markdown, pragmas, syntax diagnostics, Python language support |
| [Lint rules](references/lint-rules.md) | Rule availability and coverage, typing, imports, pytest, security, async code, Airflow |
| [Suppressions and fixes](references/suppressions-and-fixes.md) | Logical-line and file suppressions, validation, fix availability and safety |
| [CLI, server, analysis, and distribution](references/cli-server-analysis-and-distribution.md) | CLI output, report schemas, editor server, notebooks, dependency graphs, installation and builds |

## Breaking changes and deprecations

### Preserve an intentional rule selection

Ruff 0.16.0 expands the stable defaults from 59 to 413 rules and removes some
previous defaults. Set `lint.select` explicitly to preserve a project's previous
rule set; the migration reference lists the removed defaults.
Ruff 0.17.0 enables `F406` by default and drops `DTZ001`, `DTZ005`, `DTZ006`,
`DTZ007`, `DTZ011`, `DTZ012`, and `DTZ901`. Add those datetime rules to
`lint.extend-select` to keep running them alongside the new defaults.

To keep using the earlier stable default selectors in preview:

```toml
[tool.ruff.lint]
select = ["E4", "E7", "E9", "F"]
```

Rule selection starts with the highest-priority `select`: CLI, project
configuration, then inherited configuration. A CLI selection can reset project
ignores: `ruff check --select F .` enables `F401` even with project
`ignore = ["F401"]`.

### Replace retired codes and settings

Select deprecated rules by exact code; group and prefix selections skip them.
Remove retired `S320`, `PD901`, and `UP038` from selectors and suppressions.

| Existing use | Migration |
| --- | --- |
| `RUF035` for `unsafe-markup-use` | Use stable `S704` |
| Preview `RUF025` | Use `RUF037` |
| `UP007` for `typing.Optional` | Use `UP045`; `UP007` covers `typing.Union` |
| `N804` for the first argument of `__new__` | Enable `PLW0211` to retain the check |
| `TRY302` for `useless-try-except` | Use `TRY203` |
| `PLC2201` for a comparison with the constant on the left | Use `SIM300` |
| `UP011` for rewriting `@functools.lru_cache(maxsize=None)` | Use `UP033`; keep `UP011` for empty decorator parentheses |
| `builtins-`-prefixed settings | Use unprefixed settings such as `allowed-modules` |
| `lint.allow-unused-imports` | Use `allowed-unused-imports` under the Pyflakes settings |
| `update-check`, even when `false` | Remove it from configuration and CLI invocations |

Airflow preview checks have changed codes and split across rules; use the
Airflow section in the lint reference for the exact migrations.

### Python target discovery and fallbacks

Without an explicit or inferred target, Ruff 0.17.0 uses Python 3.11 for lint
rules and Python 3.15 for syntax diagnostics. Set `target-version` explicitly
to check compatibility with an older Python release.
Ruff resolves the full `extend` chain before falling back to the default target.

When `ruff.toml` omits `target-version`, Ruff reads `[project].requires-python`
from a sibling `pyproject.toml`, including one containing only project metadata.
Without project configuration it looks for the nearest parent `pyproject.toml`;
that file's `requires-python` takes precedence over user-level settings.

```toml
[tool.ruff]
target-version = "py39"

[tool.ruff.per-file-target-version]
"scripts/*.py" = "py312"
```

### Editor, package, and configuration migration

Ruff 0.17.0 removes `ruff-lsp` support. The VS Code extension always uses the
native server and ignores `ruff.nativeServer`.
The conda-forge package is Python-independent: switch its callers using
`python -m ruff` or `import ruff` to the `ruff` executable on `PATH`.

On macOS, move user configuration from
`~/Library/Application Support/ruff/ruff.toml` to the XDG location, typically
`~/.config/ruff/ruff.toml`.
Use `output-format`, `RUFF_OUTPUT_FORMAT`, and `--output-format` in place of
the old report-format setting `format`, environment variable `RUFF_FORMAT`,
and `--format` on `ruff check`, `ruff rule`, and `ruff linter`.

## Suppressions and fix safety

### Stable suppression forms

`ruff: ignore[...]` works on the diagnostic line or the preceding line.
A directive above a multiline function definition covers the whole header.
`ruff: file-ignore[...]` suppresses specified rules throughout a file.
Any `ruff` suppression directive can include a reason after its closing bracket.

```python
# ruff: file-ignore[F401] Imports are kept for interactive use
import pathlib
```

Paired `ruff: disable` and `ruff: enable` comments suppress a block:

```python
# ruff: disable[F401]
import decimal
# ruff: enable[F401]
```

Use `ruff check --add-ignore example.py` to generate stable suppression comments.
`ruff check` rejects combining `--add-noqa` with `--diff`.
`RUF102` checks unknown codes in inline and file-level suppressions; `RUF100`
limits its checks to known codes. `PGH004` flags blanket file-level `# ruff: noqa`.
For `DOC` diagnostics, put inline suppressions on the docstring's first line;
for `UP015`, put them on the redundant mode argument's line.

### Displaying edits and applying them

`ruff check` and `ruff format --check` show proposed diffs by default.
The default `full` output in 0.17.0 also shows unsafe and display-only edits
regardless of `unsafe-fixes`; automatically applying unsafe fixes still requires
opting in. The editor offers display-only fixes and marks safe fixes as preferred.

From 0.16.8, automatically applying a `UP040` type alias fix always requires
opting into unsafe fixes. Preview `G004` logging f-string fixes require that
opt-in from 0.17.5. `ISC003` and `F541` fixes are unsafe when they create a
docstring. The fixes reference retains per-rule comment-deletion and type checks.

### Future annotations and typing rewrites

Enable `lint.future-annotations` to let stable autofixes insert
`from __future__ import annotations`. This lets `TC001`–`TC003` move more
imports into `TYPE_CHECKING` blocks, `RUF013` use `|` in annotations targeting Python
before 3.10, and `UP037` unquote more annotations.

```toml
[tool.ruff.lint]
future-annotations = true
```

From 0.16.8, `TC001`, `TC002`, and `TC003` prefer `lazy import` for type-only
dependencies on Python 3.15 or later. `TID254` and `TID255` run without preview
from 0.17.0, and `TID254` skips stubs. The references retain lazy-import fix
restrictions, deferred-annotation handling, and PEP 695 conversion limits.

## Formatting and rule discovery

### Markdown and formatter controls

`ruff format README.md` formats Python code blocks in stable mode.
Recognized fences are `python`, `py`, `python3`, `py3`, `pyi`, and `pycon`;
`pyi` uses stub formatting and `pycon` uses REPL formatting.
Use `<!-- fmt: off -->` / `<!-- fmt: on -->` around Markdown regions, or
`# fmt: off` / `# fmt: on` inside a Python fence.
Add `"*.md"` to `extend-exclude` to opt out for Markdown files entirely.

Quarto files require an explicit extension mapping:

```toml
[tool.ruff]
extension = { qmd = "markdown" }
```

Use `ruff config format.nested-string-quote-style` to inspect nested quote choices.
`ruff format --extend-exclude 'generated/**' .` adds to configured exclusions.
In stable 0.17.0, the formatter and `I001`, `E501`, and `W505` exclude trailing
pragma comments from line-length calculations, which can change import wrapping.

### Rule names and preview selectors

`ruff rule unused-import` looks up a rule by name.
Preview accepts rule names in selectors and supports rules identified only by
name; select those rules by name. Preview also has category selectors.
Preview `RUF105`, `RUF106`, and `RUF201` flag legacy `noqa` comments, codes in
`ruff: ignore`, and codes in configuration selectors, respectively.
Preview `RUF202` diagnoses renamed rules; preview `RUF101` checks redirected selectors
in suppression comments beyond `noqa`.

```sh
ruff check --preview --select unused-import .
```

## CLI and integration essentials

`ruff format --exit-non-zero-on-format .` writes changes and exits with status 1
if any file is reformatted. A successful `ruff check --fix-only .` exits zero
even after fixes; use `ruff check --fix-only --exit-non-zero-on-fix .` for a
nonzero status when files change.
`ruff format --check --output-format github .` produces CI annotations.
From 0.17.4, `NO_COLOR` takes precedence over color requests;
`CLICOLOR=0 ruff check .` also disables diagnostic colors.

JSON consumers must accept `null` for `filename`, `location`, `end_location`,
`fix.edits[].location`, and `fix.edits[].end_location`. Read each edit's `content`,
`location`, and `end_location` from `fix.edits`; the message is at `fix.message`.
JUnit consumers should read `skipped` instead of `disabled` on each
`<testsuite>`; `<testsuites>` also provides `skipped`.

`ruff analyze graph` supports stubs and notebooks, can use a supplied virtual
environment, and includes directories configured in `src` during resolution.
It also has an option to omit imports inside `TYPE_CHECKING` for runtime analysis.
The language server lints TOML, excludes TOML from formatting registration,
and supports pull diagnostics for individual notebook cells.
Its uv formatter backend skips invoking `uv format` in untrusted workspaces.

Building Ruff 0.17.6 from source requires Rust 1.98 or later; the project's
Rust toolchain is 1.100. See the distribution reference for installer paths,
archive layout, container images, platform packages, and signed binaries.

Files in this skill

  • SKILL.md9.1 KB
  • coverage.json1.4 KB
  • references/cli-server-analysis-and-distribution.md3.9 KB
  • references/formatting-and-syntax.md5.4 KB
  • references/lint-rules.md12.3 KB
  • references/migration-and-configuration.md6.9 KB
  • references/suppressions-and-fixes.md5.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.