Skip to content
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

Adding pre commit hooks #26

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

matiasz8
Copy link

@matiasz8 matiasz8 commented Jan 18, 2024

What's this PR do?

This pull request enhances the existing pre-commit hooks and introduces additional hooks for improved code quality.
Upon running these hooks, I have addressed issues in other files, ensuring a more robust and reliable codebase.

@ulises-jeremias @edamico @Tsemenzato

Summary by CodeRabbit

  • Refactor

    • Enhanced code quality with new pre-commit hooks for consistency and style checks.
    • Reordered import statements across various modules for better readability.
  • Dependencies

    • Updated Python version to 3.10.13 for improved performance and security.
    • Added pre-commit to the project dependencies for automated code review checks.
  • Chores

    • Cleaned up unused imports and added necessary ones across several modules.

Copy link

coderabbitai bot commented Jan 18, 2024

Warning

Rate Limit Exceeded

@matiasz8 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 32 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between f39f8df and 47f1330.

Walkthrough

The recent updates encompass various aspects of the codebase. Import statement reorganization across multiple Python files ensures a consistent order and adherence to stylistic conventions. Additionally, there's an update to the Python version, the addition of pre-commit hooks for code quality checks, and the inclusion of pre-commit in the Pipfile. These changes aim to enhance code quality and maintainability without altering the core functionality of the codebase.

Changes

File(s) Change Summary
.pre-commit-config.yaml Updated to include new hooks for code quality checks.
.python-version Python version updated from 3.10.10 to 3.10.13.
Pipfile Added pre-commit as a dependency.
jobs/etl/__init__.py, jobs/io/__init__.py, libs/common/__init__.py, libs/config/__init__.py Reordered import statements.
jobs/etl/extract.py, jobs/io/reader.py, jobs/io/writer.py, libs/db/docdb_mongo.py Modified or reordered import statements.
jobs/etl/load_s3.py, jobs/pyspark_hello_world.py, libs/aws/s3.py Reordered imports and added new ones.
jobs/io/helpers.py, libs/db/mongo.py, libs/config/env.py Updated type annotations, function signatures, and import statements.
.github/workflows/lint.yml Added a step to install dependencies using pipenv before running the Super-Linter.

Poem

🌟 Code hops along, neat and spry, 🐇
Imports aligned, beneath the sky.
With each commit, we tidy the den,
'Til the burrow shines, time and again. 🌟

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit-tests for this file.
  • 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 generate unit tests for this file.
    • @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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@matiasz8 matiasz8 changed the title feat(hooks): Adding Hooks feat(hooks): Adding pre commit hooks Jan 18, 2024
