Skip to content

Conversation

@andrewm4894
Copy link
Owner

@andrewm4894 andrewm4894 commented Jul 30, 2025

This pull request focuses on two main areas: improving import sorting and formatting in the codebase and enhancing the maintainability of the anomstack project. The most significant changes include replacing isort with ruff for import sorting, consolidating multi-line statements into single lines for readability, and minor import reordering.

Import Sorting and Configuration Updates:

  • .pre-commit-config.yaml: Removed isort as ruff now handles import sorting. Updated the ruff version and added the ruff-format hook.

Code Formatting Improvements:

Import Reordering:

  • anomstack/alerts/email.py, anomstack/alerts/slack.py, anomstack/alerts/send.py, and anomstack/config.py: Reordered imports to align with best practices (e.g., standard library imports first, followed by third-party and local imports). [1] [2] [3] [4]

These changes collectively aim to improve the codebase's maintainability, readability, and adherence to modern Python standards.

Summary by CodeRabbit

  • Style

    • Extensive formatting and stylistic improvements across the codebase, including consistent use of double quotes, improved indentation, and more readable multi-line expressions.
    • Import statements reordered for clarity and consistency.
    • Function and variable assignments reformatted for single-line or multi-line readability.
    • Trailing commas and whitespace adjustments for code cleanliness.
  • Chores

    • Updated pre-commit and linter configuration to use Ruff for linting and formatting, replacing isort and adjusting ignore rules.
    • Added Ruff configuration to project settings for standardized code style enforcement.
  • Tests

    • Test files updated for consistent formatting, quoting style, and improved readability; no changes to test logic or coverage.

No changes to application logic or user-facing features.

- Add pyproject.toml with comprehensive ruff configuration
- Increase line length limit to 100 characters for practicality
- Add per-file ignores for dashboard star imports and maintenance scripts
- Exclude Jupyter notebooks from strict linting
- Update .pre-commit-config.yaml to use latest ruff version
- Remove conflicting isort hook (ruff handles import sorting now)
- Add ruff-format for consistent code formatting
- Run pre-commit hooks on entire codebase (93 files reformatted)
- Fix import organization across all Python files
- Remove trailing whitespace and ensure consistent line endings
- Apply ruff formatting for consistent code style
- Fix minor linting issues like noqa directive formatting
- All pre-commit hooks now pass successfully
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 30, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This change is a comprehensive codebase-wide style and formatting update. It standardizes string quoting (favoring double quotes), consolidates multi-line statements into single lines where possible, and reorders import statements for consistency. Some configuration files are updated to reflect new linting practices, and function signatures are reformatted for clarity. No core logic, control flow, or exported entity functionality is altered.

Changes

