-
Notifications
You must be signed in to change notification settings - Fork 8
Python error resolution (Sourcery refactored) #2
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
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| if data[5] == 'ro': | ||
| raise ValueError('{} is read-only'.format(name)) | ||
| raise ValueError(f'{name} is read-only') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Tuning.write refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
| result = response[0] * (2.**response[1]) | ||
|
|
||
| return result | ||
| return response[0] if data[2] == 'int' else response[0] * (2.**response[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Tuning.read refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| dev = usb.core.find(idVendor=vid, idProduct=pid) | ||
| if not dev: | ||
| return | ||
| if dev := usb.core.find(idVendor=vid, idProduct=pid): | ||
| # configuration = dev.get_active_configuration() | ||
|
|
||
| # configuration = dev.get_active_configuration() | ||
| # interface_number = None | ||
| # for interface in configuration: | ||
| # interface_number = interface.bInterfaceNumber | ||
|
|
||
| # interface_number = None | ||
| # for interface in configuration: | ||
| # interface_number = interface.bInterfaceNumber | ||
| # if dev.is_kernel_driver_active(interface_number): | ||
| # dev.detach_kernel_driver(interface_number) | ||
|
|
||
| # if dev.is_kernel_driver_active(interface_number): | ||
| # dev.detach_kernel_driver(interface_number) | ||
|
|
||
| return Tuning(dev) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function find refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression) - Lift code into else after jump in control flow (
reintroduce-else) - Swap if/else branches (
swap-if-else-branches)
| print('{}{}'.format(' '*60, extra)) | ||
| print(f"{' ' * 60}{extra}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function main refactored with the following changes:
- Replace call to format with f-string [×3] (
use-fstring-for-formatting)
Pull Request #1 refactored by Sourcery.
Since the original Pull Request was opened as a fork in a contributor's
repository, we are unable to create a Pull Request branching from it.
To incorporate these changes, you can either:
Merge this Pull Request instead of the original, or
Ask your contributor to locally incorporate these commits and push them to
the original Pull Request
Incorporate changes via command line
NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Help us improve this pull request!