Skip to content

Commit

Permalink
T6199: drop unused Python imports
Browse files Browse the repository at this point in the history
found using "git ls-files *.py | xargs pylint | grep W0611"
  • Loading branch information
c-po committed Apr 2, 2024
1 parent 4c7c168 commit 274b2da
Show file tree
Hide file tree
Showing 123 changed files with 141 additions and 387 deletions.
7 changes: 1 addition & 6 deletions python/vyos/accel_ppp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Copyright (C) 2022 VyOS maintainers and contributors
# Copyright (C) 2022-2024 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
Expand All @@ -13,14 +13,9 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

import sys

import vyos.opmode
from vyos.utils.process import rc_cmd


def get_server_statistics(accel_statistics, pattern, sep=':') -> dict:
import re

Expand Down
4 changes: 1 addition & 3 deletions python/vyos/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017, 2019-2023 VyOS maintainers and contributors <maintainers@vyos.io>
# Copyright 2017-2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -60,12 +60,10 @@
while functions prefixed "effective" return values from the running config.
In operational mode, all functions return values from the running config.
"""

import re
import json
from copy import deepcopy
from typing import Union

import vyos.configtree
Expand Down
17 changes: 11 additions & 6 deletions python/vyos/config_mgmt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 VyOS maintainers and contributors <maintainers@vyos.io>
# Copyright 2023-2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand All @@ -19,18 +19,23 @@
import gzip
import logging

from typing import Optional, Tuple, Union
from typing import Optional
from typing import Tuple
from filecmp import cmp
from datetime import datetime
from textwrap import dedent, indent
from textwrap import dedent
from pathlib import Path
from tabulate import tabulate
from shutil import copy, chown
from urllib.parse import urlsplit, urlunsplit
from urllib.parse import urlsplit
from urllib.parse import urlunsplit

from vyos.config import Config
from vyos.configtree import ConfigTree, ConfigTreeError, show_diff
from vyos.load_config import load, LoadConfigError
from vyos.configtree import ConfigTree
from vyos.configtree import ConfigTreeError
from vyos.configtree import show_diff
from vyos.load_config import load
from vyos.load_config import LoadConfigError
from vyos.defaults import directories
from vyos.version import get_full_version_data
from vyos.utils.io import ask_yes_no
Expand Down
4 changes: 1 addition & 3 deletions python/vyos/configdict.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2022 VyOS maintainers and contributors <maintainers@vyos.io>
# Copyright 2019-2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -203,8 +203,6 @@ def is_member(conf, interface, intftype=None):
empty -> Interface is not a member
key -> Interface is a member of this interface
"""
from vyos.ifconfig import Section

ret_val = {}
intftypes = ['bonding', 'bridge']

Expand Down
6 changes: 3 additions & 3 deletions python/vyos/configdiff.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 VyOS maintainers and contributors <maintainers@vyos.io>
# Copyright 2020-2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand All @@ -13,12 +13,12 @@
# 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 enum import IntFlag, auto
from enum import IntFlag
from enum import auto

from vyos.config import Config
from vyos.configtree import DiffTree
from vyos.configdict import dict_merge
from vyos.configdict import list_diff
from vyos.utils.dict import get_sub_dict
from vyos.utils.dict import mangle_dict_keys
from vyos.utils.dict import dict_search_args
Expand Down
3 changes: 0 additions & 3 deletions python/vyos/configverify.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

from vyos import ConfigError
from vyos.utils.dict import dict_search
from vyos.utils.dict import dict_search_recursive

# pattern re-used in ipsec migration script
dynamic_interface_pattern = r'(ppp|pppoe|sstpc|l2tp|ipoe)[0-9]+'

