Skip to content

Enable more ruff rules#51

Merged
JosephMarinier merged 2 commits intomainfrom
joseph/enable-more-ruff-rules
Apr 9, 2026
Merged

Enable more ruff rules#51
JosephMarinier merged 2 commits intomainfrom
joseph/enable-more-ruff-rules

Conversation

@JosephMarinier
Copy link
Copy Markdown
Collaborator

@JosephMarinier JosephMarinier commented Apr 9, 2026

Enable more Ruff rules to automatically (among other things):

  • Replace Optional[a] with a | None
    • I find the name Optional misleading since a function argument (or a Pydantic field) may be Optional and "required" if it doesn't have a default value.
  • Replace from typing import with from collections.abc import in cases where typing is deprecated
  • Replace a if a else b with a or b
  • Replace aliased asyncio.TimeoutError with TimeoutError
  • Replace alias Type with type keyword
    • This would also cover decrecated aliases like List -> list, Dict -> dict, etc.
  • Remove unnecessary mode argument "r" from open()
  • Replace f.write() in a for loop with f.writelines()
  • Replace datetime.timezone.utc with datetime.UTC

to automatically:

- Replace `Optional[a]` with `a | None`
- Replace `from typing import` with `from collections.abc import` in cases where `typing` is deprecated
- Replace `a if a else b` with `a or b`
- Replace aliased `asyncio.TimeoutError` with `TimeoutError`
- Replace alias `Type` with `type` keyword
- Remove unnecessary mode argument `"r"` from `open()`
- Replace `f.write()` in a `for` loop with `f.writelines()`
- Replace `datetime.timezone.utc` with `datetime.UTC`
Copy link
Copy Markdown
Collaborator

@gabegma gabegma left a comment

Choose a reason for hiding this comment

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

So satisfying!

@JosephMarinier JosephMarinier added this pull request to the merge queue Apr 9, 2026
Merged via the queue into main with commit a8e4779 Apr 9, 2026
1 check passed
@JosephMarinier JosephMarinier deleted the joseph/enable-more-ruff-rules branch April 9, 2026 15:06
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