Add ruff for linting and formatting Python scripts - #819
Closed
Aruna-Mani wants to merge 1 commit into
Closed
Conversation
Member
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.
What is the problem or limitation you are having?
This repository contains Python code, but we are not enforcing Ruff style configurations on that code.
Describe the solution you'd like
Adds a
[tool.ruff.lint]configuration topyproject.toml, using Toga's ruleset as a base (E,W,F,UP,B,ASYNC,C4,I), plus aruff-pre-commithook (ruff-check --fix+ruff-format) to enforce it automatically.A couple of targeted deviations from Toga's config were needed for this repo's scripts:
DTZ005/DTZ007/DTZ011are ignored globally, since blog/event post metadata dates are intentionally date-only and never need timezone awareness.E501(line length) is ignored per-file formacros.pyandnew_post.py, since these files build long Markdown/HTML content from f-strings, and wrapping those lines would alter the generated output.Ran
pre-commit run --all-filesafter adding the config, which applied formatting and auto-fixes across the codebase (import ordering, unnecessary comprehensions, redundantlist()calls, blank-line/formatting normalization) with no functional changes.Additional context
Migrating to beeware/beeware.github.io as part of migrating hosting to GitHub Pages.
PR Checklist:
Assisted-by: Claude Sonnet 5 (GitHub Copilot)