Skip to content

Commit c993fb3

Browse files
authored
Suppress aiohttp missing. (#2743)
1 parent 2740022 commit c993fb3

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

pymodbus/server/simulator/http_server.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,11 @@
77
import importlib
88
import json
99
import os
10-
from typing import TYPE_CHECKING
1110

1211

13-
try:
12+
with contextlib.suppress(ImportError):
1413
from aiohttp import web
1514

16-
AIOHTTP_MISSING = False
17-
except ImportError:
18-
AIOHTTP_MISSING = True
19-
if TYPE_CHECKING: # always False at runtime
20-
# type checkers do not understand the Raise RuntimeError in __init__()
21-
from aiohttp import web
22-
2315
from pymodbus.datastore import ModbusServerContext, ModbusSimulatorContext
2416
from pymodbus.datastore.simulator import Label
2517
from pymodbus.logging import Log
@@ -124,11 +116,6 @@ def __init__(
124116
custom_actions_module: str | None = None,
125117
):
126118
"""Initialize http interface."""
127-
if AIOHTTP_MISSING:
128-
raise RuntimeError(
129-
"Simulator server requires aiohttp. "
130-
'Please install with "pip install aiohttp" and try again.'
131-
)
132119
with open(json_file, encoding="utf-8") as file:
133120
setup = json.load(file)
134121

0 commit comments

Comments
 (0)