all: Apply Ruff 0.11.6 reformatting changes.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
pull/1001/head
Angus Gratton 2025-04-24 11:01:42 +10:00 zatwierdzone przez Damien George
rodzic d887a021e8
commit 68e0dfce0a
24 zmienionych plików z 22 dodań i 37 usunięć

Wyświetl plik

@ -132,7 +132,7 @@ async def task(g=None, prompt="--> "):
continue continue
if curs: if curs:
# move cursor to end of the line # move cursor to end of the line
sys.stdout.write("\x1B[{}C".format(curs)) sys.stdout.write("\x1b[{}C".format(curs))
curs = 0 curs = 0
sys.stdout.write("\n") sys.stdout.write("\n")
if cmd: if cmd:
@ -153,10 +153,10 @@ async def task(g=None, prompt="--> "):
if curs: if curs:
cmd = "".join((cmd[: -curs - 1], cmd[-curs:])) cmd = "".join((cmd[: -curs - 1], cmd[-curs:]))
sys.stdout.write( sys.stdout.write(
"\x08\x1B[K" "\x08\x1b[K"
) # move cursor back, erase to end of line ) # move cursor back, erase to end of line
sys.stdout.write(cmd[-curs:]) # redraw line sys.stdout.write(cmd[-curs:]) # redraw line
sys.stdout.write("\x1B[{}D".format(curs)) # reset cursor location sys.stdout.write("\x1b[{}D".format(curs)) # reset cursor location
else: else:
cmd = cmd[:-1] cmd = cmd[:-1]
sys.stdout.write("\x08 \x08") sys.stdout.write("\x08 \x08")
@ -207,21 +207,21 @@ async def task(g=None, prompt="--> "):
elif key == "[D": # left elif key == "[D": # left
if curs < len(cmd) - 1: if curs < len(cmd) - 1:
curs += 1 curs += 1
sys.stdout.write("\x1B") sys.stdout.write("\x1b")
sys.stdout.write(key) sys.stdout.write(key)
elif key == "[C": # right elif key == "[C": # right
if curs: if curs:
curs -= 1 curs -= 1
sys.stdout.write("\x1B") sys.stdout.write("\x1b")
sys.stdout.write(key) sys.stdout.write(key)
elif key == "[H": # home elif key == "[H": # home
pcurs = curs pcurs = curs
curs = len(cmd) curs = len(cmd)
sys.stdout.write("\x1B[{}D".format(curs - pcurs)) # move cursor left sys.stdout.write("\x1b[{}D".format(curs - pcurs)) # move cursor left
elif key == "[F": # end elif key == "[F": # end
pcurs = curs pcurs = curs
curs = 0 curs = 0
sys.stdout.write("\x1B[{}C".format(pcurs)) # move cursor right sys.stdout.write("\x1b[{}C".format(pcurs)) # move cursor right
else: else:
# sys.stdout.write("\\x") # sys.stdout.write("\\x")
# sys.stdout.write(hex(c)) # sys.stdout.write(hex(c))
@ -231,7 +231,7 @@ async def task(g=None, prompt="--> "):
# inserting into middle of line # inserting into middle of line
cmd = "".join((cmd[:-curs], b, cmd[-curs:])) cmd = "".join((cmd[:-curs], b, cmd[-curs:]))
sys.stdout.write(cmd[-curs - 1 :]) # redraw line to end sys.stdout.write(cmd[-curs - 1 :]) # redraw line to end
sys.stdout.write("\x1B[{}D".format(curs)) # reset cursor location sys.stdout.write("\x1b[{}D".format(curs)) # reset cursor location
else: else:
sys.stdout.write(b) sys.stdout.write(b)
cmd += b cmd += b

Wyświetl plik

@ -43,6 +43,7 @@ while (True):
print("") print("")
time.sleep_ms(100) time.sleep_ms(100)
""" """
import array import array
from micropython import const from micropython import const

Wyświetl plik

@ -1,5 +1,4 @@
"""NRF24L01 driver for MicroPython """NRF24L01 driver for MicroPython"""
"""
from micropython import const from micropython import const
import utime import utime

Wyświetl plik

@ -52,7 +52,7 @@ class HTS221:
# Set configuration register # Set configuration register
# Humidity and temperature average configuration # Humidity and temperature average configuration
self.bus.writeto_mem(self.slv_addr, 0x10, b"\x1B") self.bus.writeto_mem(self.slv_addr, 0x10, b"\x1b")
# Set control register # Set control register
# PD | BDU | ODR # PD | BDU | ODR

Wyświetl plik

@ -37,6 +37,7 @@ while (True):
print("Pressure: %.2f hPa Temperature: %.2f C"%(lps.pressure(), lps.temperature())) print("Pressure: %.2f hPa Temperature: %.2f C"%(lps.pressure(), lps.temperature()))
time.sleep_ms(10) time.sleep_ms(10)
""" """
import machine import machine
from micropython import const from micropython import const

Wyświetl plik

@ -113,22 +113,22 @@ class ESPFlash:
raise Exception(f"Register poll timeout. Addr: 0x{addr:02X} Flag: 0x{flag:02X}.") raise Exception(f"Register poll timeout. Addr: 0x{addr:02X} Flag: 0x{flag:02X}.")
def _write_slip(self, pkt): def _write_slip(self, pkt):
pkt = pkt.replace(b"\xDB", b"\xdb\xdd").replace(b"\xc0", b"\xdb\xdc") pkt = pkt.replace(b"\xdb", b"\xdb\xdd").replace(b"\xc0", b"\xdb\xdc")
self.uart.write(b"\xC0" + pkt + b"\xC0") self.uart.write(b"\xc0" + pkt + b"\xc0")
self._log(pkt) self._log(pkt)
def _read_slip(self): def _read_slip(self):
pkt = None pkt = None
# Find the packet start. # Find the packet start.
if self.uart.read(1) == b"\xC0": if self.uart.read(1) == b"\xc0":
pkt = bytearray() pkt = bytearray()
while True: while True:
b = self.uart.read(1) b = self.uart.read(1)
if b is None or b == b"\xC0": if b is None or b == b"\xc0":
break break
pkt += b pkt += b
pkt = pkt.replace(b"\xDB\xDD", b"\xDB").replace(b"\xDB\xDC", b"\xC0") pkt = pkt.replace(b"\xdb\xdd", b"\xdb").replace(b"\xdb\xdc", b"\xc0")
self._log(b"\xC0" + pkt + b"\xC0", False) self._log(b"\xc0" + pkt + b"\xc0", False)
return pkt return pkt
def _strerror(self, err): def _strerror(self, err):
@ -230,7 +230,7 @@ class ESPFlash:
raise Exception(f"Unexpected flash size bits: 0x{flash_bits:02X}.") raise Exception(f"Unexpected flash size bits: 0x{flash_bits:02X}.")
flash_size = 2**flash_bits flash_size = 2**flash_bits
print(f"Flash size {flash_size/1024/1024} MBytes") print(f"Flash size {flash_size / 1024 / 1024} MBytes")
return flash_size return flash_size
def flash_attach(self): def flash_attach(self):
@ -265,7 +265,7 @@ class ESPFlash:
self.md5sum.update(buf) self.md5sum.update(buf)
# The last data block should be padded to the block size with 0xFF bytes. # The last data block should be padded to the block size with 0xFF bytes.
if len(buf) < blksize: if len(buf) < blksize:
buf += b"\xFF" * (blksize - len(buf)) buf += b"\xff" * (blksize - len(buf))
checksum = self._checksum(buf) checksum = self._checksum(buf)
if seq % erase_blocks == 0: if seq % erase_blocks == 0:
# print(f"Erasing {seq} -> {seq+erase_blocks}...") # print(f"Erasing {seq} -> {seq+erase_blocks}...")

Wyświetl plik

@ -149,7 +149,7 @@ class Sender:
delta = time.ticks_diff(maybe_ack.ticks_ms, sent_at) delta = time.ticks_diff(maybe_ack.ticks_ms, sent_at)
print( print(
f"ACKed with RSSI {rssi}, {delta}ms after sent " f"ACKed with RSSI {rssi}, {delta}ms after sent "
+ f"(skew {delta-ACK_DELAY_MS-ack_packet_ms}ms)" + f"(skew {delta - ACK_DELAY_MS - ack_packet_ms}ms)"
) )
if adjust_output_power: if adjust_output_power:

Wyświetl plik

@ -141,7 +141,7 @@ class AsyncSender:
delta = time.ticks_diff(maybe_ack.ticks_ms, sent_at) delta = time.ticks_diff(maybe_ack.ticks_ms, sent_at)
print( print(
f"ACKed with RSSI {rssi}, {delta}ms after sent " f"ACKed with RSSI {rssi}, {delta}ms after sent "
+ f"(skew {delta-ACK_DELAY_MS-ack_packet_ms}ms)" + f"(skew {delta - ACK_DELAY_MS - ack_packet_ms}ms)"
) )
if adjust_output_power: if adjust_output_power:

Wyświetl plik

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
""" """
from senml import * from senml import *

Wyświetl plik

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
""" """
from senml import * from senml import *
import time import time

Wyświetl plik

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
""" """
from senml import * from senml import *
import time import time

Wyświetl plik

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
""" """
from senml import * from senml import *
import time import time

Wyświetl plik

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
""" """
from senml import * from senml import *
import time import time
import cbor2 import cbor2

Wyświetl plik

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
""" """
from senml import * from senml import *
import time import time

Wyświetl plik

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
""" """
from senml import * from senml import *
import time import time

Wyświetl plik

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
""" """
from senml import * from senml import *

Wyświetl plik

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
""" """
from senml import * from senml import *
import time import time

Wyświetl plik

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
""" """
from .senml_base import SenmlBase from .senml_base import SenmlBase
from .senml_pack import SenmlPack from .senml_pack import SenmlPack
from .senml_record import SenmlRecord from .senml_record import SenmlRecord

Wyświetl plik

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
""" """
from senml.senml_record import SenmlRecord from senml.senml_record import SenmlRecord
from senml.senml_base import SenmlBase from senml.senml_base import SenmlBase
import json import json

Wyświetl plik

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
""" """
import binascii import binascii
from senml.senml_base import SenmlBase from senml.senml_base import SenmlBase

Wyświetl plik

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
""" """
from ._decoder import CBORDecoder from ._decoder import CBORDecoder
from ._decoder import load from ._decoder import load
from ._decoder import loads from ._decoder import loads

Wyświetl plik

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
""" """
import io import io
import struct import struct

Wyświetl plik

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
""" """
import io import io
import struct import struct

Wyświetl plik

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
""" """
import cbor2 import cbor2
input = [ input = [