Cohort / File(s) Change Summary
Pre-commit and Linting Configuration
.pre-commit-config.yaml, pyproject.toml
Updated Ruff linter configuration, removed isort, and updated pre-commit hooks to reflect Ruff's import sorting and new exclusions.
Import Reordering and Formatting
anomstack/alerts/email.py, anomstack/alerts/send.py, anomstack/alerts/slack.py, anomstack/df/resample.py, anomstack/df/save.py, anomstack/df/utils.py, anomstack/df/wrangle.py, anomstack/external/aws/s3.py, anomstack/external/clickhouse/clickhouse.py, anomstack/external/duckdb/duckdb.py, anomstack/external/gcp/bigquery.py, anomstack/external/gcp/credentials.py, anomstack/external/gcp/gcs.py, anomstack/external/sqlite/sqlite.py, anomstack/fn/run.py, anomstack/io/load.py, anomstack/io/save.py, anomstack/jinja/render.py, anomstack/jobs/alert.py, anomstack/jobs/change.py, anomstack/jobs/cleanup.py, anomstack/jobs/delete.py, anomstack/jobs/ingest.py, anomstack/jobs/llmalert.py, anomstack/jobs/plot.py, anomstack/jobs/reload.py, anomstack/jobs/score.py, anomstack/jobs/summary.py, anomstack/jobs/train.py, anomstack/llm/agent.py, anomstack/main.py, anomstack/ml/change.py, anomstack/ml/preprocess.py, anomstack/ml/threshold.py, anomstack/ml/train.py, anomstack/plots/plot.py, anomstack/sensors/config_reload.py, anomstack/sensors/failure.py, anomstack/sensors/timeout.py, anomstack/sql/read.py, anomstack/sql/translate.py, anomstack/validate/validate.py, dashboard/app.py, dashboard/batch_stats.py, dashboard/charts.py, dashboard/components/__init__.py, dashboard/components/common.py, dashboard/components/search.py, dashboard/components/settings.py, dashboard/components/toolbar.py, dashboard/data.py, dashboard/routes/batch.py, dashboard/routes/index.py, dashboard/routes/search.py, dashboard/state.py, dashboard/utils.py, dev.py, metrics/defaults/python/preprocess.py, metrics/examples/coindesk/coindesk.py, metrics/examples/currency/currency.py, metrics/examples/eirgrid/eirgrid.py, metrics/examples/github/github.py, metrics/examples/netdata/netdata.py, metrics/examples/netdata_httpcheck/netdata_httpcheck.py, metrics/examples/posthog/posthog.py, metrics/examples/prometheus/prometheus.py, metrics/examples/python/python_ingest_simple/ingest.py, metrics/examples/weather/ingest_weather.py, metrics/examples/yfinance/yfinance.py, notebooks/dev.ipynb, notebooks/run_qry.ipynb, scripts/configuration/reload_config.py, scripts/deployment/deploy_fly.sh, scripts/examples/posthog_example.py, scripts/maintenance/cleanup_disk_space.py, scripts/maintenance/kill_long_running_tasks.py, scripts/maintenance/list_long_running_tasks.py, scripts/sqlite/create_index.py, scripts/sqlite/list_indexes.py, scripts/sqlite/list_tables.py, scripts/sqlite/qry.py, setup.py
Reordered imports, standardized string quoting (favoring double quotes), removed unnecessary blank lines, consolidated multi-line statements, and added trailing commas for consistency. No logic or control flow changes.
Function Signature Formatting
anomstack/df/save.py, anomstack/df/wrangle.py, anomstack/external/aws/s3.py, anomstack/external/gcp/gcs.py, anomstack/io/save.py, anomstack/jinja/render.py, anomstack/llm/agent.py, anomstack/ml/threshold.py, anomstack/ml/train.py, dashboard/data.py
Reformatted function signatures from multi-line to single-line or vice versa for readability and style; no change in parameters or logic.
Test Suite Formatting
tests/test_alert_jobs.py, tests/test_alerts.py, tests/test_asciiart.py, tests/test_dashboard.py, tests/test_df.py, tests/test_duckdb.py, tests/test_email.py, tests/test_external_duckdb_simple.py, tests/test_io.py, tests/test_jobs.py, tests/test_llm.py, tests/test_main.py, tests/test_ml.py, tests/test_plots.py, tests/test_slack.py, tests/test_sql.py, tests/test_threshold.py, tests/test_timeout_sensor.py, tests/test_validate.py
Updated all test code for consistent double-quoted strings, expanded dictionary/DataFrame constructions, added trailing commas, and improved formatting. No test logic or assertions changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰✨
With every quote now double bright,
And imports ordered left to right,
The code is clean, the tests aligned,
Linting rules are redefined!
A bunny hops with gleeful cheer—
Style and order reign this year.
🥕💻

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 5718065 and af67b58.

