-
Notifications
You must be signed in to change notification settings - Fork 18
chore(formatting): add black as the standard Python code formatter #368
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
chore(formatting): add black as the standard Python code formatter #368
Conversation
WalkthroughThis update introduces Black as the project's standard Python code formatter. It adds configuration files for Black and pre-commit, updates VSCode settings to use Black, modifies linting and pre-commit requirements, and documents formatting requirements in the contributing guidelines. All Python source files are reformatted for consistency, without changing any logic. Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Git
participant Pre-commit
participant Black
Developer->>Git: git commit
Git->>Pre-commit: Run pre-commit hooks
Pre-commit->>Black: Format Python files
Black-->>Pre-commit: Formatted code (if needed)
Pre-commit-->>Git: Allow or block commit based on formatting
Possibly related issues
Possibly related PRs
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure ✨ Finishing Touches
🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.pre-commit-config.yaml (1)
6-6: Add newline at end of file
YAML linters expect a trailing newline. Please append an empty line after line 6.+🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 6-6: no new line character at the end of file
(new-line-at-end-of-file)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
.pre-commit-config.yaml(1 hunks).vscode/settings.json(1 hunks)CONTRIBUTING.md(1 hunks)databases/player_database.py(2 hunks)main.py(3 hunks)models/player_model.py(3 hunks)pyproject.toml(1 hunks)requirements-lint.txt(1 hunks)requirements-pre-commit(1 hunks)routes/health_route.py(1 hunks)routes/player_route.py(9 hunks)schemas/player_schema.py(2 hunks)services/player_service.py(5 hunks)tests/player_stub.py(2 hunks)tests/test_main.py(16 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
tests/test_main.py (2)
tests/player_stub.py (3)
existing_player(33-49)nonexistent_player(52-68)unknown_player(71-81)tests/conftest.py (1)
client(11-22)
🪛 YAMLlint (1.37.1)
.pre-commit-config.yaml
[error] 6-6: no new line character at the end of file
(new-line-at-end-of-file)
🪛 Ruff (0.11.9)
routes/player_route.py
45-45: Do not perform function call Body in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
(B008)
46-46: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
(B008)
76-76: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
(B008)
105-105: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
(B008)
135-135: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
(B008)
169-169: Do not perform function call Body in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
(B008)
170-170: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
(B008)
201-201: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
(B008)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (36)
routes/health_route.py (1)
7-12: Formatting changes applied by Black.
Blank lines were added before and after the import statement and before the route decorator to conform with the Black formatter’s default spacing rules.requirements-pre-commit (1)
1-1: Add pre-commit dependency.
Pinningpre-commit==4.2.0ensures the Git hook framework is consistently installed across environments.schemas/player_schema.py (1)
34-40: Update SQLAlchemy column naming delimiters.
String delimiters for thenameparameter inColumn(...)calls have been converted from single to double quotes, aligning with Black’s default string normalization. No functional behavior was altered..vscode/settings.json (1)
11-11: Set Black as the default VSCode formatter.
The workspace setting for Python formatting has been updated to usems-python.black-formatteron save, matching the project’s new formatting standard.pyproject.toml (1)
1-3: Add Black configuration to pyproject.toml.
Defined Black’s settings (line length 88, target Python 3.12) to drive consistent formatting via CLI and editor integrations.requirements-lint.txt (1)
2-2: Add Black to lint requirements.
The addition ofblack==25.1.0complements the existingflake8dependency and enables automatic code formatting as intended.tests/player_stub.py (2)
18-18: Add trailing comma for Black compliance.
The trailing comma onstarting11=Nonealigns with Black’s style for multi-line argument lists.
80-80: Add trailing comma for Black compliance.
Including a comma afterposition="Lipsum",ensures consistency with Black’s default formatting.databases/player_database.py (3)
11-11: Insert blank line after module docstring.
A blank line was added following the docstring, improving separation and matching Black’s formatting rules.
25-25: Reformatcreate_async_enginecall.
Black consolidated the arguments onto a single line without altering functionality, enhancing conciseness.
29-29: Reformatsessionmakerinstantiation.
The inline formatting ofsessionmaker(...)follows Black’s conventions for cleaner code style.services/player_service.py (4)
14-14: Add blank line after module docstring.
This blank line separation is consistent with Black’s default layout between docstrings and imports.
46-46: Insert blank line for section separation.
Black formatted a blank line after the function’s closing docstring to delineate sections clearly.
82-84: Split long function signature per Black style.
Theretrieve_by_squad_number_asyncsignature is now broken into multiple lines, adhering to Black’s line-length and readability rules.
100-100: Add blank line before next section.
A blank line was introduced to separate the retrieve and update sections, matching Black’s formatting.models/player_model.py (3)
9-9: Insert blank line after module docstring.
This blank line placement aligns with Black’s standard for spacing between docstring and imports.
28-28: Add blank line before class attribute.
Separates the class-level docstring from themodel_configattribute, consistent with Black’s formatting.
49-49: Add blank line before field definitions.
Improves readability by inserting a blank line between thePlayerModeldocstring and its field declarations, per Black’s style.main.py (3)
10-10: Approve blank line after module docstring
The added blank line after the docstring improves separation between documentation and imports, enhancing readability.
21-22: Approve blank line before lifespan handler
Inserting a blank line before the@asynccontextmanagerdecorator cleanly separates lifecycle logic from global setup.
31-36: Approve multi-line FastAPI instantiation
Reformatting theFastAPIconstructor to multi-line promotes clarity and aligns with the Black configuration. No logic was changed.CONTRIBUTING.md (1)
47-53: Approve new "6. Formatting" section
The guidelines clearly mandate Black as the standard formatter and recommend setting up a pre-commit hook. This aligns perfectly with the rest of the PR..pre-commit-config.yaml (2)
1-6: Approve pre-commit configuration for Black
Pinning Black to25.1.0and configuring the hook ensures consistent formatting on every commit.🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 6-6: no new line character at the end of file
(new-line-at-end-of-file)
2-4: Verify Python language version alignment
The hook useslanguage_version: python3.13.3butpyproject.tomltargets Python 3.12. Ensure the pre-commit environment matches the supported Python runtime (or update one of the configurations).routes/player_route.py (10)
19-19: Approve blank line after module docstring
The inserted blank line enhances readability by separating the top-level documentation from code.
32-33: Approve constant separation
Adding a blank line betweenCACHE_KEYandCACHE_TTLgroups related constants clearly.
42-42: Approve trailing comma on decoratortagsargument
Including a trailing comma is consistent with Black's style and future-proofs against adding more tags.
45-46: Approve multi-linepost_asyncsignature formatting
Splitting theBodyandDependsparameters onto separate lines improves readability without changing functionality.🧰 Tools
🪛 Ruff (0.11.9)
45-45: Do not perform function call
Bodyin argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable(B008)
46-46: Do not perform function call
Dependsin argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable(B008)
75-76: Approve multi-lineget_all_asyncsignature formatting
Aligning parameters on their own line follows the Black formatter's conventions.🧰 Tools
🪛 Ruff (0.11.9)
76-76: Do not perform function call
Dependsin argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable(B008)
101-101: Approve trailing comma onget_by_id_asyncdecorator tags
Consistent use of trailing commas in decorator arguments improves diff friendliness.
105-105: Approve trailing comma onget_by_id_asyncdependency
Maintains consistency in argument list formatting across functions.🧰 Tools
🪛 Ruff (0.11.9)
105-105: Do not perform function call
Dependsin argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable(B008)
135-135: Approve trailing comma onget_by_squad_number_asyncdependency
Helps keep argument formatting consistent and aligned.🧰 Tools
🪛 Ruff (0.11.9)
135-135: Do not perform function call
Dependsin argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable(B008)
169-170: Approve multi-lineput_asyncsignature formatting
SeparatingBodyandDependsparameters onto individual lines improves clarity.🧰 Tools
🪛 Ruff (0.11.9)
169-169: Do not perform function call
Bodyin argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable(B008)
170-170: Do not perform function call
Dependsin argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable(B008)
201-201: Approve trailing comma ondelete_asyncdependency
Consistent formatting for function parameters, no behavior change.🧰 Tools
🪛 Ruff (0.11.9)
201-201: Do not perform function call
Dependsin argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable(B008)
tests/test_main.py (2)
18-18: Approve blank line after module-level docstring
Separating the file docstring from imports/tests with a blank line enhances readability.
27-29: Approve multi-line test function signatures
Reformatting the test definitions to placeclienton its own line and align docstrings is consistent with Black formatting and does not alter any assertions or logic.Also applies to: 45-47, 61-63, 78-80, 92-94, 113-115, 129-131, 145-147, 165-167, 181-183, 197-199, 217-219, 233-235, 250-252, 270-272, 287-289, 305-307, 344-346
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #368 +/- ##
=======================================
Coverage 89.65% 89.65%
=======================================
Files 3 3
Lines 116 116
=======================================
Hits 104 104
Misses 12 12
🚀 New features to boost your workflow:
|
|
Thanks for this contribution @Marcusfam-RB! 🙌 The changes look great — clean, thoughtful, and very well put together. I’ve added a couple of review comments just to clarify a few details, but overall everything looks solid and really well aligned with the project. Appreciate the attention to detail here — great work so far! 💯 |
|
|
Thanks again for this contribution @Marcusfam-RB — it's clear you've put in solid effort and your changes are mostly spot on. I left a few review comments a few days ago that still need to be addressed. Since it's been a bit quiet, I'm going to close this PR for now to avoid it lingering indefinitely. That said, I really appreciate your work — I’ll incorporate your changes (along with the requested tweaks) in a follow-up commit so your effort still makes it into the project. If you'd like to revisit this in the future, feel free to re-open or submit a new PR. Thanks again! |



Integrate Black code formatter across the project
This change is
Summary by CodeRabbit
New Features
Style
Chores