-
Notifications
You must be signed in to change notification settings - Fork 121
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
Sourcery Starbot ⭐ refactored romanz/amodem #63
base: master
Are you sure you want to change the base?
Conversation
data = self.stream.read(size) | ||
if data: | ||
if data := self.stream.read(size): |
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 Compressor.read
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
volume_controllers = [ | ||
dict(test='pactl --version', | ||
send='pactl set-sink-volume @DEFAULT_SINK@', | ||
recv='pactl set-source-volume @DEFAULT_SOURCE@') | ||
] | ||
if args.calibrate == 'auto': | ||
volume_controllers = [ | ||
dict(test='pactl --version', | ||
send='pactl set-sink-volume @DEFAULT_SINK@', | ||
recv='pactl set-source-volume @DEFAULT_SOURCE@') | ||
] |
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 get_volume_cmd
refactored with the following changes:
- Move assignments closer to their usage (
move-assign
)
if success: | ||
msg = 'good signal' | ||
else: | ||
msg = f'too {errors[flags.index(False)]} signal' | ||
|
||
msg = 'good signal' if success else f'too {errors[flags.index(False)]} signal' |
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 detector
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
if _prev['success'] and _next['success']: | ||
if _prev['freq'] != _next['freq']: | ||
if not curr['success']: | ||
curr['msg'] = 'frequency change' | ||
if ( | ||
_prev['success'] | ||
and _next['success'] | ||
and _prev['freq'] != _next['freq'] | ||
and not curr['success'] | ||
): | ||
curr['msg'] = 'frequency change' |
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 recv_iter
refactored with the following changes:
- Merge nested if conditions [×2] (
merge-nested-ifs
)
offset = index + len(zeroes) | ||
return offset | ||
return index + len(zeroes) |
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 Detector.find_start
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
z = [] | ||
for i in common.icapture(x, result=y): | ||
z.append(i) | ||
z = list(common.icapture(x, result=y)) |
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 test_icapture
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
) - Replace identity comprehension with call to collection constructor (
identity-comprehension
)
for i in range(10000): | ||
for _ in range(10000): |
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 test_overflow
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
r = list(itertools.islice(dsp.prbs(reg=1, poly=0x1100b, bits=16), period)) | ||
r.sort() | ||
r = sorted(itertools.islice(dsp.prbs(reg=1, poly=0x1100b, bits=16), period)) |
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 test_prbs
refactored with the following changes:
- Remove an unnecessary list construction call prior to sorting (
skip-sorted-list-construction
)
blob = bytearray(r.randrange(0, 256) for i in range(64 * 1024)) | ||
blob = bytearray(r.randrange(0, 256) for _ in range(64 * 1024)) |
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.
Lines 13-13
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
j = 0 | ||
for i, buf in result: | ||
for j, (i, buf) in enumerate(result): | ||
assert i == j | ||
assert len(buf) == f.bufsize | ||
j += 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 test_read
refactored with the following changes:
- Replace manual loop counter with call to enumerate (
convert-to-enumerate
)
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
master
branch, then run: