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: Iterate over the dictionary directly instead of using .keys(). #3631

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

MaxJPRey
Copy link
Contributor

@MaxJPRey MaxJPRey commented Dec 26, 2024

Description

  • Iterate over the dictionary directly instead of using .keys().
    If you want to check whether a specific key is in a dictionary, you can write if key in dictionary. There's no need to write if key in dictionary.keys(). Furthermore, if key in dictionary is faster because it uses a hash lookup, while if key in dictionary.keys() generates a new list and then does a linear search through that list.

  • Remove some bare except.

  • Update some docstrings.

Issue linked

Please mention the issue number or describe the problem this pull request addresses.

Checklist

@MaxJPRey MaxJPRey requested a review from a team as a code owner December 26, 2024 16:27
@ansys-reviewer-bot
Copy link
Contributor

Thanks for opening a Pull Request. If you want to perform a review write a comment saying:

@ansys-reviewer-bot review

@github-actions github-actions bot added the enhancement Improve any current implemented feature label Dec 26, 2024
@MaxJPRey MaxJPRey changed the title REFACTOR: Iterate over the dictionary directly instead of using .keys(). refactor: Iterate over the dictionary directly instead of using .keys(). Dec 26, 2024
Copy link

codecov bot commented Dec 26, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 87.14%. Comparing base (4f75f6a) to head (32e50de).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3631      +/-   ##
==========================================
- Coverage   87.18%   87.14%   -0.05%     
==========================================
  Files         187      187              
  Lines       14660    14660              
==========================================
- Hits        12781    12775       -6     
- Misses       1879     1885       +6     

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve any current implemented feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants