tooling: Enable ruff preview rules E203, E302, and E303.#401
Merged
Conversation
Closes #400. These three pycodestyle rules are in preview in ruff 0.11.6 and were not active because of explicit-preview-rules = true. Add them to the explicit select list and auto-fix the 11 existing violations across the codebase: E203 — whitespace before ':' (catches `else :`, `if x :`, etc.) E302 — expected 2 blank lines before function/class definition E303 — too many blank lines inside a block E203 was spotted in PR #399 (Aline's tamagotchi example) and E302/E303 in PR #376 (Kaan's spirit level) — both were caught manually because ruff did not flag them.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the repository’s Ruff configuration to explicitly enable three pycodestyle preview rules (E203/E302/E303) that were previously inactive due to explicit-preview-rules = true, and applies trivial whitespace-only fixes to satisfy the newly-enforced rules.
Changes:
- Enable Ruff preview rules
E203,E302, andE303via explicit selection inpyproject.toml. - Auto-fix existing violations by adjusting blank-line spacing in a handful of files.
- Remove stray whitespace-only blank lines that would now be flagged.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
pyproject.toml |
Explicitly enables preview rules E203/E302/E303 so Ruff enforces them under explicit-preview-rules = true. |
tests/conftest.py |
Removes an extra blank line to comply with blank-line rules. |
lib/wsen-pads/examples/temp_pressure_display.py |
Adds a blank line before a top-level def to satisfy E302. |
lib/wsen-pads/examples/pressure_trend.py |
Adds a blank line before a top-level def to satisfy E302. |
lib/wsen-pads/examples/altitude.py |
Adds a blank line before a top-level def to satisfy E302. |
lib/steami_screen/steami_screen/device.py |
Adjusts blank lines around top-level class/defs to satisfy E302/E303. |
lib/steami_config/steami_config/device.py |
Adjusts blank lines around top-level class/defs to satisfy E302/E303. |
lib/mcp23009e/examples/i2c_scan.py |
Removes an extra whitespace-only blank line flagged by blank-line rules. |
lib/apds9960/examples/light_theremin.py |
Removes extra blank lines inside a block to satisfy E303. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Pylance ignores python.analysis.* in settings.json when a pyproject.toml exists and warns "cannot be set when a pyproject.toml is being used". Move typeCheckingMode, extraPaths, stubPath, and diagnosticSeverityOverrides into [tool.pyright] in pyproject.toml where Pylance reads them. This also makes the configuration IDE-agnostic (works for any pyright-based tool, not just VSCode).
|
🎉 This PR is included in version 0.20.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enable three pycodestyle preview rules that were silently inactive due to
explicit-preview-rules = true::(catcheselse :,if x :)Auto-fixed the 11 pre-existing violations across 8 files (all trivial blank-line additions/removals).
Test plan
make lintpasses with the new rules activemake test-mockpasses (364 passed, 2 skipped)echo "else :" | ruff checknow triggers E203defnow triggers E302Closes
#400