From 002050d158356078931d1a196538b5803eab788e Mon Sep 17 00:00:00 2001 From: Adam Smith Date: Tue, 29 Sep 2026 19:21:15 +0000 Subject: wwan: T7487: move json/wait_for imports into their only callers Requested by c-po: json.loads and wait_for were only used by _modem_owning_port() and modem_index()'s wait branch respectively, so importing them at module level cost every other caller of this module an import it does not need. --- python/vyos/utils/wwan.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/python/vyos/utils/wwan.py b/python/vyos/utils/wwan.py index 6b708e39c..af719571d 100644 --- a/python/vyos/utils/wwan.py +++ b/python/vyos/utils/wwan.py @@ -25,11 +25,9 @@ would have done. import os -from json import loads from time import sleep from vyos.utils.dict import dict_search -from vyos.utils.misc import wait_for from vyos.utils.process import call from vyos.utils.process import cmdl from vyos.utils.process import DEVNULL @@ -58,6 +56,8 @@ admin_disconnect_dir = '/run/vyos-wwan' def _modem_owning_port(ifname: str): """Return the ModemManager modem index whose own port list includes ifname, or None if no currently-known modem owns it.""" + from json import loads + try: modem_list = loads(cmdl(['mmcli', '--list-modems', '--output-json'])).get( 'modem-list', [] @@ -100,6 +100,8 @@ def modem_index(ifname: str, wait: bool = False): if not wait: return _modem_owning_port(ifname) + from vyos.utils.misc import wait_for + index = None def _resolve(): -- cgit v1.2.3