diff options
| author | Christian Breunig <christian@breunig.cc> | 2025-07-21 20:57:52 +0200 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2025-07-21 20:57:52 +0200 |
| commit | 7f20a2ed716b396dde4b2a16f47d237c909c8d12 (patch) | |
| tree | 4126da5ea0f1eebd6b74a1465e637e3fc5a7f0e0 | |
| parent | bb6c2368912ad06b42bdabbeb1f6326f127dd686 (diff) | |
| download | vyos-1x-7f20a2ed716b396dde4b2a16f47d237c909c8d12.tar.gz vyos-1x-7f20a2ed716b396dde4b2a16f47d237c909c8d12.zip | |
T7648: when using netifaces set "pylint: disable = no-name-in-module"
As the python netifaces module is written in C - we can not inspect any import
line as the linter does not see it. Disable the warnings here.
| -rw-r--r-- | python/vyos/ifconfig/interface.py | 7 | ||||
| -rw-r--r-- | python/vyos/utils/network.py | 17 | ||||
| -rwxr-xr-x | src/conf_mode/qos.py | 3 | ||||
| -rwxr-xr-x | src/conf_mode/service_broadcast-relay.py | 2 | ||||
| -rwxr-xr-x | src/conf_mode/service_mdns_repeater.py | 4 | ||||
| -rw-r--r-- | src/conf_mode/service_stunnel.py | 2 |
6 files changed, 17 insertions, 18 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index 787364483..3b3536301 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -23,10 +23,9 @@ from glob import glob from ipaddress import IPv4Network from ipaddress import IPv6Interface -from netifaces import ifaddresses -# this is not the same as socket.AF_INET/INET6 -from netifaces import AF_INET -from netifaces import AF_INET6 +from netifaces import ifaddresses # pylint: disable = no-name-in-module +from socket import AF_INET +from socket import AF_INET6 from netaddr import EUI from netaddr import mac_unix_expanded diff --git a/python/vyos/utils/network.py b/python/vyos/utils/network.py index 2182642dd..0e2cc58cf 100644 --- a/python/vyos/utils/network.py +++ b/python/vyos/utils/network.py @@ -13,9 +13,10 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library. If not, see <http://www.gnu.org/licenses/>. +from socket import AF_INET +from socket import AF_INET6 + def _are_same_ip(one, two): - from socket import AF_INET - from socket import AF_INET6 from socket import inet_pton from vyos.template import is_ipv4 # compare the binary representation of the IP @@ -347,7 +348,7 @@ def is_ipv6_link_local(addr): def is_addr_assigned(ip_address, vrf=None, return_ifname=False, include_vrf=False) -> bool | str: """ Verify if the given IPv4/IPv6 address is assigned to any interface """ - from netifaces import interfaces + from netifaces import interfaces # pylint: disable = no-name-in-module from vyos.utils.network import get_interface_config from vyos.utils.dict import dict_search @@ -445,10 +446,8 @@ def is_subnet_connected(subnet, primary=False): from ipaddress import ip_address from ipaddress import ip_network - from netifaces import ifaddresses - from netifaces import interfaces - from netifaces import AF_INET - from netifaces import AF_INET6 + from netifaces import ifaddresses # pylint: disable = no-name-in-module + from netifaces import interfaces # pylint: disable = no-name-in-module from vyos.template import is_ipv6 @@ -482,9 +481,7 @@ def is_subnet_connected(subnet, primary=False): def is_afi_configured(interface: str, afi): """ Check if given address family is configured, or in other words - an IP address is assigned to the interface. """ - from netifaces import ifaddresses - from netifaces import AF_INET - from netifaces import AF_INET6 + from netifaces import ifaddresses # pylint: disable = no-name-in-module if afi not in [AF_INET, AF_INET6]: raise ValueError('Address family must be in [AF_INET, AF_INET6]') diff --git a/src/conf_mode/qos.py b/src/conf_mode/qos.py index 326d617a2..4ea900bb8 100755 --- a/src/conf_mode/qos.py +++ b/src/conf_mode/qos.py @@ -15,7 +15,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. from sys import exit -from netifaces import interfaces + +from netifaces import interfaces # pylint: disable = no-name-in-module from vyos.base import Warning from vyos.config import Config diff --git a/src/conf_mode/service_broadcast-relay.py b/src/conf_mode/service_broadcast-relay.py index f7f2875f5..b3f38dd21 100755 --- a/src/conf_mode/service_broadcast-relay.py +++ b/src/conf_mode/service_broadcast-relay.py @@ -17,7 +17,7 @@ import os from glob import glob -from netifaces import AF_INET +from socket import AF_INET from sys import exit from vyos.config import Config diff --git a/src/conf_mode/service_mdns_repeater.py b/src/conf_mode/service_mdns_repeater.py index 360b94588..aa10a687e 100755 --- a/src/conf_mode/service_mdns_repeater.py +++ b/src/conf_mode/service_mdns_repeater.py @@ -18,7 +18,9 @@ import os from json import loads from sys import exit -from netifaces import ifaddresses, AF_INET, AF_INET6 +from socket import AF_INET +from socket import AF_INET6 +from netifaces import ifaddresses # pylint: disable = no-name-in-module from vyos.config import Config from vyos.configverify import verify_interface_exists diff --git a/src/conf_mode/service_stunnel.py b/src/conf_mode/service_stunnel.py index eb1d4dea2..5ea5b88b4 100644 --- a/src/conf_mode/service_stunnel.py +++ b/src/conf_mode/service_stunnel.py @@ -19,7 +19,7 @@ from shutil import rmtree from sys import exit -from netifaces import AF_INET +from socket import AF_INET from psutil import net_if_addrs from vyos.config import Config |
