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

Modernise scan_disks() - no functional change intended #2826

Closed
phillxnet opened this issue Apr 3, 2024 · 1 comment
Closed

Modernise scan_disks() - no functional change intended #2826

phillxnet opened this issue Apr 3, 2024 · 1 comment
Assignees

Comments

@phillxnet
Copy link
Member

Some basic code quality/readability improvements to assist with planned functional changes associated with the following issues:

@phillxnet phillxnet self-assigned this Apr 3, 2024
phillxnet added a commit to phillxnet/rockstor-core that referenced this issue Apr 3, 2024
Includes:
- Modernisation re type hints in scan_disks().
- Improve lsblk line parser via modern Python builtins.
Replace by-hand lsblk output line parser with dictionary comprehension.
- Programmatically establish `lsblk` field derived Disk namedtuple fields.
- Refactoring for readability.
- Black reformatting.
- Employ defaults in Disk named tuple to ease creation using lsblk info,
as these defaults pertain to our extra flag info.
- Normalise scan_disks()'s working dict keys to lowercase.
By normalising on lowercase we can ease the transition to using
our Disk named tuple as the working copy: to help readability
and highlight where we write (via Disk.replace(root=True)).
This should also simplify the assembly of our final return value.
We also have a large number of tests that use the existing lowercase
Disk fields.

By working directly with the Disk namedtuple during device collation,
we gain readability and the advantages of an immutable type: i.e.
we are then more explicit where writes/changes happen due to requirement
to use Disk._replace(). We also require less type transitions overall.
@phillxnet phillxnet added this to the 5.1.X-X Stable release milestone Apr 3, 2024
phillxnet added a commit that referenced this issue Apr 3, 2024
…-no-functional-change-intended

Modernise scan_disks() - no functional change intended #2826
@phillxnet
Copy link
Member Author

Closing as:
Fixed by #2827

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

No branches or pull requests

1 participant