[PR #1391] [MERGED] Lint Python code with ruff #1999

Open
opened 2026-01-29 20:56:51 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/google/brotli/pull/1391
Author: @cclauss
Created: 11/19/2025
Status: Merged
Merged: 11/20/2025
Merged by: @copybara-service[bot]

Base: masterHead: ruff


📝 Commits (1)

  • 52ad34c Lint Python code with ruff

📊 Changes

2 files changed (+7 additions, -1 deletions)

View changed files

📝 .github/workflows/lint.yml (+6 -1)
📝 research/brotlidump.py (+1 -0)

📄 Description

An extremely fast Python linter and code formatter, written in Rust. -- https://docs.astral.sh/ruff

  • ⚖️ Drop-in parity with Flake8, isort, and Black
  • 📏 Over 800 built-in rules, with native re-implementations of popular Flake8 plugins, like flake8-bugbear

% ruff check --statistics

85	E701	[ ] multiple-statements-on-one-line-colon
 4	F401	[*] unused-import
 2	E741	[ ] ambiguous-variable-name
 2	F841	[ ] unused-variable
Found 93 errors.

% ruff check --ignore=E701,E741,F401,F841

All checks passed!

% ruff rule F841

unused-variable (F841)

Derived from the Pyflakes linter.

Fix is sometimes available.

What it does

Checks for the presence of unused variables in function scopes.

Why is this bad?

A variable that is defined but not used is likely a mistake, and should
be removed to avoid confusion.

If a variable is intentionally defined-but-not-used, it should be
prefixed with an underscore, or some other value that adheres to the
[lint.dummy-variable-rgx] pattern.

Example

def foo():
    x = 1
    y = 2
    return x

Use instead:

def foo():
    x = 1
    return x

Fix safety

This rule's fix is marked as unsafe because removing an unused variable assignment may
delete comments that are attached to the assignment.

See also

This rule does not apply to bindings in unpacked assignments (e.g. x, y = 1, 2). See
unused-unpacked-variable for this case.

Options

  • lint.dummy-variable-rgx

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/google/brotli/pull/1391 **Author:** [@cclauss](https://github.com/cclauss) **Created:** 11/19/2025 **Status:** ✅ Merged **Merged:** 11/20/2025 **Merged by:** [@copybara-service[bot]](https://github.com/apps/copybara-service) **Base:** `master` ← **Head:** `ruff` --- ### 📝 Commits (1) - [`52ad34c`](https://github.com/google/brotli/commit/52ad34cea41bbecf7291c21da4a84846f0cf6e87) Lint Python code with ruff ### 📊 Changes **2 files changed** (+7 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/lint.yml` (+6 -1) 📝 `research/brotlidump.py` (+1 -0) </details> ### 📄 Description An extremely fast Python linter and code formatter, written in Rust. -- https://docs.astral.sh/ruff * ⚖️ Drop-in parity with [Flake8](https://docs.astral.sh/ruff/faq/#how-does-ruffs-linter-compare-to-flake8), isort, and [Black](https://docs.astral.sh/ruff/faq/#how-does-ruffs-formatter-compare-to-black) * 📏 Over [800 built-in rules](https://docs.astral.sh/ruff/rules/), with native re-implementations of popular Flake8 plugins, like flake8-bugbear % `ruff check --statistics` ``` 85 E701 [ ] multiple-statements-on-one-line-colon 4 F401 [*] unused-import 2 E741 [ ] ambiguous-variable-name 2 F841 [ ] unused-variable Found 93 errors. ``` % `ruff check --ignore=E701,E741,F401,F841` ``` All checks passed! ``` % `ruff rule F841` # unused-variable (F841) Derived from the **Pyflakes** linter. Fix is sometimes available. ## What it does Checks for the presence of unused variables in function scopes. ## Why is this bad? A variable that is defined but not used is likely a mistake, and should be removed to avoid confusion. If a variable is intentionally defined-but-not-used, it should be prefixed with an underscore, or some other value that adheres to the [`lint.dummy-variable-rgx`] pattern. ## Example ```python def foo(): x = 1 y = 2 return x ``` Use instead: ```python def foo(): x = 1 return x ``` ## Fix safety This rule's fix is marked as unsafe because removing an unused variable assignment may delete comments that are attached to the assignment. ## See also This rule does not apply to bindings in unpacked assignments (e.g. `x, y = 1, 2`). See [`unused-unpacked-variable`][RUF059] for this case. ## Options - `lint.dummy-variable-rgx` [RUF059]: https://docs.astral.sh/ruff/rules/unused-unpacked-variable/ --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 20:56:51 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#1999