Expand Down Expand Up @@ -246,7 +244,6 @@ def verify_interface_exists(ifname, warning_only=False):
if the interface is defined on the CLI, if it's not found we try if
it exists at the OS level.
"""
import os
from vyos.base import Warning
from vyos.configquery import ConfigTreeQuery
from vyos.utils.dict import dict_search_recursive
Expand Down
1 change: 0 additions & 1 deletion python/vyos/ethtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# 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/>.

import os
import re

from json import loads
Expand Down
3 changes: 1 addition & 2 deletions python/vyos/firewall.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Copyright (C) 2021-2023 VyOS maintainers and contributors
# Copyright (C) 2021-2024 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
Expand Down Expand Up @@ -30,7 +30,6 @@
from vyos.template import render
from vyos.utils.dict import dict_search_args
from vyos.utils.dict import dict_search_recursive
from vyos.utils.process import call
from vyos.utils.process import cmd
from vyos.utils.process import run

Expand Down
3 changes: 1 addition & 2 deletions python/vyos/frr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 VyOS maintainers and contributors <maintainers@vyos.io>
# Copyright 2020-2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -69,7 +69,6 @@
import re

from vyos import ConfigError
from vyos.utils.permission import chown
from vyos.utils.process import cmd
from vyos.utils.process import popen
from vyos.utils.process import STDOUT
Expand Down
3 changes: 1 addition & 2 deletions python/vyos/ifconfig/bond.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2022 VyOS maintainers and contributors <maintainers@vyos.io>
# Copyright 2019-2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand All @@ -16,7 +16,6 @@
import os

from vyos.ifconfig.interface import Interface
from vyos.utils.process import cmd
from vyos.utils.dict import dict_search
from vyos.utils.assertion import assert_list
from vyos.utils.assertion import assert_positive
Expand Down
1 change: 0 additions & 1 deletion python/vyos/ifconfig/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from vyos.template import render
from vyos.utils.network import mac2eui64
from vyos.utils.dict import dict_search
from vyos.utils.file import read_file
from vyos.utils.network import get_interface_config
from vyos.utils.network import get_interface_namespace
from vyos.utils.network import is_netns_interface
Expand Down
4 changes: 1 addition & 3 deletions python/vyos/ifconfig/vrrp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2023 VyOS maintainers and contributors <maintainers@vyos.io>
# Copyright 2019-2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand All @@ -18,7 +18,6 @@
import signal

from time import time
from time import sleep
from tabulate import tabulate

from vyos.configquery import ConfigTreeQuery
Expand Down Expand Up @@ -155,4 +154,3 @@ def format(cls, data):
# add to the active list disabled instances
groups.extend(cls.disabled())
return(tabulate(groups, headers))

5 changes: 1 addition & 4 deletions python/vyos/ifconfig/vxlan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2023 VyOS maintainers and contributors <maintainers@vyos.io>
# Copyright 2019-2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand All @@ -13,9 +13,6 @@
# 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 json import loads

from vyos import ConfigError
from vyos.configdict import list_diff
from vyos.ifconfig import Interface
from vyos.utils.assertion import assert_list
Expand Down
3 changes: 1 addition & 2 deletions python/vyos/ifconfig/wireguard.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2023 VyOS maintainers and contributors <maintainers@vyos.io>
# Copyright 2019-2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand All @@ -25,7 +25,6 @@
from vyos.ifconfig import Interface
from vyos.ifconfig import Operational
from vyos.template import is_ipv6
from vyos.base import Warning

class WireGuardOperational(Operational):
def _dump(self):
Expand Down
38 changes: 18 additions & 20 deletions python/vyos/iflag.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 VyOS maintainers and contributors <maintainers@vyos.io>
# Copyright 2019-2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand All @@ -13,26 +13,24 @@
# 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 enum import Enum, unique, IntEnum

from enum import IntEnum

class IFlag(IntEnum):
""" net/if.h interface flags """

IFF_UP = 0x1 #: Interface up/down status
IFF_BROADCAST = 0x2 #: Broadcast address valid
IFF_DEBUG = 0x4, #: Debugging
IFF_LOOPBACK = 0x8 #: Is loopback network
IFF_POINTOPOINT = 0x10 #: Is point-to-point link
IFF_NOTRAILERS = 0x20 #: Avoid use of trailers
IFF_RUNNING = 0x40 #: Resources allocated
IFF_NOARP = 0x80 #: No address resolution protocol
IFF_PROMISC = 0x100 #: Promiscuous mode
IFF_ALLMULTI = 0x200 #: Receive all multicast
IFF_MASTER = 0x400 #: Load balancer master
IFF_SLAVE = 0x800 #: Load balancer slave
IFF_MULTICAST = 0x1000 #: Supports multicast
IFF_PORTSEL = 0x2000 #: Media type adjustable
IFF_AUTOMEDIA = 0x4000 #: Automatic media type enabled
IFF_DYNAMIC = 0x8000 #: Is a dial-up device with dynamic address

IFF_UP = 0x1 #: Interface up/down status
IFF_BROADCAST = 0x2 #: Broadcast address valid
IFF_DEBUG = 0x4, #: Debugging
IFF_LOOPBACK = 0x8 #: Is loopback network
IFF_POINTOPOINT = 0x10 #: Is point-to-point link
IFF_NOTRAILERS = 0x20 #: Avoid use of trailers
IFF_RUNNING = 0x40 #: Resources allocated
IFF_NOARP = 0x80 #: No address resolution protocol
IFF_PROMISC = 0x100 #: Promiscuous mode
IFF_ALLMULTI = 0x200 #: Receive all multicast
IFF_MASTER = 0x400 #: Load balancer master
IFF_SLAVE = 0x800 #: Load balancer slave
IFF_MULTICAST = 0x1000 #: Supports multicast
IFF_PORTSEL = 0x2000 #: Media type adjustable
IFF_AUTOMEDIA = 0x4000 #: Automatic media type enabled
IFF_DYNAMIC = 0x8000 #: Is a dial-up device with dynamic address
4 changes: 1 addition & 3 deletions python/vyos/initialsetup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# initialsetup -- functions for setting common values in config file,
# for use in installation and first boot scripts
#
# Copyright (C) 2018-2023 VyOS maintainers and contributors
# Copyright (C) 2018-2024 VyOS maintainers and contributors
#
# This library is free software; you can redistribute it and/or modify it under the terms of
# the GNU Lesser General Public License as published by the Free Software Foundation;
Expand All @@ -14,8 +14,6 @@
# You should have received a copy of the GNU Lesser General Public License along with this library;
# if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

import vyos.configtree

from vyos.utils.auth import make_password_hash
from vyos.utils.auth import split_ssh_public_key

Expand Down
5 changes: 2 additions & 3 deletions python/vyos/ioctl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 VyOS maintainers and contributors <maintainers@vyos.io>
# Copyright 2019-2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand All @@ -13,7 +13,6 @@
# 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/>.

import sys
import os
import socket
import fcntl
Expand All @@ -29,7 +28,7 @@ def get_terminal_size():

def get_interface_flags(intf):
""" Pull the SIOCGIFFLAGS """
nullif = '\0'*256
nullif = '\0'*256
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
raw = fcntl.ioctl(sock.fileno(), SIOCGIFFLAGS, intf + nullif)
flags, = struct.unpack('H', raw[16:18])
Expand Down
3 changes: 1 addition & 2 deletions python/vyos/kea.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 VyOS maintainers and contributors <maintainers@vyos.io>
# Copyright 2023-2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand All @@ -22,7 +22,6 @@
from vyos.template import netmask_from_cidr
from vyos.utils.dict import dict_search_args
from vyos.utils.file import file_permissions
from vyos.utils.file import read_file
from vyos.utils.process import run

kea4_options = {
Expand Down
4 changes: 1 addition & 3 deletions python/vyos/progressbar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 VyOS maintainers and contributors <maintainers@vyos.io>
# Copyright 2023-2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand All @@ -17,12 +17,10 @@
import os
import signal
import subprocess
import sys

from vyos.utils.io import is_dumb_terminal
from vyos.utils.io import print_error


class Progressbar:
def __init__(self, step=None):
self.total = 0.0
Expand Down
3 changes: 1 addition & 2 deletions python/vyos/qos/priority.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 VyOS maintainers and contributors <maintainers@vyos.io>
# Copyright 2022-2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand All @@ -14,7 +14,6 @@
# License along with this library. If not, see <http://www.gnu.org/licenses/>.

from vyos.qos.base import QoSBase
from vyos.utils.dict import dict_search

class Priority(QoSBase):
_parent = 1
Expand Down
Loading

0 comments on commit 274b2da

Please sign in to comment.