Sourcery Starbot ⭐ refactored romanz/amodem#63
Sourcery Starbot ⭐ refactored romanz/amodem#63SourceryAI wants to merge 1 commit intoromanz:masterfrom
Conversation
| while True: | ||
| data = self.stream.read(size) | ||
| if data: | ||
| if data := self.stream.read(size): |
There was a problem hiding this comment.
Function Compressor.read refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
amodem/__main__.py
Outdated
| 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.
Function get_volume_cmd refactored with the following changes:
- Move assignments closer to their usage (
move-assign)
| 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.
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.
Function recv_iter refactored with the following changes:
- Merge nested if conditions [×2] (
merge-nested-ifs)
| log.info('Carrier coherence: %.3f%%', coeffs[index] * 100) | ||
| offset = index + len(zeroes) | ||
| return offset | ||
| return index + len(zeroes) |
There was a problem hiding this comment.
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.
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)
amodem/tests/test_dsp.py
Outdated
| q = dsp.MODEM(config.symbols) | ||
| r = np.random.RandomState(seed=0) | ||
| for i in range(10000): | ||
| for _ in range(10000): |
There was a problem hiding this comment.
Function test_overflow refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore)
| period = 2 ** 16 - 1 | ||
| 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.
Function test_prbs refactored with the following changes:
- Remove an unnecessary list construction call prior to sorting (
skip-sorted-list-construction)
|
|
||
| r = random.Random(0) | ||
| 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.
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.
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
masterbranch, then run: