Refactor get_cpus() function into single-responsibility functions - #210
Open
elfosardo wants to merge 1 commit into
Open
Refactor get_cpus() function into single-responsibility functions#210elfosardo wants to merge 1 commit into
elfosardo wants to merge 1 commit into
Conversation
Break down the 143-line monolithic get_cpus() function into 6 smaller, focused functions to improve maintainability and testability. Changes: - Extract _parse_lscpu_output() for lscpu command parsing - Extract _detect_physical_cpus() for socket and CPU properties detection - Extract _detect_logical_cpus() for logical CPU and governor detection - Extract _detect_numa_nodes() for NUMA topology parsing - Move _maybe_int() and _get_governor() to module level as utilities - Add comprehensive docstrings for all new functions - Fix PEP8 line length violations Benefits: - Improved code readability and maintainability - Better testability with focused, single-responsibility functions - Easier debugging by isolating CPU detection aspects - Reduced cyclomatic complexity from one large function All existing tests pass (24/24) and PEP8 compliance maintained. CPU detection output is identical to previous implementation. Assisted-By: Claude Opus 4.6
elfosardo
force-pushed
the
refactor-get-cpu
branch
from
August 20, 2026 14:56
d3c9bde to
1a7e6a9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Break down the 143-line monolithic get_cpus() function into 6 smaller,
focused functions to improve maintainability and testability.
Changes:
Benefits:
All existing tests pass (24/24) and PEP8 compliance maintained.
CPU detection output is identical to previous implementation.
Assisted-By: Claude Opus 4.6