Conversation
| mac = mac[0:6] + 'fffe' + mac[6:] | ||
| return hex(int(mac[0:2], 16) ^ 2)[2:] + mac[2:] | ||
| mac = f'{mac[:6]}fffe{mac[6:]}' | ||
| return hex(int(mac[:2], 16) ^ 2)[2:] + mac[2:] |
There was a problem hiding this comment.
Function mac2eui refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] [×2] (
remove-redundant-slice-index) - Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation)
| def get_millis(): | ||
| millisecond = time.ticks_ms() | ||
| return millisecond | ||
| return time.ticks_ms() |
There was a problem hiding this comment.
Function get_millis refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| node_name = "ESP_" + uuid | ||
| return node_name | ||
| return f"ESP_{uuid}" |
There was a problem hiding this comment.
Function get_nodename refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable) - Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| if example == 'sender': | ||
| LoRaSender.send(lora) | ||
| if example == 'receiver': | ||
| LoRaReceiver.receive(lora) No newline at end of file | ||
| LoRaReceiver.receive(lora) | ||
| elif example == 'sender': | ||
| LoRaSender.send(lora) No newline at end of file |
There was a problem hiding this comment.
Lines 23-26 refactored with the following changes:
- Simplify conditional into switch-like form (
switch)
| oled.fill(0) | ||
| for row, text in enumerate(screen): | ||
| print("{} - {}".format(row, text)) | ||
| print(f"{row} - {text}") |
There was a problem hiding this comment.
Function write_screen refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
| bins = (7.8E3, 10.4E3, 15.6E3, 20.8E3, 31.25E3, 41.7E3, 62.5E3, 125E3, 250E3) | ||
|
|
||
| bw = 9 | ||
|
|
||
| if sbw < 10: | ||
| bw = sbw | ||
| else: | ||
| bins = (7.8E3, 10.4E3, 15.6E3, 20.8E3, 31.25E3, 41.7E3, 62.5E3, 125E3, 250E3) | ||
|
|
There was a problem hiding this comment.
Function SX127x.set_signal_bandwidth refactored with the following changes:
- Move assignments closer to their usage (
move-assign)
|
|
||
| payload = bytearray() | ||
| for i in range(packet_length): | ||
| for _ in range(packet_length): |
There was a problem hiding this comment.
Function SX127x.read_payload refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore)
|
|
||
| def blink_led(self, times = 1, on_seconds = 0.1, off_seconds = 0.1): | ||
| for i in range(times): | ||
| for _ in range(times): |
There was a problem hiding this comment.
Function SX127x.blink_led refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore)
| gc.collect() | ||
| if __DEBUG__: | ||
| print('[Memory - free: {} allocated: {}]'.format(gc.mem_free(), gc.mem_alloc())) | ||
| print(f'[Memory - free: {gc.mem_free()} allocated: {gc.mem_alloc()}]') |
There was a problem hiding this comment.
Function SX127x.collect_garbage refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
| payload = lora.read_payload() | ||
| print(payload) | ||
| screen[0] = "pkt: {}".format(payload) | ||
| screen[0] = f"pkt: {payload}" |
There was a problem hiding this comment.
Function receive refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
Branch
mainrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
mainbranch, then run:Help us improve this pull request!