Skip to content

chore: use ruff for linting and formatting #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 2, 2025
Merged

chore: use ruff for linting and formatting #246

merged 10 commits into from
Jul 2, 2025

Conversation

taeold
Copy link
Collaborator

@taeold taeold commented Jul 1, 2025

Summary

  • Replace pylint and yapf with ruff for modern Python linting and formatting
  • Apply ruff formatting across codebase
  • Fix all linting issues

Changes

1. Added ruff configuration in pyproject.toml

  • Settings that match Google style guide while adopting modern defaults
  • Configured linting rules and formatting options

2. Updated CI workflows

  • Removed pylint, replaced with ruff for linting
  • Replaced yapf with ruff for formatting checks

3. Applied ruff formatting and linting fixes

  • Formatted all Python files (56 files reformatted)
  • Fixed 18 linting issues including:
    • Import organization and ordering
    • Modernized isinstance() calls to use | operator
    • Converted .format() to f-strings
    • Simplified path comparisons
    • Removed trailing whitespace
    • Updated type hints to use built-in types
    • Implemented hash method for Sentinel class
    • Added noqa comments for intentional exception patterns

4. Removed legacy tools

  • Deleted .pylintrc configuration
  • Removed yapf configuration from pyproject.toml
  • Removed pylint from setup.py dependencies
  • Updated CONTRIBUTING.md documentation
  • Updated VS Code settings to use ruff

5. Fixed import issues

  • Restored public API exports that were accidentally removed during import reorganization
    • Timezone in scheduler_fn.py
    • AlertType in alerts_fn.py

6. Added .git-blame-ignore-revs

  • Preserves git blame history through the large formatting commit

taeold added 2 commits July 1, 2025 09:57
- Add ruff to dev dependencies
- Configure ruff in pyproject.toml to match Google style
- Add ruff linting to CI alongside pylint
- Replace yapf with ruff format in CI
- Remove yapf from dependencies
- Add .git-blame-ignore-revs for formatting commit
Apply ruff formatting to entire codebase. This is a one-time
formatting change to adopt modern Python formatting standards.

Main changes:
- Consistent double quotes for strings
- Trailing commas in multi-line function parameters
- Standardized spacing and line breaks
- Removed trailing whitespace

No functional changes - formatting only.
taeold added 7 commits July 1, 2025 10:06
- Auto-fixed 13 issues with --unsafe-fixes:
  - Import reordering for better organization
  - Modernized isinstance() calls to use | operator
  - Converted .format() to f-strings
  - Simplified path comparisons
  - Converted generator to dict comprehension
  - Removed trailing whitespace
  - Updated type hints from typing module to built-in types

- Manual fixes:
  - Added noqa comments for exception chaining (B904) where existing pattern is intentional
  - Implemented __hash__ method for Sentinel class to properly support equality comparison
- Remove pylint from CI workflow and setup.py
- Delete .pylintrc configuration file
- Remove yapf configuration from pyproject.toml
- Update CONTRIBUTING.md to use ruff commands
- Update VS Code settings to use ruff formatter and linter
- Fix missing imports that were removed during ruff import reorganization:
  - Restore Timezone export in scheduler_fn.py
  - Restore AlertType export in alerts_fn.py
- Format remaining files with ruff formatter
- Add clear comments explaining why Timezone and AlertType are re-exported
- Add noqa: F401 to suppress unused import warnings for intentional re-exports
- Fix import ordering to satisfy ruff
- Mypy doesn't understand dynamic attributes on Callable types
- Add type: ignore comment to suppress the error
- This is a common pattern for decorators that add attributes
@taeold taeold changed the title chore: add ruff for linting and formatting chore: use ruff for linting and formatting Jul 1, 2025
@taeold
Copy link
Collaborator Author

taeold commented Jul 1, 2025

/gemini review

@taeold
Copy link
Collaborator Author

taeold commented Jul 1, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is an excellent pull request that successfully migrates the project from pylint and yapf to ruff. The changes are comprehensive, covering not only the code formatting and linting fixes but also updating the configuration, developer documentation, and editor settings. The addition of .git-blame-ignore-revs is a thoughtful touch that will maintain the quality of the git history.

The new ruff configuration in pyproject.toml is well-structured and the selected rules and ignores are sensible for a project of this nature. The automated code changes, such as modernizing type hints and using f-strings, are great improvements.

I've reviewed all the changes carefully and found no issues of medium or higher severity. The migration appears to be executed flawlessly. Great work!

@taeold taeold merged commit 4e674e7 into main Jul 2, 2025
11 checks passed
@taeold taeold deleted the add-ruff-formatter branch July 2, 2025 03:02
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.

1 participant