From 7f20a2ed716b396dde4b2a16f47d237c909c8d12 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Mon, 21 Jul 2025 20:57:52 +0200 Subject: 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. --- python/vyos/ifconfig/interface.py | 7 +++---- python/vyos/utils/network.py | 17 +++++++---------- 2 files changed, 10 insertions(+), 14 deletions(-) (limited to 'python') 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 . +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]') -- cgit v1.2.3