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

Refactor remove_prefix_from_names function for improved readability #1228

Closed
wants to merge 1 commit into from

Conversation

defitricks
Copy link

Description:

This PR refactors the remove_prefix_from_names function to improve code readability. Specifically, it replaces the usage of update with direct dictionary key assignment.

Original code:

def remove_prefix_from_names(contracts):
    for contract in contracts:
        contract.update([("name", remove_prefix(contract['name'], 'openzeppelin_presets_'))])
    return contracts

Refactored code:

def remove_prefix_from_names(contracts):
    for contract in contracts:
        contract['name'] = remove_prefix(contract['name'], 'openzeppelin_presets_')
    return contracts

Reason for the change:

  • The use of direct assignment (contract['name'] = ...) is more intuitive and widely understood in Python. It simplifies the code and makes it clearer, especially for developers who might be unfamiliar with the update method.
  • This is a minor improvement in terms of code style, but it contributes to better readability and maintainability.

Let me know if there are any questions or additional changes needed.

This PR refactors the remove_prefix_from_names function to improve code readability. Specifically, it replaces the usage of update with direct dictionary key assignment.
Copy link

codecov bot commented Nov 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.26%. Comparing base (3fdef27) to head (98d572c).
Report is 13 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1228   +/-   ##
=======================================
  Coverage   92.26%   92.26%           
=======================================
  Files          59       59           
  Lines        1811     1811           
=======================================
  Hits         1671     1671           
  Misses        140      140           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3fdef27...98d572c. Read the comment docs.

@ericnordelo
Copy link
Member

Update is correctly used in this context.

@defitricks defitricks deleted the patch-1 branch December 19, 2024 07:25
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