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

Fix/solve OFAC path issue #351

Merged
merged 3 commits into from
Sep 23, 2024
Merged

Fix/solve OFAC path issue #351

merged 3 commits into from
Sep 23, 2024

Conversation

aarmoa
Copy link
Collaborator

@aarmoa aarmoa commented Sep 23, 2024

  • Fixed logic to get the absolute ofac.json file path

Summary by CodeRabbit

Release Notes for Version 1.7.1

  • Bug Fixes

    • Improved error handling for missing OFAC list file, providing clearer guidance for users.
  • New Features

    • Updated the changelog to reflect the latest changes and version increment.
  • Documentation

    • Changelog now includes details of the new version and previous updates.

Copy link
Contributor

coderabbitai bot commented Sep 23, 2024

Walkthrough

The pull request introduces version 1.7.1 of the project, which includes a fix for the logic that retrieves the absolute path of the ofac.json file. The OfacChecker class has been modified to improve error handling during the initialization process when reading the OFAC list. Additionally, the project version has been updated in the pyproject.toml file.

Changes

File Change Summary
CHANGELOG.md Updated to version 1.7.1; added a fix for the ofac.json file path retrieval logic.
pyinjective/ofac.py Modified OfacChecker class to improve initialization logic with better error handling for OFAC list.
pyproject.toml Incremented project version from 1.7.0 to 1.7.1; no other changes made.

Poem

In the burrow deep, where the code does play,
A fix was found, brightening the day.
With paths now clear, and errors less grim,
The OFAC list shines, on a programming whim.
Hoppy updates, with joy we embrace,
In the world of code, we quicken our pace! 🐇✨


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.

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.

@aarmoa aarmoa merged commit dccedfc into master Sep 23, 2024
12 checks passed
@aarmoa aarmoa deleted the fix/solve_ofac_path_issue branch September 23, 2024 19:29
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: 0

Outside diff range and nitpick comments (1)
CHANGELOG.md (1)

5-7: LGTM with a minor suggestion.

The changelog entry accurately reflects the purpose of the PR and follows the proper versioning convention. Great job on keeping the changelog up-to-date!

Consider simplifying the entry to avoid repetition:

 ## [1.7.1] - 2024-09-24
 ### Fixed
-- Fixed logic to get the absolute ofac.json file path
++ Logic to get the absolute ofac.json file path

This change removes the redundant "Fixed" at the beginning of the line, as it's already implied by the "### Fixed" section header.

Tools
LanguageTool

[duplication] ~6-~6: Possible typo: you repeated a word
Context: ...this file. ## [1.7.1] - 2024-09-24 ### Fixed - Fixed logic to get the absolute ofac.json fil...

(ENGLISH_WORD_REPEAT_RULE)

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ffd2151 and ca5b59f.

Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • pyinjective/ofac.py (1 hunks)
  • pyproject.toml (1 hunks)
Files skipped from review due to trivial changes (1)
  • pyproject.toml
Additional context used
LanguageTool
CHANGELOG.md

[duplication] ~6-~6: Possible typo: you repeated a word
Context: ...this file. ## [1.7.1] - 2024-09-24 ### Fixed - Fixed logic to get the absolute ofac.json fil...

(ENGLISH_WORD_REPEAT_RULE)

Ruff
pyinjective/ofac.py

19-21: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

Additional comments not posted (2)
pyinjective/ofac.py (2)

25-25: Simplified path retrieval looks good

The updated get_ofac_list_path method is a clear improvement. It's more concise and uses a reliable method to get the current file's directory.


15-20: Improve exception handling and error message

The new try-except block is a good addition for better error handling. However, there are a couple of improvements we can make:

  1. Use raise ... from e to preserve the original traceback, which aids in debugging.
  2. Make the error message more generic to cover other potential issues.

Here's a suggested improvement:

 try:
     with open(self._ofac_list_path, "r") as f:
         self._ofac_list = set(json.load(f))
 except Exception as e:
-    raise Exception(
-        f"Error parsing OFAC list. Please, download it by running python3 pyinjective/ofac_list.py ({e})"
-    )
+    raise Exception(
+        f"Error reading or parsing OFAC list. If the file is missing, please download it by running python3 pyinjective/ofac_list.py"
+    ) from e

To ensure the OFAC list file exists and is readable, run the following script:

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