@matiasz8 matiasz8 changed the title feat(hooks): Adding pre commit hooks Adding pre commit hooks Jan 18, 2024
Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between aa5e12f and 930fcdc.
Files ignored due to path filters (1)
  • Pipfile.lock is excluded by: !**/*.lock
Files selected for processing (18)
  • .github/PULL_REQUEST_TEMPLATE.md (1 hunks)
  • .pre-commit-config.yaml (1 hunks)
  • .python-version (1 hunks)
  • Pipfile (1 hunks)
  • jobs/etl/init.py (1 hunks)
  • jobs/etl/extract.py (1 hunks)
  • jobs/etl/load_s3.py (1 hunks)
  • jobs/io/init.py (1 hunks)
  • jobs/io/helpers.py (1 hunks)
  • jobs/io/reader.py (1 hunks)
  • jobs/io/writer.py (1 hunks)
  • jobs/pyspark_hello_world.py (1 hunks)
  • libs/aws/s3.py (1 hunks)
  • libs/common/init.py (1 hunks)
  • libs/config/init.py (1 hunks)
  • libs/config/secrets.py (1 hunks)
  • libs/db/docdb_mongo.py (1 hunks)
  • libs/db/mongo.py (1 hunks)
Files skipped from review due to trivial changes (9)
  • .github/PULL_REQUEST_TEMPLATE.md
  • .python-version
  • jobs/etl/load_s3.py
  • jobs/io/init.py
  • jobs/io/reader.py
  • jobs/io/writer.py
  • libs/config/init.py
  • libs/config/secrets.py
  • libs/db/docdb_mongo.py
Additional comments: 11
libs/common/__init__.py (1)
  • 1-2: The reordering of imports in libs/common/__init__.py is correct and follows the alphabetical order which is a common convention in Python.
jobs/etl/__init__.py (1)
  • 1-4: The reordering of imports in jobs/etl/__init__.py is correct and follows the alphabetical order which is a common convention in Python.
Pipfile (1)
  • 20-20: Adding pre-commit as a dependency in the Pipfile is appropriate as it is necessary for the new pre-commit hooks to function.
jobs/etl/extract.py (1)
  • 7-7: The re-import of libs.config.Config in jobs/etl/extract.py is correct and does not change the functionality, assuming the import was not removed elsewhere in the file.
jobs/pyspark_hello_world.py (1)
  • 8-8: The reordering of imports and the addition of extract, load_to_postgresql_db, and load_to_s3 in jobs/pyspark_hello_world.py is correct. However, ensure that the commented-out import load_to_document_db is intentional and that its functionality is not required elsewhere in the code.
Verification successful

The commented-out import load_to_document_db in jobs/pyspark_hello_world.py is not actively used within that file. The function is defined in the jobs/etl module, but there is no indication from the current context that it is required in jobs/pyspark_hello_world.py. The review comment is consistent with the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify if the commented-out import `load_to_document_db` is used elsewhere in the code.
rg --type py 'load_to_document_db'

Length of output: 374



Script:

#!/bin/bash
# Check for any active usage of load_to_document_db in jobs/pyspark_hello_world.py
rg 'load_to_document_db' jobs/pyspark_hello_world.py

Length of output: 161

.pre-commit-config.yaml (1)
  • 4-27: The updates to .pre-commit-config.yaml are correct and include a comprehensive set of hooks for code quality checks. Ensure that the hooks are compatible with the project's existing codebase and that they do not introduce any breaking changes.
libs/aws/s3.py (3)
  • 1-1: The addition of the Union import in libs/aws/s3.py is correct and follows best practices for type hinting.
  • 2-2: The addition of the boto3 import in libs/aws/s3.py is correct, assuming it is used within the file.
  • 4-4: The removal of the unused import get_config from libs/aws/s3.py is a good practice to keep the code clean and maintainable.
libs/db/mongo.py (1)
  • 2-2: The addition of the PyMongoClient import in libs/db/mongo.py is correct and necessary for the MongoClient class to function properly.
jobs/io/helpers.py (1)
  • 3-3: The addition of the load_tls_ca_bundle import in jobs/io/helpers.py is correct, assuming it is used within the file.

Copy link
Member

@ulises-jeremias ulises-jeremias left a comment

Choose a reason for hiding this comment

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

🔥

Copy link

@nahuelgarcianan nahuelgarcianan left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@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.

Review Status

Actionable comments generated: 6

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 930fcdc and 035fde1.
Files selected for processing (3)
  • jobs/io/helpers.py (9 hunks)
  • libs/config/env.py (2 hunks)
  • libs/db/mongo.py (5 hunks)
Additional comments: 9
libs/db/mongo.py (2)
  • 1-1: The addition of Optional from the typing module is a good practice for indicating that certain parameters can be None. This enhances type safety and clarity in the codebase.
  • 92-92: Changing the return type of the find_one method to Optional[Dict[str, Any]] is a positive change that accurately reflects the possibility of the method returning None if no document matches the query. This is a good practice for type safety.
jobs/io/helpers.py (7)
  • 1-1: The addition of Optional to the import from the typing module is appropriate for the changes made to function signatures in this file, indicating that certain parameters can be None. This is a good practice for enhancing type safety and clarity.
  • 12-13: The use of Optional[str] for the user and password parameters in the get_url_for_engine function is a good practice that accurately reflects the optional nature of these parameters. This change improves the function's type safety and clarity.
  • 48-49: Similarly, applying Optional[str] to the user and password parameters in the _build_mongodb_connection_string function is a positive change that enhances the function's type safety by clearly indicating that these parameters can be None.
  • 65-65: The addition of Optional[str] to the authchars parameter in the _encode_mongodb_auth_special_chars function is a good practice. It accurately reflects that the parameter can be None, improving the function's type safety and clarity.
  • 112-112: Using Optional[str] for the engine parameter in the get_driver_for_engine function is a positive change that enhances type safety by clearly indicating that the parameter can be None.
  • 132-132: The application of Optional[str] to the engine parameter in the get_format_for_engine function is another good practice that improves type safety and clarity by indicating the optional nature of the parameter.
  • 154-167: The reordering of parameters in the get_connection_options function, specifically moving the ssl parameter to the end, and the use of Optional for several parameters, is a thoughtful change that enhances the function's readability and type safety. This modification makes the function's interface more intuitive and aligns with Python's convention of placing optional parameters at the end.

@@ -10,7 +10,7 @@ class EnvironmentVariable:
args = {}
cache = {}

def __init__(self, args: dict = None) -> None:
def __init__(self, args: dict = None) -> None: # type: ignore
Copy link

Choose a reason for hiding this comment

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

Adding # type: ignore to the __init__ method bypasses type checking for this method. Ensure that this is intentional and that the potential risks of skipping type checks are understood and mitigated.

libs/config/env.py Outdated Show resolved Hide resolved
libs/db/mongo.py Show resolved Hide resolved
libs/db/mongo.py Outdated Show resolved Hide resolved
libs/db/mongo.py Outdated Show resolved Hide resolved
libs/db/mongo.py Outdated Show resolved Hide resolved
Copy link

@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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 035fde1 and f39f8df.
Files selected for processing (3)
  • .github/workflows/lint.yml (2 hunks)
  • libs/config/env.py (3 hunks)
  • libs/db/mongo.py (5 hunks)
Files skipped from review as they are similar to previous changes (2)
  • libs/config/env.py
  • libs/db/mongo.py

.github/workflows/lint.yml Show resolved Hide resolved
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.

3 participants