Skip to content

Fix/remove deprecated methods from examples#312

Merged
aarmoa merged 3 commits intomasterfrom
fix/remove_deprecated_methods_from_examples
Mar 12, 2024
Merged

Fix/remove deprecated methods from examples#312
aarmoa merged 3 commits intomasterfrom
fix/remove_deprecated_methods_from_examples

Conversation

@aarmoa
Copy link
Copy Markdown
Collaborator

@aarmoa aarmoa commented Mar 12, 2024

  • Refactored example scripts that were still referencing deprecated methods

Summary by CodeRabbit

  • New Features

    • Updated example scripts to use the latest function calls, ensuring they align with current best practices.
  • Bug Fixes

    • Removed a deprecated test method related to oracle list deprecation warnings.
  • Tests

    • Added new test methods for checking deprecation warnings for specific methods.
    • Updated test cases to reflect the latest function naming conventions.
  • Documentation

    • Updated the changelog to reflect the new changes in version 1.4.1.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 12, 2024

Walkthrough

This update to version 1.4.1 focuses on modernizing the codebase by replacing deprecated functions with their updated counterparts across example scripts and test files. It also updates the project version in its configuration, reflecting the continuous effort to align with best practices and maintain code quality.

Changes

File(s) Summary
examples/.../3_MessageBroadcaster.py,
examples/.../5_MessageBroadcasterWithoutSimulation.py,
examples/.../exchange/8_MsgCancelSpotOrder.py,
examples/.../exchange/9_MsgBatchUpdateOrders.py,
tests/core/test_gas_limit_estimator.py
Updated function calls from composer.MsgBatchUpdateOrders to composer.msg_batch_update_orders and similar, affecting message preparation.
pyproject.toml Updated the version from "1.4.0" to "1.4.1".
tests/test_async_client_deprecation_warnings.py Removed test for deprecated oracle list method.
tests/test_composer_deprecation_warnings.py Added tests for deprecation warnings on Coin and MsgWithdrawDelegatorReward methods.

🐇✨
In the realm of code, where changes abound,
A rabbit hopped in, with updates profound.
Deprecated no more, the functions align,
With version one-four-one, now all is fine.
🌟📜
So hop we do, on this journey so bright,
With cleaner code, we leap towards the light.


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>.
    • Generate unit-tests 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 tests 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.25%. Comparing base (52033b4) to head (7521f81).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #312      +/-   ##
==========================================
+ Coverage   76.16%   76.25%   +0.09%     
==========================================
  Files          50       50              
  Lines        4111     4111              
  Branches      351      351              
==========================================
+ Hits         3131     3135       +4     
+ Misses        875      871       -4     
  Partials      105      105              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
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.

Review Status

Actionable comments generated: 11

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 52033b4 and f26f536.
Files selected for processing (9)
  • CHANGELOG.md (1 hunks)
  • examples/chain_client/3_MessageBroadcaster.py (1 hunks)
  • examples/chain_client/5_MessageBroadcasterWithoutSimulation.py (1 hunks)
  • examples/chain_client/exchange/8_MsgCancelSpotOrder.py (1 hunks)
  • examples/chain_client/exchange/9_MsgBatchUpdateOrders.py (1 hunks)
  • pyproject.toml (1 hunks)
  • tests/core/test_gas_limit_estimator.py (10 hunks)
  • tests/test_async_client_deprecation_warnings.py (1 hunks)
  • tests/test_composer_deprecation_warnings.py (2 hunks)
Files skipped from review due to trivial changes (2)
  • pyproject.toml
  • tests/test_async_client_deprecation_warnings.py
Additional comments: 6
examples/chain_client/3_MessageBroadcaster.py (1)
  • 59-59: The update from composer.MsgBatchUpdateOrders to composer.msg_batch_update_orders aligns with the PR's objective to remove references to deprecated methods. This change is correctly applied and follows Python's naming conventions for methods. Ensure that all references to the old method name are updated across the project to maintain consistency.
examples/chain_client/5_MessageBroadcasterWithoutSimulation.py (1)
  • 59-59: The method call update from composer.MsgBatchUpdateOrders to composer.msg_batch_update_orders is correctly implemented, ensuring the example script uses the latest method names. This change is consistent with the PR's goal of updating example scripts to reflect current best practices. Good job on maintaining consistency across similar scripts.
examples/chain_client/exchange/8_MsgCancelSpotOrder.py (1)
  • 38-38: The update from composer.MsgCancelSpotOrder to composer.msg_cancel_spot_order is correctly applied, reflecting the PR's objective to use updated method names. This change ensures that the example script remains relevant and uses the current API. It's important to verify that all documentation and other example scripts are also updated to prevent confusion.
examples/chain_client/exchange/9_MsgBatchUpdateOrders.py (1)
  • 121-121: The method call update from composer.MsgBatchUpdateOrders to composer.msg_batch_update_orders is correctly implemented. This ensures that the example script is up-to-date with the latest method names, aligning with the PR's objectives. It's crucial to ensure that all example scripts and documentation reflect these updates for consistency and clarity.
CHANGELOG.md (1)
  • 5-7: The changelog entry for version 1.4.1 succinctly captures the essence of the updates made to the example scripts, specifically the removal of deprecated method references. This aligns well with the PR objectives and ensures users are informed of the changes in a clear and concise manner.
