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: Rewrite the function SysUtil.link_info_find() in a more pythonic way #761

Conversation

liangwen12year
Copy link
Collaborator

  • Removed the unnecessary refresh argument since it wasn't used.
  • Used None checks more idiomatically with if mac instead of is not None.
  • Eliminated redundant variables and conditions to improve readability.
  • Avoided using locals() by explicitly storing fallback results.
  • Made ifname matching take priority before checking MAC addresses.
  • Ensured that the function returns early when a definitive match is found.

Enhancement:

Reason:

Result:

Issue Tracker Tickets (Jira or BZ if any):

Copy link

codecov bot commented Feb 4, 2025

Codecov Report

Attention: Patch coverage is 5.88235% with 16 lines in your changes missing coverage. Please review.

Project coverage is 43.10%. Comparing base (89d7148) to head (7bf2105).
Report is 28 commits behind head on main.

Files with missing lines Patch % Lines
library/network_connections.py 5.88% 16 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #761       +/-   ##
===========================================
+ Coverage   20.40%   43.10%   +22.69%     
===========================================
  Files          10       12        +2     
  Lines        1485     3125     +1640     
  Branches      436        0      -436     
===========================================
+ Hits          303     1347     +1044     
- Misses       1181     1778      +597     
+ Partials        1        0        -1     
Flag Coverage Δ
sanity ?

Flags with carried forward coverage won't be shown. Click here to find out more.

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

…ythonic way

- Removed the unnecessary `refresh` argument since it wasn't used.
- Used `None` checks more idiomatically with `if mac` instead of `is not None`.
- Eliminated redundant variables and conditions to improve readability.
- Avoided using `locals()` by explicitly storing fallback results.
- Made `ifname` matching take priority before checking MAC addresses.
- Ensured that the function returns early when a definitive match is found.
@liangwen12year liangwen12year force-pushed the link_infos_find_fetch_fix branch from 627518a to 7bf2105 Compare February 4, 2025 01:34
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