Skip to content

Conversation

@Devasy
Copy link
Owner

@Devasy Devasy commented Jul 26, 2025

Introduce a pre-commit configuration that integrates Black, isort, and autopep8 for consistent code formatting.

Summary by CodeRabbit

  • Chores
    • Added configuration for automated code formatting and import sorting to run before commits.
    • Improved code style, formatting, and import organization across the backend codebase.
    • Enhanced authentication service with new refresh token and password reset token generation.
    • Refined error handling consistency and logging in authentication and user services.
    • Updated tests for better readability and robustness without changing test coverage or logic.

@netlify
Copy link

netlify bot commented Jul 26, 2025

Deploy Preview for splitwizer canceled.

Name Link
🔨 Latest commit 8b83890
🔍 Latest deploy log https://app.netlify.com/projects/splitwizer/deploys/6885150691d8c80008f4b0fd

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 26, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update introduces a .pre-commit-config.yaml file configuring pre-commit hooks for code formatting and import sorting tools Black, isort, and autopep8, each pinned to stable versions. Additionally, extensive codebase-wide reformatting and import reorganizations were applied across authentication, expenses, groups, user modules, and tests to improve readability and consistency without changing functionality.

Changes

File(s) Change Summary
.pre-commit-config.yaml Added pre-commit configuration for Black 24.8.0, isort 5.13.2, and autopep8 v2.3.1 hooks.
backend/app/auth/* (all files: init.py, routes.py, schemas.py, security.py, service.py) Reorganized imports, reformatted code for readability, improved error handling consistency, added new token generation functions, and enhanced Firebase initialization style without logic changes.
backend/app/config.py Reformatted imports and logging middleware code for clarity; no logic changes.
backend/app/database.py Consolidated and reordered imports; minor formatting fixes.
backend/app/dependencies.py Reordered imports, reformatted function signatures and whitespace; no logic changes.
backend/app/expenses/* (routes.py, schemas.py, service.py) Reformatted imports, function signatures, and code style for readability; no functional changes.
backend/app/groups/* (routes.py, schemas.py, service.py) Reorganized imports, reformatted code and function signatures for clarity; no logic changes.
backend/app/user/* (routes.py, schemas.py, service.py) Reordered imports, reformatted code and function signatures; no logic or behavior changes.
backend/generate_secret.py Reformatted string concatenation and spacing; no logic changes.
backend/main.py Reordered imports, added routers, reformatted middleware and endpoint code for clarity; no logic changes.
backend/tests/* (auth, expenses, groups, logger, user) Reformatted imports, function signatures, test data, and patching style for consistency and readability; no test logic changes.
backend/tests/conftest.py Reordered imports, enhanced debug print statements, reformatted patch calls; no logic changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

A rabbit hops through lines anew,
Formatting clean with tools in view.
Black and isort lead the way,
Autopep8 joins the fray.
Code now neat, a joy to see,
Commit with pride, wild and free!
🐇✨🎨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 541dd68 and 8b83890.

📒 Files selected for processing (29)
  • .pre-commit-config.yaml (1 hunks)
  • backend/app/auth/__init__.py (1 hunks)
  • backend/app/auth/routes.py (3 hunks)
  • backend/app/auth/schemas.py (2 hunks)
  • backend/app/auth/security.py (2 hunks)
  • backend/app/auth/service.py (3 hunks)
  • backend/app/config.py (3 hunks)
  • backend/app/database.py (1 hunks)
  • backend/app/dependencies.py (1 hunks)
  • backend/app/expenses/routes.py (9 hunks)
  • backend/app/expenses/schemas.py (10 hunks)
  • backend/app/expenses/service.py (25 hunks)
  • backend/app/groups/routes.py (1 hunks)
  • backend/app/groups/schemas.py (2 hunks)
  • backend/app/groups/service.py (12 hunks)
  • backend/app/user/routes.py (1 hunks)
  • backend/app/user/schemas.py (2 hunks)
  • backend/app/user/service.py (4 hunks)
  • backend/generate_secret.py (1 hunks)
  • backend/main.py (5 hunks)
  • backend/tests/auth/test_auth_routes.py (7 hunks)
  • backend/tests/conftest.py (3 hunks)
  • backend/tests/expenses/test_expense_routes.py (4 hunks)
  • backend/tests/expenses/test_expense_service.py (45 hunks)
  • backend/tests/groups/test_groups_routes.py (7 hunks)
  • backend/tests/groups/test_groups_service.py (12 hunks)
  • backend/tests/logger/test_logger.py (3 hunks)
  • backend/tests/user/test_user_routes.py (5 hunks)
  • backend/tests/user/test_user_service.py (9 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/adds-precommit

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.pre-commit-config.yaml (1)

1-15: Terminate file with a newline

YAML-lint flags the missing trailing newline. Adding one keeps linters quiet and follows POSIX text-file conventions.

       - id: autopep8
+
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 969ef81 and 541dd68.

📒 Files selected for processing (1)
  • .pre-commit-config.yaml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.pre-commit-config.yaml

[error] 15-15: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (1)
.pre-commit-config.yaml (1)

12-15: Re-evaluate the need for autopep8; it overlaps with Black

Black already enforces a complete formatting style. Running autopep8 afterwards adds no value and can even undo Black’s choices, causing pointless churn in commits. Consider removing this hook (or disabling it for Python files) unless you have a very specific use-case that Black cannot cover.

@github-project-automation github-project-automation bot moved this to Backlog in Splitwiser Jul 26, 2025
@Devasy Devasy moved this from Backlog to In review in Splitwiser Jul 26, 2025
@Devasy Devasy merged commit 0e940a3 into main Jul 26, 2025
7 of 8 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in Splitwiser Jul 26, 2025
@Devasy Devasy deleted the feat/adds-precommit branch July 26, 2025 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants