-
Notifications
You must be signed in to change notification settings - Fork 15
Sourcery Starbot ⭐ refactored Querela/termux-usb-python #3
base: master
Are you sure you want to change the base?
Conversation
| + "\n".join(["{:>12}: {}".format(k, repr(v)) for k, v in namespace.items()]) | ||
| + "\n" | ||
| ) | ||
| + "\n".join( | ||
| "{:>12}: {}".format(k, repr(v)) for k, v in namespace.items() | ||
| ) | ||
| ) + "\n" | ||
|
|
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 shell_usbdevice refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator)
| return -1 != self.buf.find(expected) | ||
| return self.buf.find(expected) != -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 Buffer.contains refactored with the following changes:
- Ensure constant in comparison is on the right (
flip-comparison)
| if duration is not None: | ||
| self.target_time = self.TIME() + duration | ||
| else: | ||
| self.target_time = None | ||
| self.target_time = self.TIME() + duration if duration is not None else None |
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 Timeout.__init__ refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| if delta > self.duration: | ||
| # clock jumped, recalculate | ||
| self.target_time = self.TIME() + self.duration | ||
| return self.duration | ||
| else: | ||
| if delta <= self.duration: | ||
| return max(0, delta) | ||
|
|
||
| # clock jumped, recalculate | ||
| self.target_time = self.TIME() + self.duration | ||
| return self.duration |
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 Timeout.time_left refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches) - Remove unnecessary else after guard condition (
remove-unnecessary-else)
| ret = self._device.ctrl_transfer( | ||
| return self._device.ctrl_transfer( |
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 CP210xSerial.send_ctrl_cmd refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| if -1 == data_peek.find(expected): | ||
| if data_peek.find(expected) == -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 CP210xSerial.read_until_or_none refactored with the following changes:
- Ensure constant in comparison is on the right (
flip-comparison)
| if ret < 0: | ||
| return False | ||
|
|
||
| return True | ||
| return ret >= 0 |
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 CP210xSerial.prepare_usb_cp210x refactored with the following changes:
- Simplify conditional into return statement (
return-identity)
| text = "".join([chr(v) for v in data]) | ||
| text = "".join(chr(v) for v in data) |
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 CP210xSerial.read_dump_forever refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator)
| while not stop: | ||
| data = ser._buf_in.read(100) | ||
| text = "".join([chr(v) for v in data]) | ||
| text = "".join(chr(v) for v in data) |
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 dump_test.dumper refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator)
| print(" no data") | ||
| continue | ||
| text = "".join([chr(v) for v in data]) | ||
| text = "".join(chr(v) for v in data) |
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 buf_test.dumper refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run: