Skip to content

Add ruff for linting and formatting Python scripts - #819

Closed
Aruna-Mani wants to merge 1 commit into
beeware:mainfrom
Aruna-Mani:main
Closed

Add ruff for linting and formatting Python scripts#819
Aruna-Mani wants to merge 1 commit into
beeware:mainfrom
Aruna-Mani:main

Conversation

@Aruna-Mani

Copy link
Copy Markdown

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 to pyproject.toml, using Toga's ruleset as a base (E, W, F, UP, B, ASYNC, C4, I), plus a ruff-pre-commit hook (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/DTZ011 are ignored globally, since blog/event post metadata dates are intentionally date-only and never need timezone awareness.
  • E501 (line length) is ignored per-file for macros.py and new_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-files after adding the config, which applied formatting and auto-fixes across the codebase (import ordering, unnecessary comprehensions, redundant list() 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:

  • I will abide by the BeeWare Code of Conduct
  • I have read and have followed the CONTRIBUTING.md file
  • This PR was generated or assisted using an AI tool

Assisted-by: Claude Sonnet 5 (GitHub Copilot)

@freakboy3742

Copy link
Copy Markdown
Member

Thanks for the PR; unfortunately, it looks like sprint conditions have led to two people working on the same issue at the same time (see #820). Although this one arrived first, the author of #820 dropped a note first to "claim" the issue, so I'm going to close this version in favour of that one.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants