Skip to content

Commit 00fc3fd

Browse files
projectgusdpgeorge
authored andcommittedMay 17, 2024·
all: Enable ruff E401 and E402 import lints.
Mostly small cleanups to put each top-level import on its own line. But explicitly disable the lint for examples/tests which insert the current directory into the path before importing. Signed-off-by: Angus Gratton <[email protected]>
1 parent 992eecf commit 00fc3fd

27 files changed

+58
-20
lines changed
 

‎micropython/bluetooth/aioble/examples/l2cap_file_client.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import sys
77

8+
# ruff: noqa: E402
89
sys.path.append("")
910

1011
from micropython import const

‎micropython/bluetooth/aioble/examples/l2cap_file_server.py

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import sys
1818

19+
# ruff: noqa: E402
1920
sys.path.append("")
2021

2122
from micropython import const

‎micropython/bluetooth/aioble/examples/temp_client.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22

3+
# ruff: noqa: E402
34
sys.path.append("")
45

56
from micropython import const

‎micropython/bluetooth/aioble/examples/temp_sensor.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22

3+
# ruff: noqa: E402
34
sys.path.append("")
45

56
from micropython import const

‎micropython/bluetooth/aioble/multitests/ble_buffered_characteristic.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import sys
44

5+
# ruff: noqa: E402
56
sys.path.append("")
67

78
from micropython import const
8-
import time, machine
9+
import machine
10+
import time
911

1012
import uasyncio as asyncio
1113
import aioble

‎micropython/bluetooth/aioble/multitests/ble_characteristic.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import sys
44

5+
# ruff: noqa: E402
56
sys.path.append("")
67

78
from micropython import const
8-
import time, machine
9+
import machine
10+
import time
911

1012
import uasyncio as asyncio
1113
import aioble

‎micropython/bluetooth/aioble/multitests/ble_descriptor.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import sys
44

5+
# ruff: noqa: E402
56
sys.path.append("")
67

78
from micropython import const
8-
import time, machine
9+
import machine
10+
import time
911

1012
import uasyncio as asyncio
1113
import aioble

‎micropython/bluetooth/aioble/multitests/ble_notify.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import sys
44

5+
# ruff: noqa: E402
56
sys.path.append("")
67

78
from micropython import const
8-
import time, machine
9+
import machine
10+
import time
911

1012
import uasyncio as asyncio
1113
import aioble

‎micropython/bluetooth/aioble/multitests/ble_shutdown.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import sys
44

5+
# ruff: noqa: E402
56
sys.path.append("")
67

78
from micropython import const
8-
import time, machine
9+
import machine
10+
import time
911

1012
import uasyncio as asyncio
1113
import aioble

‎micropython/bluetooth/aioble/multitests/ble_write_capture.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import sys
44

5+
# ruff: noqa: E402
56
sys.path.append("")
67

78
from micropython import const
8-
import time, machine
9+
import machine
10+
import time
911

1012
import uasyncio as asyncio
1113
import aioble

‎micropython/bluetooth/aioble/multitests/ble_write_order.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import sys
44

5+
# ruff: noqa: E402
56
sys.path.append("")
67

78
from micropython import const
8-
import time, machine
9+
import machine
10+
import time
911

1012
import uasyncio as asyncio
1113
import aioble

‎micropython/bluetooth/aioble/multitests/perf_gatt_notify.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import sys
44

5+
# ruff: noqa: E402
56
sys.path.append("")
67

78
from micropython import const
8-
import time, machine
9+
import machine
10+
import time
911

1012
import uasyncio as asyncio
1113
import aioble

‎micropython/bluetooth/aioble/multitests/perf_l2cap.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import sys
22

3+
# ruff: noqa: E402
34
sys.path.append("")
45

56
from micropython import const
6-
import time, machine
7+
import machine
8+
import time
79

810
import uasyncio as asyncio
911
import aioble

‎micropython/drivers/display/lcd160cr/lcd160cr.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
# MIT license; Copyright (c) 2017 Damien P. George
33

