-
Notifications
You must be signed in to change notification settings - Fork 2
Sourcery refactored main branch #1
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: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) | ||
| LoRaReceiver.receive(lora) | ||
| elif example == 'sender': | ||
| LoRaSender.send(lora) |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!