Skip to content

tooling: Enable ruff preview rules E203, E302, and E303.#401

Merged
nedseb merged 4 commits intomainfrom
tooling/ruff-preview-rules
Apr 16, 2026
Merged

tooling: Enable ruff preview rules E203, E302, and E303.#401
nedseb merged 4 commits intomainfrom
tooling/ruff-preview-rules

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Apr 16, 2026

Summary

Enable three pycodestyle preview rules that were silently inactive due to explicit-preview-rules = true:

Rule Description Where it was missed
E203 Whitespace before : (catches else :, if x :) PR #399 (Aline's tamagotchi)
E302 Expected 2 blank lines before function/class PR #376 (Kaan's spirit level)
E303 Too many blank lines PR #376

Auto-fixed the 11 pre-existing violations across 8 files (all trivial blank-line additions/removals).

Test plan

  • make lint passes with the new rules active
  • make test-mock passes (364 passed, 2 skipped)
  • echo "else :" | ruff check now triggers E203
  • Single blank line before a top-level def now triggers E302

Closes

#400

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.
Copilot AI review requested due to automatic review settings April 16, 2026 19:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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, and E303 via explicit selection in pyproject.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.

nedseb added 2 commits April 16, 2026 21:26
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).
@nedseb nedseb merged commit aa08fbe into main Apr 16, 2026
9 checks passed
@nedseb nedseb deleted the tooling/ruff-preview-rules branch April 16, 2026 19:31
@semantic-release-updater
Copy link
Copy Markdown

🎉 This PR is included in version 0.20.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants