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

lint and upgrade #122

Merged
merged 3 commits into from
Nov 25, 2024
Merged

lint and upgrade #122

merged 3 commits into from
Nov 25, 2024

Conversation

jschlyter
Copy link
Member

@jschlyter jschlyter commented Nov 25, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced the AggregateMetadataResponse class with example values for better API documentation clarity.
  • Bug Fixes

    • Improved error handling and messaging for invalid aggregate intervals to provide clearer guidance.
  • Chores

    • Updated the version of the Ruff dependency to ensure compatibility with the latest features and improvements.
    • Modernized type annotations across various components for improved code clarity and consistency.

@jschlyter jschlyter requested a review from a team as a code owner November 25, 2024 06:25
Copy link

coderabbitai bot commented Nov 25, 2024

Walkthrough

The changes in this pull request involve updates to several files, primarily focusing on type annotations and dependency versions. The .pre-commit-config.yaml file has been modified to update the version of the Ruff pre-commit hook from v0.7.2 to v0.8.0. In aggrec/aggregates.py, type annotations have been modernized, and example values have been added to the AggregateMetadataResponse class. Similarly, aggrec/settings.py has seen updates in type annotations. Lastly, the pyproject.toml file reflects the updated dependency version for Ruff.

Changes

File Change Summary
.pre-commit-config.yaml Updated Ruff pre-commit hook version from v0.7.2 to v0.8.0.
aggrec/aggregates.py Removed List and Dict imports; updated type annotations to list[str] and dict[str, str]; added example values to AggregateMetadataResponse.
aggrec/settings.py Removed Tuple and Type imports; updated settings_customise_sources method parameter and return type to use type and tuple.
pyproject.toml Updated ruff dependency version from >=0.6.3 to >=0.8.0.

Poem

🐇 In the garden where code does bloom,
A rabbit hops, dispelling gloom.
With types refined and hooks anew,
The code now dances, fresh as dew.
Let’s celebrate with joyful cheer,
For every change brings progress near! 🌼

Warning

Rate limit exceeded

@jschlyter has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 27 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

Reviewing files that changed from the base of the PR and between 324fc28 and af41652.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 324fc28 and af41652.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • aggrec/aggregates.py (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • aggrec/aggregates.py

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>, please review it.
    • Generate unit testing code for this file.
    • 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 generate unit testing code 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 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 generate unit testing code.
    • @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.

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

@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: 0

🧹 Outside diff range and nitpick comments (3)
pyproject.toml (1)

Line range hint 89-106: Consider enabling additional Ruff rules

With Ruff 0.8.0, you could enhance code quality by enabling additional rule sets:

  • RUF for Ruff-specific rules
  • TCH for type-checking
  • PLC for pylint conventions
  • PT for pytest style

Consider adding these to your select list in the Ruff configuration:

 select = [
     # pycodestyle
     "E",
     # Pyflakes
     "F",
     # pyupgrade
     "UP",
     # flake8-bugbear
     "B",
     # flake8-simplify
     "SIM",
     # isort
     "I",
+    # Ruff-specific rules
+    "RUF",
+    # Type checking
+    "TCH",
+    # Pylint conventions
+    "PLC",
+    # Pytest style
+    "PT",
 ]
aggrec/aggregates.py (2)

Line range hint 64-93: LGTM! Well-structured response model

The AggregateMetadataResponse class is well-designed with:

  • Clear field definitions with descriptive titles
  • Proper type hints including optional fields
  • Clean conversion from DB model

Consider adding examples to the field descriptions for better API documentation.

Add example values to the Field descriptions:

-    aggregate_id: str = Field(title="Aggregate identifier")
+    aggregate_id: str = Field(title="Aggregate identifier", example="507f1f77bcf86cd799439011")
-    content_type: str = Field(title="Content MIME type")
+    content_type: str = Field(title="Content MIME type", example="application/vnd.apache.parquet")

Line range hint 213-277: LGTM! Enhanced parameter documentation

The function's parameter documentation has been improved with:

  • Clear type annotations using Annotated
  • Detailed descriptions for signature requirements
  • Example values where appropriate

Consider enhancing the error message for invalid aggregate intervals.

Make the error message more descriptive:

-            raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, "Invalid Aggregate-Interval")
+            raise HTTPException(
+                status.HTTP_422_UNPROCESSABLE_ENTITY,
+                "Invalid Aggregate-Interval: must be an ISO 8601 time interval (e.g., '2024-01-01T12:00:00Z/PT1M')"
+            )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 022a1d1 and 324fc28.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • .pre-commit-config.yaml (1 hunks)
  • aggrec/aggregates.py (2 hunks)
  • aggrec/settings.py (2 hunks)
  • pyproject.toml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .pre-commit-config.yaml
