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 /python | |
| 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.
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/ifconfig/interface.py | 7 | ||||
| -rw-r--r-- | python/vyos/utils/network.py | 17 |
2 files changed, 10 insertions, 14 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]') |