📒 Files selected for processing (105)
  • .pre-commit-config.yaml (1 hunks)
  • anomstack/alerts/asciiart.py (11 hunks)
  • anomstack/alerts/email.py (4 hunks)
  • anomstack/alerts/send.py (2 hunks)
  • anomstack/alerts/slack.py (4 hunks)
  • anomstack/config.py (6 hunks)
  • anomstack/df/resample.py (1 hunks)
  • anomstack/df/save.py (1 hunks)
  • anomstack/df/utils.py (2 hunks)
  • anomstack/df/wrangle.py (6 hunks)
  • anomstack/external/aws/s3.py (2 hunks)
  • anomstack/external/clickhouse/clickhouse.py (3 hunks)
  • anomstack/external/duckdb/duckdb.py (1 hunks)
  • anomstack/external/gcp/bigquery.py (5 hunks)
  • anomstack/external/gcp/credentials.py (1 hunks)
  • anomstack/external/gcp/gcs.py (1 hunks)
  • anomstack/external/sqlite/sqlite.py (2 hunks)
  • anomstack/fn/run.py (1 hunks)
  • anomstack/io/load.py (1 hunks)
  • anomstack/io/save.py (2 hunks)
  • anomstack/jinja/render.py (1 hunks)
  • anomstack/jobs/alert.py (3 hunks)
  • anomstack/jobs/change.py (6 hunks)
  • anomstack/jobs/cleanup.py (8 hunks)
  • anomstack/jobs/delete.py (1 hunks)
  • anomstack/jobs/ingest.py (6 hunks)
  • anomstack/jobs/llmalert.py (8 hunks)
  • anomstack/jobs/plot.py (2 hunks)
  • anomstack/jobs/reload.py (3 hunks)
  • anomstack/jobs/score.py (7 hunks)
  • anomstack/jobs/summary.py (1 hunks)
  • anomstack/jobs/train.py (4 hunks)
  • anomstack/llm/agent.py (1 hunks)
  • anomstack/main.py (1 hunks)
  • anomstack/ml/change.py (4 hunks)
  • anomstack/ml/preprocess.py (2 hunks)
  • anomstack/ml/threshold.py (3 hunks)
  • anomstack/ml/train.py (2 hunks)
  • anomstack/plots/plot.py (4 hunks)
  • anomstack/sensors/config_reload.py (3 hunks)
  • anomstack/sensors/failure.py (1 hunks)
  • anomstack/sensors/timeout.py (4 hunks)
  • anomstack/sql/read.py (2 hunks)
  • anomstack/sql/translate.py (1 hunks)
  • anomstack/validate/validate.py (2 hunks)
  • dashboard/app.py (2 hunks)
  • dashboard/batch_stats.py (1 hunks)
  • dashboard/charts.py (4 hunks)
  • dashboard/components/__init__.py (1 hunks)
  • dashboard/components/common.py (1 hunks)
  • dashboard/components/search.py (1 hunks)
  • dashboard/components/settings.py (2 hunks)
  • dashboard/components/toolbar.py (0 hunks)
  • dashboard/data.py (3 hunks)
  • dashboard/routes/batch.py (14 hunks)
  • dashboard/routes/index.py (4 hunks)
  • dashboard/routes/search.py (8 hunks)
  • dashboard/state.py (2 hunks)
  • dashboard/utils.py (2 hunks)
  • dev.py (1 hunks)
  • metrics/defaults/python/preprocess.py (1 hunks)
  • metrics/examples/coindesk/coindesk.py (3 hunks)
  • metrics/examples/currency/currency.py (2 hunks)
  • metrics/examples/eirgrid/eirgrid.py (1 hunks)
  • metrics/examples/github/github.py (3 hunks)
  • metrics/examples/netdata/netdata.py (1 hunks)
  • metrics/examples/netdata_httpcheck/netdata_httpcheck.py (1 hunks)
  • metrics/examples/posthog/posthog.py (3 hunks)
  • metrics/examples/prometheus/prometheus.py (3 hunks)
  • metrics/examples/python/python_ingest_simple/ingest.py (1 hunks)
  • metrics/examples/weather/ingest_weather.py (1 hunks)
  • metrics/examples/yfinance/yfinance.py (2 hunks)
  • notebooks/dev.ipynb (4 hunks)
  • notebooks/run_qry.ipynb (1 hunks)
  • pyproject.toml (1 hunks)
  • scripts/configuration/reload_config.py (6 hunks)
  • scripts/deployment/deploy_fly.sh (1 hunks)
  • scripts/examples/posthog_example.py (1 hunks)
  • scripts/maintenance/cleanup_disk_space.py (6 hunks)
  • scripts/maintenance/kill_long_running_tasks.py (2 hunks)
  • scripts/maintenance/list_long_running_tasks.py (7 hunks)
  • scripts/sqlite/create_index.py (1 hunks)
  • scripts/sqlite/list_indexes.py (1 hunks)
  • scripts/sqlite/list_tables.py (1 hunks)
  • scripts/sqlite/qry.py (1 hunks)
  • setup.py (1 hunks)
  • tests/test_alert_jobs.py (17 hunks)
  • tests/test_alerts.py (4 hunks)
  • tests/test_asciiart.py (8 hunks)
  • tests/test_dashboard.py (2 hunks)
  • tests/test_df.py (2 hunks)
  • tests/test_duckdb.py (10 hunks)
  • tests/test_email.py (4 hunks)
  • tests/test_external_duckdb_simple.py (4 hunks)
  • tests/test_io.py (4 hunks)
  • tests/test_jobs.py (18 hunks)
  • tests/test_llm.py (16 hunks)
  • tests/test_main.py (1 hunks)
  • tests/test_ml.py (14 hunks)
  • tests/test_plots.py (10 hunks)
  • tests/test_slack.py (15 hunks)
  • tests/test_sql.py (12 hunks)
  • tests/test_threshold.py (1 hunks)
  • tests/test_timeout_sensor.py (0 hunks)
  • tests/test_validate.py (6 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 precommit-improve

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

@andrewm4894 andrewm4894 marked this pull request as ready for review July 30, 2025 21:29
@andrewm4894 andrewm4894 requested a review from Copilot July 30, 2025 21:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request consolidates multi-line statements into single lines for improved readability and replaces isort with ruff for import sorting. The changes focus on formatting improvements and tooling modernization while maintaining code functionality.

  • Replaced isort with ruff for import sorting in pre-commit configuration and added ruff-format hook
  • Consolidated multi-line DataFrame definitions, function calls, and dict/list literals into single lines across test files
  • Updated string quotes from single to double quotes for consistency with ruff formatting standards

Reviewed Changes

Copilot reviewed 102 out of 105 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/test_validate.py Reformatted DataFrame definitions and function calls from multi-line to single-line format
tests/test_timeout_sensor.py Removed blank line at beginning of file
tests/test_threshold.py Consolidated multi-line DataFrame definitions and function parameters
tests/test_sql.py Reformatted test method definitions and DataFrame creations
tests/test_slack.py Consolidated multi-line dictionary definitions and function calls
tests/test_plots.py Reformatted DataFrame definitions and function calls
tests/test_ml.py Reordered imports and consolidated multi-line statements
tests/test_main.py Split long assertion into multiple lines for readability
tests/test_llm.py Consolidated DataFrame definitions and multi-line function calls
tests/test_jobs.py Removed blank lines and reformatted multi-line configurations
tests/test_io.py Reordered imports and consolidated multi-line statements
tests/test_external_duckdb_simple.py Reformatted DataFrame definitions and function calls
tests/test_email.py Consolidated multi-line configurations and function calls
tests/test_duckdb.py Reformatted test method definitions and DataFrame creations
tests/test_df.py Consolidated DataFrame definitions and function parameters
tests/test_dashboard.py Reordered imports and reformatted DataFrame definition
tests/test_asciiart.py Removed blank line and consolidated DataFrame definitions
tests/test_alerts.py Reformatted function calls and DataFrame definitions

@github-actions
Copy link

📊 Test Coverage Report

Coverage: 59% (yellow)

✅ Coverage maintained or improved!

💡 See detailed coverage report in the tests README

@andrewm4894 andrewm4894 merged commit 0456f32 into main Jul 30, 2025
2 of 3 checks passed
@andrewm4894 andrewm4894 deleted the precommit-improve branch July 30, 2025 21:32
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.

2 participants