Skip to content

Conversation

@tspenov
Copy link
Collaborator

@tspenov tspenov commented Dec 29, 2025

  • Update test paths and enhance san module with versioning and error handling
  • Changed test paths in pytest configuration to point to 'san/tests'.
  • Added versioning to the san module, with a fallback for unknown versions.
  • Improved error handling in utility functions to provide clearer messages for API call issues.

Summary by CodeRabbit

  • New Features

    • Package version is now publicly accessible.
  • Bug Fixes

    • API error messages are now more descriptive and provide clearer feedback on failures.
  • Tests

    • Updated test discovery configuration paths.
  • Refactor

    • Removed internal redundancies for improved efficiency.

✏️ Tip: You can customize this high-level summary in your review settings.

…ndling

- Changed test paths in pytest configuration to point to 'san/tests'.
- Added versioning to the san module, with a fallback for unknown versions.
- Improved error handling in utility functions to provide clearer messages for API call issues.
@tspenov tspenov changed the title Update test paths and enhance san module with versioning and error ha… Fixing bugs and general improvements Dec 29, 2025
@tspenov tspenov marked this pull request as ready for review January 13, 2026 12:09
@tspenov tspenov requested a review from IvanIvanoff January 13, 2026 12:09
@tspenov
Copy link
Collaborator Author

tspenov commented Jan 13, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 13, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Jan 13, 2026

📝 Walkthrough

Walkthrough

Test configuration updated to discover tests in san/tests directory. Package now includes resilient version attribute with fallback handling. Removed redundant API batching call and simplified error handling in utility functions with improved exception messaging.

Changes

Cohort / File(s) Summary
Test Configuration
pytest.ini
Test discovery path updated from tests to san/tests
Version Management
san/__init__.py
Added resilient __version__ attribute using importlib.metadata.version() with "unknown" fallback; exposed in __all__ for public export
Code Cleanup
san/batch.py
Removed redundant self.__batch_gql_queries(batched_queries) invocation in __create_batched_query_string, now returns result directly
Error Handling Improvements
san/utility.py
Removed debug print from __request_api_call_data; broadened exception handling in __parse_out_calls_data to catch KeyError and TypeError with improved error messaging using exception chaining

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A hop and a skip through the code we go,
Version falls back when it doesn't know,
Redundant calls cleaned, errors refined,
Tests in new homes, a neater design!
Twitches nose happily

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and generic, using non-descriptive language like 'bugs and general improvements' that does not convey meaningful information about the specific changes made. Revise the title to be more specific and descriptive. For example: 'Update test paths, add version handling, and improve error messages' would better reflect the actual changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de28128 and 8701bcb.

📒 Files selected for processing (4)
  • pytest.ini
  • san/__init__.py
  • san/batch.py
  • san/utility.py
💤 Files with no reviewable changes (1)
  • san/batch.py
🧰 Additional context used
🧬 Code graph analysis (1)
san/utility.py (1)
san/error.py (1)
  • SanError (1-2)
🪛 Ruff (0.14.10)
san/utility.py

46-46: Avoid specifying long messages outside the exception class

(TRY003)

🔇 Additional comments (5)
san/utility.py (2)

34-37: Good use of exception chaining.

The from exc clause properly preserves the original exception context in the traceback, improving debuggability while providing a clearer user-facing message via SanError.


45-46: Appropriate broadening of exception handling.

Catching both KeyError and TypeError handles malformed API responses robustly. The exception chaining preserves the original context for debugging.

Regarding the Ruff TRY003 hint: the inline message is acceptable here given the context—creating a dedicated exception subclass for this single parsing error case would be over-engineering.

san/__init__.py (2)

23-26: Clean version handling with proper fallback.

Using importlib.metadata.version is the modern Python approach for package version discovery. The fallback to "unknown" handles editable installs and development scenarios gracefully.


42-42: LGTM!

Exposing __version__ in __all__ follows Python packaging conventions.

pytest.ini (1)

2-2: LGTM! The test directory configuration is correct.

The testpaths configuration change to san/tests is valid. The directory exists and contains the test files (test_batch.py, test_get.py, test_sanbase_integration.py).


Comment @coderabbitai help to get the list of available commands and usage tips.

@tspenov
Copy link
Collaborator Author

tspenov commented Jan 13, 2026

@coderabbitai help

@coderabbitai
Copy link

coderabbitai bot commented Jan 13, 2026

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue 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 evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @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 resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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.
  • You can also validate your configuration using the online YAML validator.
  • 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

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • 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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
san/__init__.py (1)

29-38: Add timeout and handle JSON parsing errors.

The requests.get() call lacks a timeout, which could cause the function to hang indefinitely. Additionally, json.loads() can raise json.JSONDecodeError and the dictionary access can raise KeyError, neither of which are caught.

🔧 Proposed fix
 def get_latest():
     url = "https://pypi.python.org/pypi/%s/json" % (PROJECT)
     try:
-        response = requests.get(url).text
+        response = requests.get(url, timeout=5).text
         return json.loads(response)["info"]["version"]
-    except requests.exceptions.RequestException:
+    except (requests.exceptions.RequestException, json.JSONDecodeError, KeyError):
         try:
             return version(PROJECT)
         except PackageNotFoundError:
             return "unknown"
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de28128 and 8701bcb.

📒 Files selected for processing (4)
  • pytest.ini
  • san/__init__.py
  • san/batch.py
  • san/utility.py
💤 Files with no reviewable changes (1)
  • san/batch.py
🧰 Additional context used
🧬 Code graph analysis (1)
san/utility.py (1)
san/error.py (1)
  • SanError (1-2)
🪛 Ruff (0.14.10)
san/utility.py

46-46: Avoid specifying long messages outside the exception class

(TRY003)

🔇 Additional comments (5)
san/utility.py (2)

34-37: Good use of exception chaining.

The from exc clause properly preserves the original exception context in the traceback, improving debuggability while providing a clearer user-facing message via SanError.


45-46: Appropriate broadening of exception handling.

Catching both KeyError and TypeError handles malformed API responses robustly. The exception chaining preserves the original context for debugging.

Regarding the Ruff TRY003 hint: the inline message is acceptable here given the context—creating a dedicated exception subclass for this single parsing error case would be over-engineering.

san/__init__.py (2)

23-26: Clean version handling with proper fallback.

Using importlib.metadata.version is the modern Python approach for package version discovery. The fallback to "unknown" handles editable installs and development scenarios gracefully.


42-42: LGTM!

Exposing __version__ in __all__ follows Python packaging conventions.

pytest.ini (1)

2-2: LGTM! The test directory configuration is correct.

The testpaths configuration change to san/tests is valid. The directory exists and contains the test files (test_batch.py, test_get.py, test_sanbase_integration.py).

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