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

usbsdmux: sd_regs: Fix ruff error regarding the use of percent formatting #89

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

hnez
Copy link
Member

@hnez hnez commented Jan 29, 2025

It looks like ruff has learned a new trick, making the CI pipeline in #88 fail, even though it did not touch the python code at all.
This PR should fix that.

The primary goal of this commit is fixing the following ruff linting error:

usbsdmux/sd_regs.py:39:50: UP031 Use format specifiers instead of percent format
   |
37 |             text.append(f"  {f['field']}")
38 |         raw = f["raw"]
39 |         text.append(f"    raw: 0b{format(raw[0], '0%db' % raw[1])} == 0x{raw[0]:0x} == {int(raw[0])}")
   |                                                  ^^^^^^ UP031
40 |         if "enum" in f:
41 |             text.append(f"    enum: {f['enum']} {f.get('unit', '')}".rstrip())
   |
   = help: Replace with format specifiers

While at it I had a hard time understanding what the offending code does, so I have decided to restructure it a bit while at it.

The code path is covered by the pytest testsuite, so we can be somewhat certain that the behaviour did not change.

…ting

The primary goal of this commit is fixing the following `ruff`
linting error:

    usbsdmux/sd_regs.py:39:50: UP031 Use format specifiers instead of percent format
       |
    37 |             text.append(f"  {f['field']}")
    38 |         raw = f["raw"]
    39 |         text.append(f"    raw: 0b{format(raw[0], '0%db' % raw[1])} == 0x{raw[0]:0x} == {int(raw[0])}")
       |                                                  ^^^^^^ UP031
    40 |         if "enum" in f:
    41 |             text.append(f"    enum: {f['enum']} {f.get('unit', '')}".rstrip())
       |
       = help: Replace with format specifiers

While at it I had a hard time understanding what the offending code does,
so I have decided to restructure it a bit while at it.

The code path is covered by the pytest testsuite, so we can be somewhat
certain that the behaviour did not change.

Signed-off-by: Leonard Göhrs <[email protected]>
@SmithChart SmithChart merged commit a90da1e into linux-automation:master Jan 30, 2025
7 checks passed
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