kopia lustrzana https://github.com/micropython/micropython-lib
all: Lint Python code with ruff.
Signed-off-by: Christian Clauss <cclauss@me.com>pull/651/head
rodzic
752ce66c24
commit
4da6e6f1b2
|
@ -9,8 +9,8 @@ jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-python@v1
|
- uses: actions/setup-python@v4
|
||||||
- name: Setup environment
|
- name: Setup environment
|
||||||
run: source tools/ci.sh && ci_build_packages_setup
|
run: source tools/ci.sh && ci_build_packages_setup
|
||||||
- name: Check manifest files
|
- name: Check manifest files
|
||||||
|
|
|
@ -7,6 +7,6 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: vars.MICROPY_PUBLISH_MIP_INDEX
|
if: vars.MICROPY_PUBLISH_MIP_INDEX
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Clean up published files
|
- name: Clean up published files
|
||||||
run: source tools/ci.sh && ci_cleanup_package_index ${{ github.event.ref }}
|
run: source tools/ci.sh && ci_cleanup_package_index ${{ github.event.ref }}
|
||||||
|
|
|
@ -6,8 +6,10 @@ jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-python@v1
|
- run: pip install --user ruff
|
||||||
|
- run: ruff --format=github .
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
- name: Install packages
|
- name: Install packages
|
||||||
run: source tools/ci.sh && ci_code_formatting_setup
|
run: source tools/ci.sh && ci_code_formatting_setup
|
||||||
- name: Run code formatting
|
- name: Run code formatting
|
||||||
|
|
|
@ -11,17 +11,17 @@ class AIOESPNow(espnow.ESPNow):
|
||||||
# Read one ESPNow message
|
# Read one ESPNow message
|
||||||
async def arecv(self):
|
async def arecv(self):
|
||||||
yield asyncio.core._io_queue.queue_read(self)
|
yield asyncio.core._io_queue.queue_read(self)
|
||||||
return self.recv(0) # type: ignore
|
return self.recv(0) # type: ignore[misc]
|
||||||
|
|
||||||
async def airecv(self):
|
async def airecv(self):
|
||||||
yield asyncio.core._io_queue.queue_read(self)
|
yield asyncio.core._io_queue.queue_read(self)
|
||||||
return self.irecv(0) # type: ignore
|
return self.irecv(0) # type: ignore[misc]
|
||||||
|
|
||||||
async def asend(self, mac, msg=None, sync=None):
|
async def asend(self, mac, msg=None, sync=None):
|
||||||
if msg is None:
|
if msg is None:
|
||||||
msg, mac = mac, None # If msg is None: swap mac and msg
|
msg, mac = mac, None # If msg is None: swap mac and msg
|
||||||
yield asyncio.core._io_queue.queue_write(self)
|
yield asyncio.core._io_queue.queue_write(self)
|
||||||
return self.send(mac, msg, sync) # type: ignore
|
return self.send(mac, msg, sync) # type: ignore[misc]
|
||||||
|
|
||||||
# "async for" support
|
# "async for" support
|
||||||
def __aiter__(self):
|
def __aiter__(self):
|
||||||
|
|
|
@ -87,7 +87,7 @@ class FileClient:
|
||||||
|
|
||||||
send_seq = await self._command(_COMMAND_SEND, path.encode())
|
send_seq = await self._command(_COMMAND_SEND, path.encode())
|
||||||
|
|
||||||
with open(dest, "wb") as f:
|
with open(dest, "wb") as f: # noqa: ASYNC101
|
||||||
total = 0
|
total = 0
|
||||||
buf = bytearray(self._channel.our_mtu)
|
buf = bytearray(self._channel.our_mtu)
|
||||||
mv = memoryview(buf)
|
mv = memoryview(buf)
|
||||||
|
|
|
@ -82,7 +82,7 @@ async def l2cap_task(connection):
|
||||||
|
|
||||||
if send_file:
|
if send_file:
|
||||||
print("Sending:", send_file)
|
print("Sending:", send_file)
|
||||||
with open(send_file, "rb") as f:
|
with open(send_file, "rb") as f: # noqa: ASYNC101
|
||||||
buf = bytearray(channel.peer_mtu)
|
buf = bytearray(channel.peer_mtu)
|
||||||
mv = memoryview(buf)
|
mv = memoryview(buf)
|
||||||
while n := f.readinto(buf):
|
while n := f.readinto(buf):
|
||||||
|
|
|
@ -578,7 +578,7 @@ class WM8960:
|
||||||
raise ValueError("Invalid route")
|
raise ValueError("Invalid route")
|
||||||
|
|
||||||
def set_left_input(self, input):
|
def set_left_input(self, input):
|
||||||
if not input in self._input_config_table.keys():
|
if input not in self._input_config_table:
|
||||||
raise ValueError("Invalid input")
|
raise ValueError("Invalid input")
|
||||||
|
|
||||||
input = self._input_config_table[input]
|
input = self._input_config_table[input]
|
||||||
|
@ -595,7 +595,7 @@ class WM8960:
|
||||||
regs[_LINVOL] = input[1]
|
regs[_LINVOL] = input[1]
|
||||||
|
|
||||||
def set_right_input(self, input):
|
def set_right_input(self, input):
|
||||||
if not input in self._input_config_table.keys():
|
if input not in self._input_config_table:
|
||||||
raise ValueError("Invalid input name")
|
raise ValueError("Invalid input name")
|
||||||
|
|
||||||
input = self._input_config_table[input]
|
input = self._input_config_table[input]
|
||||||
|
@ -629,7 +629,7 @@ class WM8960:
|
||||||
self.regs[_IFACE1] = (_IFACE1_WL_MASK, wl << _IFACE1_WL_SHIFT)
|
self.regs[_IFACE1] = (_IFACE1_WL_MASK, wl << _IFACE1_WL_SHIFT)
|
||||||
|
|
||||||
def volume(self, module, volume_l=None, volume_r=None):
|
def volume(self, module, volume_l=None, volume_r=None):
|
||||||
if not module in self._volume_config_table.keys():
|
if module not in self._volume_config_table:
|
||||||
raise ValueError("Invalid module")
|
raise ValueError("Invalid module")
|
||||||
|
|
||||||
if volume_l is None: # get volume
|
if volume_l is None: # get volume
|
||||||
|
@ -644,7 +644,7 @@ class WM8960:
|
||||||
|
|
||||||
if not ((0 <= volume_l <= 100) and (0 <= volume_r <= 100)):
|
if not ((0 <= volume_l <= 100) and (0 <= volume_r <= 100)):
|
||||||
raise ValueError("Invalid value for volume")
|
raise ValueError("Invalid value for volume")
|
||||||
elif not module in self._volume_config_table.keys():
|
elif module not in self._volume_config_table:
|
||||||
raise ValueError("Invalid module")
|
raise ValueError("Invalid module")
|
||||||
|
|
||||||
vol_max, regnum, flags = self._volume_config_table[module]
|
vol_max, regnum, flags = self._volume_config_table[module]
|
||||||
|
|
|
@ -524,13 +524,13 @@ class BMI270:
|
||||||
# Sanity checks
|
# Sanity checks
|
||||||
if not self._use_i2c:
|
if not self._use_i2c:
|
||||||
raise ValueError("SPI mode is not supported")
|
raise ValueError("SPI mode is not supported")
|
||||||
if not gyro_odr in ODR:
|
if gyro_odr not in ODR:
|
||||||
raise ValueError("Invalid gyro sampling rate: %d" % gyro_odr)
|
raise ValueError("Invalid gyro sampling rate: %d" % gyro_odr)
|
||||||
if not gyro_scale in GYRO_SCALE:
|
if gyro_scale not in GYRO_SCALE:
|
||||||
raise ValueError("Invalid gyro scaling: %d" % gyro_scale)
|
raise ValueError("Invalid gyro scaling: %d" % gyro_scale)
|
||||||
if not accel_odr in ODR:
|
if accel_odr not in ODR:
|
||||||
raise ValueError("Invalid accelerometer sampling rate: %d" % accel_odr)
|
raise ValueError("Invalid accelerometer sampling rate: %d" % accel_odr)
|
||||||
if not accel_scale in ACCEL_SCALE:
|
if accel_scale not in ACCEL_SCALE:
|
||||||
raise ValueError("Invalid accelerometer scaling: %d" % accel_scale)
|
raise ValueError("Invalid accelerometer scaling: %d" % accel_scale)
|
||||||
if self._read_reg(_CHIP_ID) != 0x24:
|
if self._read_reg(_CHIP_ID) != 0x24:
|
||||||
raise OSError("No BMI270 device was found at address 0x%x" % (self.address))
|
raise OSError("No BMI270 device was found at address 0x%x" % (self.address))
|
||||||
|
|
|
@ -80,7 +80,7 @@ class BMM150:
|
||||||
# Sanity checks
|
# Sanity checks
|
||||||
if not self._use_i2c:
|
if not self._use_i2c:
|
||||||
raise ValueError("SPI mode is not supported")
|
raise ValueError("SPI mode is not supported")
|
||||||
if not magnet_odr in _ODR:
|
if magnet_odr not in _ODR:
|
||||||
raise ValueError("Invalid sampling rate: %d" % magnet_odr)
|
raise ValueError("Invalid sampling rate: %d" % magnet_odr)
|
||||||
|
|
||||||
# Perform soft reset, and power on.
|
# Perform soft reset, and power on.
|
||||||
|
|
|
@ -130,20 +130,20 @@ class LSM6DSOX:
|
||||||
accel_odr = round(accel_odr, 2)
|
accel_odr = round(accel_odr, 2)
|
||||||
|
|
||||||
# Sanity checks
|
# Sanity checks
|
||||||
if not gyro_odr in ODR:
|
if gyro_odr not in ODR:
|
||||||
raise ValueError("Invalid sampling rate: %d" % gyro_odr)
|
raise ValueError("Invalid sampling rate: %d" % gyro_odr)
|
||||||
if not gyro_scale in SCALE_GYRO:
|
if gyro_scale not in SCALE_GYRO:
|
||||||
raise ValueError("invalid gyro scaling: %d" % gyro_scale)
|
raise ValueError("invalid gyro scaling: %d" % gyro_scale)
|
||||||
if not accel_odr in ODR:
|
if accel_odr not in ODR:
|
||||||
raise ValueError("Invalid sampling rate: %d" % accel_odr)
|
raise ValueError("Invalid sampling rate: %d" % accel_odr)
|
||||||
if not accel_scale in SCALE_ACCEL:
|
if accel_scale not in SCALE_ACCEL:
|
||||||
raise ValueError("invalid accelerometer scaling: %d" % accel_scale)
|
raise ValueError("invalid accelerometer scaling: %d" % accel_scale)
|
||||||
|
|
||||||
# Soft-reset the device.
|
# Soft-reset the device.
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
# Load and configure MLC if UCF file is provided
|
# Load and configure MLC if UCF file is provided
|
||||||
if ucf != None:
|
if ucf is not None:
|
||||||
self.load_mlc(ucf)
|
self.load_mlc(ucf)
|
||||||
|
|
||||||
# Set Gyroscope datarate and scale.
|
# Set Gyroscope datarate and scale.
|
||||||
|
|
|
@ -17,7 +17,7 @@ def imu_int_handler(pin):
|
||||||
INT_FLAG = True
|
INT_FLAG = True
|
||||||
|
|
||||||
|
|
||||||
if INT_MODE == True:
|
if INT_MODE is True:
|
||||||
int_pin = Pin(24)
|
int_pin = Pin(24)
|
||||||
int_pin.irq(handler=imu_int_handler, trigger=Pin.IRQ_RISING)
|
int_pin.irq(handler=imu_int_handler, trigger=Pin.IRQ_RISING)
|
||||||
|
|
||||||
|
@ -44,5 +44,5 @@ while True:
|
||||||
print(UCF_LABELS[lsm.mlc_output()[0]])
|
print(UCF_LABELS[lsm.mlc_output()[0]])
|
||||||
else:
|
else:
|
||||||
buf = lsm.mlc_output()
|
buf = lsm.mlc_output()
|
||||||
if buf != None:
|
if buf is not None:
|
||||||
print(UCF_LABELS[buf[0]])
|
print(UCF_LABELS[buf[0]])
|
||||||
|
|
|
@ -95,19 +95,19 @@ class LSM9DS1:
|
||||||
self.address_magnet = address_magnet
|
self.address_magnet = address_magnet
|
||||||
|
|
||||||
# Sanity checks
|
# Sanity checks
|
||||||
if not gyro_odr in _ODR_IMU:
|
if gyro_odr not in _ODR_IMU:
|
||||||
raise ValueError("Invalid gyro sampling rate: %d" % gyro_odr)
|
raise ValueError("Invalid gyro sampling rate: %d" % gyro_odr)
|
||||||
if not gyro_scale in _GYRO_SCALE:
|
if gyro_scale not in _GYRO_SCALE:
|
||||||
raise ValueError("Invalid gyro scaling: %d" % gyro_scale)
|
raise ValueError("Invalid gyro scaling: %d" % gyro_scale)
|
||||||
|
|
||||||
if not accel_odr in _ODR_IMU:
|
if accel_odr not in _ODR_IMU:
|
||||||
raise ValueError("Invalid accelerometer sampling rate: %d" % accel_odr)
|
raise ValueError("Invalid accelerometer sampling rate: %d" % accel_odr)
|
||||||
if not accel_scale in _ACCEL_SCALE:
|
if accel_scale not in _ACCEL_SCALE:
|
||||||
raise ValueError("Invalid accelerometer scaling: %d" % accel_scale)
|
raise ValueError("Invalid accelerometer scaling: %d" % accel_scale)
|
||||||
|
|
||||||
if not magnet_odr in _ODR_MAGNET:
|
if magnet_odr not in _ODR_MAGNET:
|
||||||
raise ValueError("Invalid magnet sampling rate: %d" % magnet_odr)
|
raise ValueError("Invalid magnet sampling rate: %d" % magnet_odr)
|
||||||
if not magnet_scale in _MAGNET_SCALE:
|
if magnet_scale not in _MAGNET_SCALE:
|
||||||
raise ValueError("Invalid magnet scaling: %d" % magnet_scale)
|
raise ValueError("Invalid magnet scaling: %d" % magnet_scale)
|
||||||
|
|
||||||
if (self.magent_id() != b"=") or (self.gyro_id() != b"h"):
|
if (self.magent_id() != b"=") or (self.gyro_id() != b"h"):
|
||||||
|
|
|
@ -40,7 +40,7 @@ def main():
|
||||||
print("Receiving...")
|
print("Receiving...")
|
||||||
rx = modem.recv(timeout_ms=5000)
|
rx = modem.recv(timeout_ms=5000)
|
||||||
if rx:
|
if rx:
|
||||||
print(f"Received: {repr(rx)}")
|
print(f"Received: {rx!r}")
|
||||||
else:
|
else:
|
||||||
print("Timeout!")
|
print("Timeout!")
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
|
@ -41,7 +41,7 @@ async def recv_coro(modem):
|
||||||
print("Receiving...")
|
print("Receiving...")
|
||||||
rx = await modem.recv(2000)
|
rx = await modem.recv(2000)
|
||||||
if rx:
|
if rx:
|
||||||
print(f"Received: {repr(rx)}")
|
print(f"Received: {rx!r}")
|
||||||
else:
|
else:
|
||||||
print("Receive timeout!")
|
print("Receive timeout!")
|
||||||
|
|
||||||
|
|
|
@ -487,7 +487,7 @@ class _SX126x(BaseModem):
|
||||||
else:
|
else:
|
||||||
# DS says "Contact your Semtech representative for the other optimal
|
# DS says "Contact your Semtech representative for the other optimal
|
||||||
# calibration settings outside of the given frequency bands"
|
# calibration settings outside of the given frequency bands"
|
||||||
raise ValueError()
|
raise ValueError
|
||||||
|
|
||||||
self._cmd(">BH", _CMD_CALIBRATE_IMAGE, args)
|
self._cmd(">BH", _CMD_CALIBRATE_IMAGE, args)
|
||||||
|
|
||||||
|
|
|
@ -282,7 +282,7 @@ class BaseModem:
|
||||||
#
|
#
|
||||||
# Part of common low-level modem API, see README.md for usage.
|
# Part of common low-level modem API, see README.md for usage.
|
||||||
if continuous and timeout_ms is not None:
|
if continuous and timeout_ms is not None:
|
||||||
raise ValueError() # these two options are mutually exclusive
|
raise ValueError # these two options are mutually exclusive
|
||||||
|
|
||||||
if timeout_ms is not None:
|
if timeout_ms is not None:
|
||||||
self._rx = time.ticks_add(time.ticks_ms(), timeout_ms)
|
self._rx = time.ticks_add(time.ticks_ms(), timeout_ms)
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Coordinates(SenmlRecord):
|
||||||
|
|
||||||
def _check_value_type(self, value):
|
def _check_value_type(self, value):
|
||||||
"""overriding the check on value type to make certain that only an array with 3 values is assigned: lat,lon/alt"""
|
"""overriding the check on value type to make certain that only an array with 3 values is assigned: lat,lon/alt"""
|
||||||
if not value == None:
|
if value is not None:
|
||||||
if not isinstance(value, list):
|
if not isinstance(value, list):
|
||||||
raise Exception("invalid data type: array with 3 elements expected lat, lon, alt")
|
raise Exception("invalid data type: array with 3 elements expected lat, lon, alt")
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ def gateway_callback(record, **kwargs):
|
||||||
:param kwargs: optional extra parameters (device can be found here)
|
:param kwargs: optional extra parameters (device can be found here)
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
if "device" in kwargs and kwargs["device"] != None:
|
if "device" in kwargs and kwargs["device"] is not None:
|
||||||
print("for device: " + kwargs["device"].name)
|
print("for device: " + kwargs["device"].name)
|
||||||
else:
|
else:
|
||||||
print("for gateway: ")
|
print("for gateway: ")
|
||||||
|
|
|
@ -47,7 +47,7 @@ class SenmlPackIterator:
|
||||||
self._index += 1
|
self._index += 1
|
||||||
return res
|
return res
|
||||||
else:
|
else:
|
||||||
raise StopIteration()
|
raise StopIteration
|
||||||
|
|
||||||
|
|
||||||
class SenmlPack(SenmlBase):
|
class SenmlPack(SenmlBase):
|
||||||
|
@ -156,7 +156,7 @@ class SenmlPack(SenmlBase):
|
||||||
checks if the type of value is allowed for senml
|
checks if the type of value is allowed for senml
|
||||||
:return: None, raisee exception if not ok.
|
:return: None, raisee exception if not ok.
|
||||||
"""
|
"""
|
||||||
if not value == None:
|
if value is not None:
|
||||||
if not (isinstance(value, int) or isinstance(value, float)):
|
if not (isinstance(value, int) or isinstance(value, float)):
|
||||||
raise Exception("invalid type for " + field_name + ", only numbers allowed")
|
raise Exception("invalid type for " + field_name + ", only numbers allowed")
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ class SenmlPack(SenmlBase):
|
||||||
"""
|
"""
|
||||||
if not (isinstance(item, SenmlBase)):
|
if not (isinstance(item, SenmlBase)):
|
||||||
raise Exception("invalid type of param, SenmlRecord or SenmlPack expected")
|
raise Exception("invalid type of param, SenmlRecord or SenmlPack expected")
|
||||||
if not item._parent == None:
|
if item._parent is not None:
|
||||||
raise Exception("item is already part of a pack")
|
raise Exception("item is already part of a pack")
|
||||||
|
|
||||||
self._data.append(item)
|
self._data.append(item)
|
||||||
|
|
|
@ -79,7 +79,7 @@ class SenmlRecord(SenmlBase):
|
||||||
checks if the type of value is allowed for senml
|
checks if the type of value is allowed for senml
|
||||||
:return: None, raisee exception if not ok.
|
:return: None, raisee exception if not ok.
|
||||||
"""
|
"""
|
||||||
if not value == None:
|
if value is not None:
|
||||||
if not (
|
if not (
|
||||||
isinstance(value, bool)
|
isinstance(value, bool)
|
||||||
or isinstance(value, int)
|
or isinstance(value, int)
|
||||||
|
@ -96,7 +96,7 @@ class SenmlRecord(SenmlBase):
|
||||||
checks if the type of value is allowed for senml
|
checks if the type of value is allowed for senml
|
||||||
:return: None, raisee exception if not ok.
|
:return: None, raisee exception if not ok.
|
||||||
"""
|
"""
|
||||||
if not value == None:
|
if value is not None:
|
||||||
if not (isinstance(value, int) or isinstance(value, float)):
|
if not (isinstance(value, int) or isinstance(value, float)):
|
||||||
raise Exception("invalid type for " + field_name + ", only numbers allowed")
|
raise Exception("invalid type for " + field_name + ", only numbers allowed")
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
[tool.ruff]
|
||||||
|
exclude = [
|
||||||
|
"python-stdlib",
|
||||||
|
"unix-ffi",
|
||||||
|
]
|
||||||
|
select = [
|
||||||
|
"ASYNC", # flake8-comprehensions
|
||||||
|
"C4", # flake8-comprehensions
|
||||||
|
"C90", # McCabe cyclomatic complexity
|
||||||
|
"DTZ", # flake8-datetimez
|
||||||
|
"E", # pycodestyle
|
||||||
|
"EXE", # flake8-executable
|
||||||
|
"F", # Pyflakes
|
||||||
|
"G", # flake8-logging-format
|
||||||
|
"ICN", # flake8-import-conventions
|
||||||
|
"INT", # flake8-gettext
|
||||||
|
"ISC", # flake8-implicit-str-concat
|
||||||
|
"PGH", # pygrep-hooks
|
||||||
|
"PIE", # flake8-pie
|
||||||
|
"PL", # Pylint
|
||||||
|
"PYI", # flake8-pyi
|
||||||
|
"RSE", # flake8-raise
|
||||||
|
"RUF", # Ruff-specific rules
|
||||||
|
"T10", # flake8-debugger
|
||||||
|
"TCH", # flake8-type-checking
|
||||||
|
"W", # pycodestyle
|
||||||
|
"YTT", # flake8-2020
|
||||||
|
# "A", # flake8-builtins
|
||||||
|
# "ANN", # flake8-annotations
|
||||||
|
# "ARG", # flake8-unused-arguments
|
||||||
|
# "B", # flake8-bugbear
|
||||||
|
# "BLE", # flake8-blind-except
|
||||||
|
# "COM", # flake8-commas
|
||||||
|
# "D", # pydocstyle
|
||||||
|
# "DJ", # flake8-django
|
||||||
|
# "EM", # flake8-errmsg
|
||||||
|
# "ERA", # eradicate
|
||||||
|
# "FBT", # flake8-boolean-trap
|
||||||
|
# "I", # isort
|
||||||
|
# "INP", # flake8-no-pep420
|
||||||
|
# "N", # pep8-naming
|
||||||
|
# "NPY", # NumPy-specific rules
|
||||||
|
# "PD", # pandas-vet
|
||||||
|
# "PT", # flake8-pytest-style
|
||||||
|
# "PTH", # flake8-use-pathlib
|
||||||
|
# "Q", # flake8-quotes
|
||||||
|
# "RET", # flake8-return
|
||||||
|
# "S", # flake8-bandit
|
||||||
|
# "SIM", # flake8-simplify
|
||||||
|
# "SLF", # flake8-self
|
||||||
|
# "T20", # flake8-print
|
||||||
|
# "TID", # flake8-tidy-imports
|
||||||
|
# "TRY", # tryceratops
|
||||||
|
# "UP", # pyupgrade
|
||||||
|
]
|
||||||
|
ignore = [
|
||||||
|
"E401",
|
||||||
|
"E402",
|
||||||
|
"E722",
|
||||||
|
"E741",
|
||||||
|
"F401",
|
||||||
|
"F403",
|
||||||
|
"F405",
|
||||||
|
"F541",
|
||||||
|
"F821",
|
||||||
|
"F841",
|
||||||
|
"ISC003", # micropython does not support implicit concatenation of f-strings
|
||||||
|
"PIE810", # micropython does not support passing tuples to .startswith or .endswith
|
||||||
|
"PLC1901",
|
||||||
|
"PLR1701",
|
||||||
|
"PLR1714",
|
||||||
|
"PLR5501",
|
||||||
|
"PLW0602",
|
||||||
|
"PLW0603",
|
||||||
|
"PLW2901",
|
||||||
|
"RUF012",
|
||||||
|
"RUF100",
|
||||||
|
]
|
||||||
|
line-length = 260
|
||||||
|
target-version = "py37"
|
||||||
|
|
||||||
|
[tool.ruff.mccabe]
|
||||||
|
max-complexity = 61
|
||||||
|
|
||||||
|
[tool.ruff.pylint]
|
||||||
|
allow-magic-value-types = ["bytes", "int", "str"]
|
||||||
|
max-args = 14
|
||||||
|
max-branches = 58
|
||||||
|
max-returns = 13
|
||||||
|
max-statements = 166
|
||||||
|
|
||||||
|
[tool.ruff.per-file-ignores]
|
||||||
|
"micropython/aiorepl/aiorepl.py" = ["PGH001"]
|
|
@ -25,7 +25,6 @@ THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import math
|
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,6 @@ class Stats:
|
||||||
st["errors"],
|
st["errors"],
|
||||||
" receiver",
|
" receiver",
|
||||||
)
|
)
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def recvn(s, n):
|
def recvn(s, n):
|
||||||
|
|
|
@ -92,7 +92,7 @@ def request(
|
||||||
if proto == "https:":
|
if proto == "https:":
|
||||||
s = ussl.wrap_socket(s, server_hostname=host)
|
s = ussl.wrap_socket(s, server_hostname=host)
|
||||||
s.write(b"%s /%s HTTP/1.0\r\n" % (method, path))
|
s.write(b"%s /%s HTTP/1.0\r\n" % (method, path))
|
||||||
if not "Host" in headers:
|
if "Host" not in headers:
|
||||||
s.write(b"Host: %s\r\n" % host)
|
s.write(b"Host: %s\r\n" % host)
|
||||||
# Iterate over keys to avoid tuple alloc
|
# Iterate over keys to avoid tuple alloc
|
||||||
for k in headers:
|
for k in headers:
|
||||||
|
|
Ładowanie…
Reference in New Issue