Skip to content

Commit 9a93fb8

Browse files
authored
chore(ruff): enforce imports at top level via PLC0415 (Bluetooth-Devices#263)
1 parent 2914b34 commit 9a93fb8

5 files changed

Lines changed: 11 additions & 9 deletions

File tree

bench/test_parse_gap_tuple.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from bluetooth_data_tools import parse_advertisement_data_tuple
1+
from bluetooth_data_tools import (
2+
parse_advertisement_data_bytes,
3+
parse_advertisement_data_tuple,
4+
)
25
from bluetooth_data_tools.gap import _uncached_parse_advertisement_data
36

47
# cythonize -X language_level=3 -a -i src/bluetooth_data_tools/gap.py
@@ -92,8 +95,6 @@ def test_parse_advertisement_data_tuple_uncached(benchmark):
9295

9396

9497
def test_parse_advertisement_data_tuple_bytes_cache_fallthrough(benchmark):
95-
from bluetooth_data_tools import parse_advertisement_data_bytes
96-
9798
joined = b"".join(advs)
9899
parse_advertisement_data_bytes(joined)
99100

build_ext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def build(setup_kwargs: Any) -> None:
6363
if os.environ.get("SKIP_CYTHON", False):
6464
return
6565
try:
66-
from Cython.Build import cythonize
66+
from Cython.Build import cythonize # noqa: PLC0415
6767

6868
setup_kwargs.update(
6969
dict(

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ extend-select = [
129129
"E",
130130
"F",
131131
"I", # isort
132+
"PLC0415", # import-outside-toplevel
132133
"S", # security (bandit)
133134
"W",
134135
"UP", # pyupgrade

tests/benchmarks/test_parse_gap_tuple.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# cythonize -X language_level=3 -a -i src/bluetooth_data_tools/gap.py
22
from pytest_codspeed import BenchmarkFixture
33

4-
from bluetooth_data_tools import parse_advertisement_data_tuple
4+
from bluetooth_data_tools import (
5+
parse_advertisement_data_bytes,
6+
parse_advertisement_data_tuple,
7+
)
58
from bluetooth_data_tools.gap import _uncached_parse_advertisement_data
69

710
advs = (
@@ -101,8 +104,6 @@ def test_parse_advertisement_data_tuple_bytes_cache_fallthrough(
101104
identity per callback but the joined payload was already parsed (e.g.
102105
same advertisement was seen via the bytes-form helper earlier).
103106
"""
104-
from bluetooth_data_tools import parse_advertisement_data_bytes
105-
106107
joined = b"".join(advs)
107108
parse_advertisement_data_bytes(joined)
108109

tests/test_gap.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import base64
2+
import logging
23

34
import pytest
45

@@ -103,8 +104,6 @@ def test_parse_advertisement_data_trailing_minimum_ad_struct(caplog):
103104
# Manufacturer-data struct (5 bytes) followed by a trailing minimum-AD
104105
# struct [length=1][type=0x09] (2 bytes). The loop must enter the trailing
105106
# struct rather than silently skip it; preceding data must still parse.
106-
import logging
107-
108107
data = [b"\x04\xff\x4c\x00\x10\x01\x09"]
109108

110109
with caplog.at_level(logging.DEBUG, logger="bluetooth_data_tools.gap"):

0 commit comments

Comments
 (0)