Skip to content

Commit 81dfcbe

Browse files
committed
Fix pylint issues in test file
- Fix import order: pytest before local imports - Add pylint disable comments for protected access to _ask method - Achieve 10.00/10 pylint score for test file
1 parent 6f33f12 commit 81dfcbe

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

teensytoany/teensytoany.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,8 @@ def i2c_write_no_register_uint8(self, address: int, data: int):
620620
cmd = f"i2c_write_no_register_uint8 0x{address:02x} 0x{data:02x}"
621621
self._ask(cmd)
622622

623-
def i2c_read_payload_uint16(self, address: int, register_address: int, num_bytes: int) -> Sequence:
623+
def i2c_read_payload_uint16(self, address: int, register_address: int,
624+
num_bytes: int) -> Sequence:
624625
"""Read up to 256 bytes from the I2C bus starting at a specified 16 bit register address."""
625626
cmd = f"i2c_read_payload_uint16 0x{address:02x} 0x{register_address:04x} {num_bytes}"
626627
returned = self._ask(cmd)
@@ -787,8 +788,9 @@ def i2c_1_write_no_register_uint8(self, address: int, data: int):
787788
cmd = f"i2c_1_write_no_register_uint8 0x{address:02x} 0x{data:02x}"
788789
self._ask(cmd)
789790

790-
def i2c_1_read_payload_uint16(self, address: int, register_address: int, num_bytes: int) -> Sequence:
791-
"""Read up to 256 bytes from the I2C_1 bus starting at a specified 16 bit register address."""
791+
def i2c_1_read_payload_uint16(self, address: int, register_address: int,
792+
num_bytes: int) -> Sequence:
793+
"""Read up to 256 bytes from the I2C_1 bus at a specified 16 bit register address."""
792794
cmd = f"i2c_1_read_payload_uint16 0x{address:02x} 0x{register_address:04x} {num_bytes}"
793795
returned = self._ask(cmd)
794796
register_data = [int(val, base=0) for val in returned.split()]

teensytoany/tests/test_teensytoany.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import teensytoany
2-
from teensytoany import TeensyToAny
31
import pytest
42

3+
import teensytoany
4+
from teensytoany import TeensyToAny
55

66

77
def test_project_import():
@@ -16,11 +16,12 @@ def test_nop():
1616

1717

1818
@pytest.mark.hardware
19-
@pytest.mark.parametrize("i", range(256, 2048 + 1, 256))
19+
@pytest.mark.parametrize("i", range(256, 2048, 256))
2020
def test_nop_buffer_size(i):
2121
# We shouldn't fail with up to 2048 bytes of input
2222
with TeensyToAny() as t:
23-
t._ask("nop" + " " * (2048 - i - len("nop\n")))
23+
# pylint: disable=protected-access
24+
t._ask("nop" + " " * (2048 - len("nop\n") - i))
2425

2526

2627
@pytest.mark.hardware
@@ -29,4 +30,5 @@ def test_nop_buffer_size_fail(i):
2930
with TeensyToAny() as t:
3031
# We should fail with more than 2048 bytes of input
3132
with pytest.raises(Exception):
33+
# pylint: disable=protected-access
3234
t._ask("nop" + " " * (i + 1 - len("nop\n")))

0 commit comments

Comments
 (0)