Skip to content

Commit d8b791d

Browse files
committed
pylint 3.11
1 parent bace7f3 commit d8b791d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pymodbus/transport/transport.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import asyncio
55
import dataclasses
66
import ssl
7+
import sys
78
from contextlib import suppress
89
from enum import Enum
910
from typing import Any, Callable, Coroutine
@@ -14,6 +15,14 @@
1415

1516
NULLMODEM_HOST = "__pymodbus_nullmodem"
1617

18+
if sys.version_info.minor == 11:
19+
USEEXCEPTIONS: tuple[type[Any], type[Any]] | type[Any] = OSError
20+
else:
21+
USEEXCEPTIONS = (
22+
asyncio.TimeoutError,
23+
OSError,
24+
)
25+
1726

1827
class CommType(Enum):
1928
"""Type of transport"""
@@ -229,10 +238,7 @@ async def transport_connect(self) -> bool:
229238
self.call_create(),
230239
timeout=self.comm_params.timeout_connect,
231240
)
232-
except (
233-
asyncio.TimeoutError,
234-
OSError,
235-
) as exc:
241+
except USEEXCEPTIONS as exc:
236242
Log.warning("Failed to connect {}", exc)
237243
self.transport_close(intern=True, reconnect=True)
238244
return False

0 commit comments

Comments
 (0)