🔇 Additional comments (4)
pyproject.toml (1)

32-32: Verify Ruff upgrade compatibility

The Ruff upgrade from >=0.6.3 to >=0.8.0 is significant. While the change looks good, please ensure compatibility with the existing configuration.

Let's verify the compatibility and check for any breaking changes:

✅ Verification successful

Let's gather more information about the project's Ruff configuration and usage to ensure compatibility.


Ruff upgrade is safe to proceed

The upgrade from Ruff 0.6.3 to 0.8.0 is compatible with the current configuration:

  • The project uses standard ruff rules (E, F, UP, B, SIM, I) which are core rules supported across versions
  • The configuration is simple and doesn't use any advanced features
  • pytest-ruff requires ruff>=0.0.242, making it fully compatible with 0.8.0
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check Ruff changelog for breaking changes and verify pytest-ruff compatibility

# Get Ruff changelog for versions between 0.6.3 and 0.8.0
echo "Checking Ruff changelog for breaking changes..."
gh api repos/astral-sh/ruff/releases --paginate | \
  jq -r '.[] | select(.tag_name | startswith("v0.")) | select(.tag_name >= "v0.6.3" and .tag_name <= "v0.8.0") | "\(.tag_name)\n\(.body)"'

# Check if current pytest-ruff version supports Ruff 0.8.0
echo "Checking pytest-ruff compatibility..."
curl -s https://pypi.org/pypi/pytest-ruff/json | jq -r '.info.requires_dist[] | select(contains("ruff"))'

Length of output: 500


Script:

#!/bin/bash
# Check Ruff configuration in pyproject.toml and any potential usage patterns
echo "Checking Ruff configuration..."
cat pyproject.toml | grep -A 20 "\[tool.ruff\]"

# Look for any Ruff-specific rule configurations or plugins
echo -e "\nChecking for Ruff rule usage..."
rg "ruff: " -A 2

# Check for any Ruff configuration files
echo -e "\nChecking for additional Ruff config files..."
fd -e toml -e ini -e yaml -e yml | grep -i "ruff"

Length of output: 645

aggrec/settings.py (1)

60-60: LGTM! Type hint modernization looks good.

The changes align with PEP 585, using built-in collection types (type, tuple) instead of their typing module counterparts. This is a good modernization that maintains compatibility while reducing imports.

Let's verify if there are any remaining outdated type hints that could be modernized:

Also applies to: 65-65

✅ Verification successful

Type hint modernization is complete and consistent

The verification confirms that there are no remaining instances of typing.Type or typing.Tuple in the codebase, indicating that the type hint modernization has been thoroughly applied. The changes in aggrec/settings.py are part of a complete modernization effort.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of typing.Type and typing.Tuple in the codebase
# that could potentially be modernized to use built-in types.

echo "Checking for remaining usage of typing.Type and typing.Tuple..."
rg -l "from typing import .*(?:Type|Tuple)" || true

echo "Checking for direct usage of Type[] or Tuple[]..."
rg "(?:Type|Tuple)\[" || true

Length of output: 329

aggrec/aggregates.py (2)

7-7: LGTM! Modern type hint imports

The changes appropriately modernize the type hint imports by:

  • Using built-in collection types directly (e.g., list, dict) instead of typing imports
  • Adding Annotated for enhanced type metadata in FastAPI parameters

106-106: LGTM! Updated type hints

The function signature has been appropriately modernized to use built-in collection types for type hints while maintaining the same robust functionality.

@jschlyter jschlyter merged commit 6a96b37 into main Nov 25, 2024
5 checks passed
@jschlyter jschlyter deleted the lint branch November 25, 2024 06:43
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.

1 participant