tests/test_composer_deprecation_warnings.py (1)
  • 537-550: The new test method test_msg_withdraw_delegator_reward_deprecation_warning correctly checks for a deprecation warning when using the MsgWithdrawDelegatorReward method. This addition aligns with the PR's objectives to update and improve the test suite.

),
]
message = composer.MsgBatchUpdateOrders(
message = composer.msg_batch_update_orders(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The method call composer.msg_batch_update_orders correctly replaces the deprecated method name. This change aligns with the PR's objective to update example scripts and test files to use current method names. However, there's a minor typo in the sender parameter value ("senders" should be "sender").

-            sender="senders",
+            sender="sender",

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
message = composer.msg_batch_update_orders(
message = composer.msg_batch_update_orders(

),
]
message = composer.MsgBatchUpdateOrders(
message = composer.msg_batch_update_orders(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The method call composer.msg_batch_update_orders for creating derivative orders is correctly updated. The change is consistent with the PR's goal. The same typo in the sender parameter value is present here as well.

-            sender="senders",
+            sender="sender",

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
message = composer.msg_batch_update_orders(
message = composer.msg_batch_update_orders(
sender="sender",

),
]
message = composer.MsgBatchUpdateOrders(
message = composer.msg_batch_update_orders(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The method call composer.msg_batch_update_orders for creating binary options orders is correctly updated. This change aligns with the PR's objectives. The typo in the sender parameter value is repeated here.

-            sender="senders",
+            sender="sender",

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
message = composer.msg_batch_update_orders(
message = composer.msg_batch_update_orders(

),
]
message = composer.MsgBatchUpdateOrders(
message = composer.msg_batch_update_orders(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The method call composer.msg_batch_update_orders for canceling spot orders is correctly updated. This change aligns with the PR's objectives. The typo in the sender parameter value is repeated here.

-            sender="senders",
+            sender="sender",

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
message = composer.msg_batch_update_orders(
message = composer.msg_batch_update_orders(

),
]
message = composer.MsgBatchUpdateOrders(
message = composer.msg_batch_update_orders(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The method call composer.msg_batch_update_orders for canceling derivative orders is correctly updated. This change aligns with the PR's objectives. The typo in the sender parameter value is repeated here.

-            sender="senders",
+            sender="sender",

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
message = composer.msg_batch_update_orders(
message = composer.msg_batch_update_orders(
sender="sender",

composer = Composer(network="testnet")

message = composer.MsgBatchUpdateOrders(
message = composer.msg_batch_update_orders(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The method call composer.msg_batch_update_orders for canceling all orders for a spot market is correctly updated. This change aligns with the PR's objectives. The typo in the sender parameter value is repeated here.

-            sender="senders",
+            sender="sender",

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
message = composer.msg_batch_update_orders(
message = composer.msg_batch_update_orders(

composer = Composer(network="testnet")

message = composer.MsgBatchUpdateOrders(
message = composer.msg_batch_update_orders(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The method call composer.msg_batch_update_orders for canceling all orders for a derivative market is correctly updated. This change aligns with the PR's objectives. The typo in the sender parameter value is repeated here.

-            sender="senders",
+            sender="sender",

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
message = composer.msg_batch_update_orders(
message = composer.msg_batch_update_orders(

composer = Composer(network="testnet")

message = composer.MsgBatchUpdateOrders(
message = composer.msg_batch_update_orders(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The method call composer.msg_batch_update_orders for canceling all orders for a binary options market is correctly updated. This change aligns with the PR's objectives. The typo in the sender parameter value is repeated here.

-            sender="senders",
+            sender="sender",

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
message = composer.msg_batch_update_orders(
message = composer.msg_batch_update_orders(
sender="sender",

),
]
inner_message = composer.MsgBatchUpdateOrders(
inner_message = composer.msg_batch_update_orders(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The method call composer.msg_batch_update_orders within the MsgExec message is correctly updated. This change aligns with the PR's objectives. The typo in the sender parameter value is repeated here.

-            sender="senders",
+            sender="sender",

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
inner_message = composer.msg_batch_update_orders(
inner_message = composer.msg_batch_update_orders(

Comment on lines +53 to +64
def teste_coin_deprecation_warning(self):
composer = Composer(network=Network.devnet().string())

with warnings.catch_warnings(record=True) as all_warnings:
composer.Coin(
amount=1,
denom="INJ",
)

deprecation_warnings = [warning for warning in all_warnings if issubclass(warning.category, DeprecationWarning)]
assert len(deprecation_warnings) == 1
assert str(deprecation_warnings[0].message) == "This method is deprecated. Use coin instead"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The new test method teste_coin_deprecation_warning correctly checks for a deprecation warning when using the Coin method. However, there's a typo in the method name ("teste" should be "test").

-    def teste_coin_deprecation_warning(self):
+    def test_coin_deprecation_warning(self):

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
def teste_coin_deprecation_warning(self):
composer = Composer(network=Network.devnet().string())
with warnings.catch_warnings(record=True) as all_warnings:
composer.Coin(
amount=1,
denom="INJ",
)
deprecation_warnings = [warning for warning in all_warnings if issubclass(warning.category, DeprecationWarning)]
assert len(deprecation_warnings) == 1
assert str(deprecation_warnings[0].message) == "This method is deprecated. Use coin instead"
def test_coin_deprecation_warning(self):
composer = Composer(network=Network.devnet().string())
with warnings.catch_warnings(record=True) as all_warnings:
composer.Coin(
amount=1,
denom="INJ",
)
deprecation_warnings = [warning for warning in all_warnings if issubclass(warning.category, DeprecationWarning)]
assert len(deprecation_warnings) == 1
assert str(deprecation_warnings[0].message) == "This method is deprecated. Use coin instead"

Copy link
Copy Markdown
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.

Review Status

Actionable comments generated: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between f26f536 and 7521f81.
Files selected for processing (1)
  • tests/test_composer_deprecation_warnings.py (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/test_composer_deprecation_warnings.py

@aarmoa aarmoa merged commit 1a4abc3 into master Mar 12, 2024
@aarmoa aarmoa deleted the fix/remove_deprecated_methods_from_examples branch March 12, 2024 15:48
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