Add isort config and sort imports - #239
Open
john-s-morgan wants to merge 3 commits into
Open
Conversation
Enforce consistent import ordering across the codebase. Uses the Black-compatible wrapping style (matches the dominant single-line convention while preserving existing vertical import blocks). - Skips generated migrations. - Skips racetime/views/__init__.py, whose imports are hand-ordered to pair each view with its OAuth variant.
Apply the isort configuration across the codebase. No functional changes.
john-s-morgan
marked this pull request as ready for review
July 10, 2026 21:20
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 this is
Adds isort, a tool that keeps
importstatements in a consistent order; plus a one-time pass applying it across the codebase.Why bother
Right now import order is freeform, so it drifts. In practice that costs us three small-but-recurring things:
None of these are on fire. This is a papercut fix.
What it does not change
racetime/views/__init__.pyis skipped: its imports are deliberately hand-ordered to pair each view with its OAuth variant (RaceChatPinnext toOAuthRaceChatPin). The config respects that instead of flattening it, since we can't auto-sort while preserving that intent.How it's structured
Two commits, so you can review the decision separately from the churn:
Add isort configuration: just.isort.cfg(~9 lines). This is the only part that's a decision; read this one.Sort imports with isort: the mechanical result of running the tool. 27 files, all reordering. You can skim or trust it; it's reproducible by runningisort ..What you have to do going forward
Nothing required. If you ever want to keep it tidy,
pip install isort && isort .reformats everything; running it twice is a no-op. If you decide you hate it, deleting.isort.cfgreverts to freeform with no other cleanup.If you love it and want it enforced automatically
Happy to follow up with a CI check (
isort --check) and/or a pre-commit hook so it stays consistent without anyone thinking about it. if you'd prefer