Skip to content

Commit

Permalink
ignore datetime standard-lib module name shadowing
Browse files Browse the repository at this point in the history
  • Loading branch information
farmio committed Jan 21, 2025
1 parent cf446da commit 3240a5c
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion examples/ip_secure_calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def main() -> None:
)
session_authenticate = bytes.fromhex(
"06 10 09 53 00 18 00 01"
"1f 1d 59 ea 9f 12 a1 52 e5 d9 72 7f 08 46 2c de" # MAC
+ "1f 1d 59 ea 9f 12 a1 52 e5 d9 72 7f 08 46 2c de" # MAC
)
mac_cbc_authenticate = calculate_message_authentication_code_cbc(
password_hash,
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,6 @@ combine-as-imports = true
"RUF012",
"SLF", # private member access
] # Mutable class attributes should be annotated with `typing.ClassVar`

[tool.ruff.lint.flake8-builtins]
builtins-allowed-modules = ["datetime"]
11 changes: 7 additions & 4 deletions test/knxip_tests/connect_request_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,26 @@ def test_from_knx_wrong_length_of_cri(self):
def test_from_knx_wrong_length_of_cri2(self):
"""Test parsing and streaming wrong ConnectRequest."""
raw = bytes.fromhex(
"06 10 02 05 00 18 08 01 C0 A8 2A 01 84 95 08 01 C0 A8 2A 01 CC A9 03 03"
"06 10 02 05 00 18 08 01 C0 A8 2A 01 84 95 08 01"
+ "C0 A8 2A 01 CC A9 03 03"
)
with pytest.raises(CouldNotParseKNXIP):
KNXIPFrame.from_knx(raw)

def test_from_knx_wrong_length_of_cri3(self):
"""Test parsing and streaming wrong ConnectRequest."""
raw = bytes.fromhex(
"06 10 02 05 00 18 08 01 C0 A8 2A 01 84 95 08 01 C0 A8 2A 01 CC A9 01 03"
"06 10 02 05 00 18 08 01 C0 A8 2A 01 84 95 08 01"
+ "C0 A8 2A 01 CC A9 01 03"
)
with pytest.raises(CouldNotParseKNXIP):
KNXIPFrame.from_knx(raw)

def test_from_knx_wrong_length_of_cri4(self):
"""Test parsing and streaming wrong ConnectRequest."""
raw = bytes.fromhex(
"06 10 02 05 00 19 08 01 C0 A8 2A 01 84 95 08 01 C0 A8 2A 01 CC A9 03 03 01"
"06 10 02 05 00 19 08 01 C0 A8 2A 01 84 95 08 01"
+ "C0 A8 2A 01 CC A9 03 03 01"
)
with pytest.raises(CouldNotParseKNXIP):
KNXIPFrame.from_knx(raw)
Expand All @@ -151,7 +154,7 @@ def test_from_knx_wrong_cri(self):
"""Test parsing and streaming wrong ConnectRequest."""
raw = bytes.fromhex(
"06 10 02 05 00 1A 08 01 C0 A8 2A 01 84 95 08 01"
"C0 A8 2A 01 CC A9 04 04 02"
+ "C0 A8 2A 01 CC A9 04 04 02"
)
with pytest.raises(CouldNotParseKNXIP):
KNXIPFrame.from_knx(raw)
2 changes: 1 addition & 1 deletion test/knxip_tests/session_authenticate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_session_authenticate(self):
"e5 d9 72 7f 08 46 2c de"
)
raw = (
bytes.fromhex("06 10 09 53 00 18" "00 01") # KNXnet/IP header # User ID
bytes.fromhex("06 10 09 53 00 18 00 01") # KNXnet/IP header # User ID
+ message_authentication_code
)
knxipframe, _ = KNXIPFrame.from_knx(raw)
Expand Down
2 changes: 1 addition & 1 deletion test/knxip_tests/timer_notify_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TestKNXIPTimerNotify:
def test_timer_notify(self):
"""Test parsing and streaming TimerNotify KNX/IP packet."""
message_authentication_code = bytes.fromhex(
"72 12 a0 3a aa e4 9d a8" "56 89 77 4c 1d 2b 4d a4"
"72 12 a0 3a aa e4 9d a8 56 89 77 4c 1d 2b 4d a4"
)
raw = (
bytes.fromhex(
Expand Down
6 changes: 1 addition & 5 deletions xknx/cemi/cemi_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,7 @@ def from_knx(cls, raw: bytes) -> CEMIData:

def __repr__(self) -> str:
"""Return object as readable string."""
return (
f"CEMIMPropWriteRequest("
f"{self.property_info}"
f'data="{self.data.hex()}" )'
)
return f'CEMIMPropWriteRequest({self.property_info}data="{self.data.hex()}" )'


class CEMIMPropWriteResponse(CEMIData):
Expand Down
6 changes: 1 addition & 5 deletions xknx/knxip/connect_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,4 @@ def __repr__(self) -> str:
if self._is_tunnel_crd() and self.individual_address
else ""
)
return (
"<ConnectResponseData "
f'request_type="{self.request_type}" '
f"{_address}/>"
)
return f'<ConnectResponseData request_type="{self.request_type}" {_address}/>'
2 changes: 1 addition & 1 deletion xknx/knxip/description_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ def to_knx(self) -> bytes:
def __repr__(self) -> str:
"""Return object as readable string."""
_dibs_str = ",\n".join(dib.__repr__() for dib in self.dibs)
return "<DescriptionResponse " f'dibs="[\n{_dibs_str}\n]" />'
return f'<DescriptionResponse dibs="[\n{_dibs_str}\n]" />'

0 comments on commit 3240a5c

Please sign in to comment.