summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2025-07-21 20:57:52 +0200
committerChristian Breunig <christian@breunig.cc>2025-07-21 20:57:52 +0200
commit7f20a2ed716b396dde4b2a16f47d237c909c8d12 (patch)
tree4126da5ea0f1eebd6b74a1465e637e3fc5a7f0e0
parentbb6c2368912ad06b42bdabbeb1f6326f127dd686 (diff)
downloadvyos-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.py7
-rw-r--r--python/vyos/utils/network.py17
-rwxr-xr-xsrc/conf_mode/qos.py3
-rwxr-xr-xsrc/conf_mode/service_broadcast-relay.py2
-rwxr-xr-xsrc/conf_mode/service_mdns_repeater.py4
-rw-r--r--src/conf_mode/service_stunnel.py2
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