-
Notifications
You must be signed in to change notification settings - Fork 28
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) Implement get_ofac_list_path without a loop #350
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe changes involve a modification to the Changes
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- pyinjective/ofac.py (1 hunks)
Additional comments not posted (2)
pyinjective/ofac.py (2)
Line range hint
1-56
: Final approval: Changes look good overallThe implementation of
get_ofac_list_path
without a loop has been successfully achieved. The new method is simpler, more direct, and should be more reliable. The changes are well-contained and don't negatively impact the rest of the file.Great job on improving this part of the code!
Line range hint
28-41
: Verify OFAC list file placement after downloadThe changes to
get_ofac_list_path
look good, but it's important to ensure that thedownload_ofac_list
method is placing the file in the correct location.Please run the following script to verify that the OFAC list file is being downloaded to the correct location:
This will help ensure that the
download_ofac_list
method is consistent with the newget_ofac_list_path
implementation.
while os.path.basename(current_directory) != "sdk-python": | ||
current_directory = os.path.dirname(current_directory) | ||
return os.path.join(os.path.join(current_directory, "pyinjective"), OFAC_LIST_FILENAME) | ||
return os.path.join(os.path.dirname(__file__), OFAC_LIST_FILENAME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approve the changes with a suggestion for improvement
The new implementation of get_ofac_list_path
is a significant improvement. It's more straightforward, likely more reliable, and aligns with the PR objective of implementing the method without a loop. Good job on simplifying this!
Consider adding a check to ensure the file exists at the specified location. This could help with debugging if the file is missing or moved. Here's a suggested improvement:
@classmethod
def get_ofac_list_path(cls):
path = os.path.join(os.path.dirname(__file__), OFAC_LIST_FILENAME)
if not os.path.exists(path):
raise FileNotFoundError(f"OFAC list file not found at {path}")
return path
This addition would make the method more robust and help catch configuration issues early.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We check for existence of file whenever we want to open it. This function just produces a string with the path to the ofac.json
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PavelInjective, thank you for the clarification. That makes sense—since the existence of the file is checked when opening it elsewhere, there's no need to add the check in get_ofac_list_path()
. The function's purpose is solely to provide the path.
(。・ω・。)
Learnings added
Learnt from: PavelInjective
PR: InjectiveLabs/sdk-python#350
File: pyinjective/ofac.py:25-25
Timestamp: 2024-09-23T19:13:38.964Z
Learning: In `pyinjective/ofac.py`, the function `get_ofac_list_path` only returns the path to the `ofac.json` file; checks for the existence of the file are performed when the file is opened elsewhere.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
a5b506f
to
901c5a9
Compare
Summary by CodeRabbit