44
from micropython import const
5+
import machine
56
from utime import sleep_ms
67
from ustruct import calcsize, pack_into
7-
import uerrno, machine
8+
import uerrno
89

910
# for set_orient
1011
PORTRAIT = const(0)

‎micropython/drivers/display/lcd160cr/lcd160cr_test.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Driver test for official MicroPython LCD160CR display
22
# MIT license; Copyright (c) 2017 Damien P. George
33

4-
import time, math, framebuf, lcd160cr
4+
import framebuf
5+
import lcd160cr
6+
import math
7+
import time
58

69

710
def get_lcd(lcd):

‎micropython/drivers/storage/sdcard/sdtest.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Test for sdcard block protocol
22
# Peter hinch 30th Jan 2016
3-
import os, sdcard, machine
3+
import machine
4+
import os
5+
import sdcard
46

57

68
def sdtest():

‎pyproject.toml

+3-5
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,12 @@ select = [
5454
# "UP", # pyupgrade
5555
]
5656
ignore = [
57-
"E401",
58-
"E402",
5957
"E722",
60-
"E741",
58+
"E741", # 'l' is currently widely used
6159
"F401",
6260
"F403",
6361
"F405",
64-
"E501",
62+
"E501", # line length, recommended to disable
6563
"ISC001",
6664
"ISC003", # micropython does not support implicit concatenation of f-strings
6765
"PIE810", # micropython does not support passing tuples to .startswith or .endswith
@@ -74,7 +72,7 @@ ignore = [
7472
"PLW2901",
7573
"RUF012",
7674
"RUF100",
77-
"W191",
75+
"W191", # tab-indent, redundant when using formatter
7876
]
7977
line-length = 99
8078
target-version = "py37"

‎python-ecosys/aiohttp/aiohttp/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def _decode(self, data):
2222
c_encoding = self.headers.get("Content-Encoding")
2323
if c_encoding in ("gzip", "deflate", "gzip,deflate"):
2424
try:
25-
import deflate, io
25+
import deflate
26+
import io
2627

2728
if c_encoding == "deflate":
2829
with deflate.DeflateIO(io.BytesIO(data), deflate.ZLIB) as d:

‎python-ecosys/aiohttp/examples/client.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22

3+
# ruff: noqa: E402
34
sys.path.insert(0, ".")
45
import aiohttp
56
import asyncio

‎python-ecosys/aiohttp/examples/compression.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22

3+
# ruff: noqa: E402
34
sys.path.insert(0, ".")
45
import aiohttp
56
import asyncio

‎python-ecosys/aiohttp/examples/get.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22

3+
# ruff: noqa: E402
34
sys.path.insert(0, ".")
45
import aiohttp
56
import asyncio

‎python-ecosys/aiohttp/examples/headers.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22

3+
# ruff: noqa: E402
34
sys.path.insert(0, ".")
45
import aiohttp
56
import asyncio

‎python-ecosys/aiohttp/examples/methods.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22

3+
# ruff: noqa: E402
34
sys.path.insert(0, ".")
45
import aiohttp
56
import asyncio

‎python-ecosys/aiohttp/examples/params.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22

3+
# ruff: noqa: E402
34
sys.path.insert(0, ".")
45
import aiohttp
56
import asyncio

‎python-ecosys/aiohttp/examples/ws.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22

3+
# ruff: noqa: E402
34
sys.path.insert(0, ".")
45
import aiohttp
56
import asyncio

‎python-ecosys/aiohttp/examples/ws_repl_echo.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22

3+
# ruff: noqa: E402
34
sys.path.insert(0, ".")
45
import aiohttp
56
import asyncio

‎python-ecosys/iperf3/iperf3.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
iperf3.client('192.168.1.5', udp=True, reverse=True)
1313
"""
1414

15-
import sys, struct
16-
import time, select, socket
1715
import json
16+
import select
17+
import socket
18+
import struct
19+
import sys
20+
import time
1821

1922
# Provide a urandom() function, supporting devices without os.urandom().
2023
try:

0 commit comments

Comments
 (0)
Please sign in to comment.