From 996b86c7559e59f55e58307ed9f8c219bbf6adb9 Mon Sep 17 00:00:00 2001 From: Peter Saveliev Date: Fri, 2 Feb 2024 11:17:41 +0100 Subject: [PATCH 1/5] ci: update flake8 to version 7.0.0 --- .pre-commit-config.yaml | 2 +- pyroute2/common.py | 4 +++- pyroute2/ipdb/routes.py | 4 ++-- pyroute2/netlink/diag/ss2.py | 2 +- pyroute2/netlink/rtnl/tcmsg/common.py | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c1d088132..b1fd7dba3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: black args: ['-C', '-S', '-l', '79'] - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 + rev: 7.0.0 hooks: - id: flake8 files: \.py$ diff --git a/pyroute2/common.py b/pyroute2/common.py index bf22db064..caaf0f54b 100644 --- a/pyroute2/common.py +++ b/pyroute2/common.py @@ -199,7 +199,9 @@ class Dotkeys(dict): __var_name = re.compile('^[a-zA-Z_]+[a-zA-Z_0-9]*$') def __dir__(self): - return [i for i in self if type(i) == str and self.__var_name.match(i)] + return [ + i for i in self if isinstance(i, str) and self.__var_name.match(i) + ] def __getattribute__(self, key, *argv): try: diff --git a/pyroute2/ipdb/routes.py b/pyroute2/ipdb/routes.py index 2f1c1983f..15e38648b 100644 --- a/pyroute2/ipdb/routes.py +++ b/pyroute2/ipdb/routes.py @@ -727,7 +727,7 @@ def __setitem__(self, key, value): ret = Transactional.__getitem__(self, key) # it doesn't # (plain dict can be safely discarded) - if (type(ret) == dict) or not ret: + if isinstance(ret, dict) or not ret: # bake transactionals in place if key == 'encap': ret = Encap(parent=self) @@ -822,7 +822,7 @@ def make_key(cls, msg): def __setitem__(self, key, value): if key == 'via' and isinstance(value, dict): # replace with a new transactional - if type(value) == Via: + if isinstance(value, Via): with self._direct_state: return BaseRoute.__setitem__(self, key, value) # or load the dict diff --git a/pyroute2/netlink/diag/ss2.py b/pyroute2/netlink/diag/ss2.py index c0d15d2d9..93b9284f0 100755 --- a/pyroute2/netlink/diag/ss2.py +++ b/pyroute2/netlink/diag/ss2.py @@ -528,7 +528,7 @@ def _refine_tcp_info(self, vessel, tcp_info_raw): vessel[info_k] = {} # BUG - pyroute2 diag - seems always last info instance from kernel - if type(tcp_info_raw) != str: + if not isinstance(tcp_info_raw, str): for k, v in tcp_info_raw.items(): if k not in info_refine_tabl: continue diff --git a/pyroute2/netlink/rtnl/tcmsg/common.py b/pyroute2/netlink/rtnl/tcmsg/common.py index 332642312..6456d46b2 100644 --- a/pyroute2/netlink/rtnl/tcmsg/common.py +++ b/pyroute2/netlink/rtnl/tcmsg/common.py @@ -263,7 +263,7 @@ def get_tca_ops(kwarg, attrs): attrs.append(['TCA_FLOW_RSHIFT', rshift_value]) elif op == 'addend': # Check if an IP was specified - if type(num) == str and len(num.split('.')) == 4: + if isinstance(num, str) and len(num.split('.')) == 4: if num.startswith('-'): inverse = True else: From 739437e83b96f6611839f3ce69da8e5edaa2de71 Mon Sep 17 00:00:00 2001 From: Peter Saveliev Date: Fri, 2 Feb 2024 11:18:47 +0100 Subject: [PATCH 2/5] ci: add setuptools to the repo test deps --- requirements.repo.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.repo.txt b/requirements.repo.txt index ffc3bef1b..8fa399720 100644 --- a/requirements.repo.txt +++ b/requirements.repo.txt @@ -1,3 +1,4 @@ nox pytest pytest-cov +setuptools From 372c0b09a189147c0d4ba7e48bf1d3e4be2d5e47 Mon Sep 17 00:00:00 2001 From: Peter Saveliev Date: Fri, 2 Feb 2024 11:39:44 +0100 Subject: [PATCH 3/5] ci: update pre-commit-hooks to 4.5.0 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b1fd7dba3..6b550b8df 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ files: '^(noxfile.py|pyroute2|pr2modules|util|examlpes/ndb|docs/conf.py|examples/pyroute2-cli|tests)' repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer From ca8bf0fd68c9b7fa749819faef5ca625322db716 Mon Sep 17 00:00:00 2001 From: Peter Saveliev Date: Fri, 2 Feb 2024 11:44:36 +0100 Subject: [PATCH 4/5] ci: update isort to 5.13.2 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6b550b8df..0a56118fc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort name: isort (python) From 7340c4939a85959972e7c1de6620a8d2da304339 Mon Sep 17 00:00:00 2001 From: Peter Saveliev Date: Fri, 2 Feb 2024 14:29:43 +0100 Subject: [PATCH 5/5] ci: update black to 24.1.1 --- .pre-commit-config.yaml | 2 +- pr2modules/__init__.py | 1 + pyroute2/bsd/util.py | 1 + pyroute2/dhcp/dhcp4socket.py | 1 + pyroute2/ethtool/ethtool.py | 8 +++----- pyroute2/ipdb/linkedset.py | 1 + pyroute2/ipdb/routes.py | 14 ++++++++------ pyroute2/ipdb/transactional.py | 1 + pyroute2/iproute/bsd.py | 1 + pyroute2/iproute/windows.py | 1 + pyroute2/ipset.py | 1 + pyroute2/ndb/main.py | 1 + pyroute2/ndb/objects/__init__.py | 1 + pyroute2/ndb/objects/address.py | 1 + pyroute2/ndb/objects/route.py | 1 + pyroute2/ndb/report.py | 1 + pyroute2/ndb/schema.py | 1 + pyroute2/ndb/source.py | 1 + pyroute2/ndb/transaction.py | 1 + pyroute2/netlink/devlink/__init__.py | 1 + pyroute2/netlink/event/acpi_event.py | 1 + pyroute2/netlink/event/dquot.py | 1 + pyroute2/netlink/event/thermal.py | 1 + pyroute2/netlink/generic/wireguard.py | 1 - pyroute2/netlink/ipq/__init__.py | 1 + pyroute2/netlink/nl80211/__init__.py | 13 +++++++------ pyroute2/netlink/proxy.py | 1 + pyroute2/netlink/rtnl/__init__.py | 1 + pyroute2/netlink/rtnl/tcmsg/act_skbedit.py | 1 - pyroute2/netlink/rtnl/tcmsg/cls_u32.py | 1 + pyroute2/netlink/rtnl/tcmsg/sched_cake.py | 1 - pyroute2/netlink/rtnl/tcmsg/sched_choke.py | 1 + pyroute2/netlink/rtnl/tcmsg/sched_clsact.py | 1 + pyroute2/netlink/rtnl/tcmsg/sched_drr.py | 1 + pyroute2/netlink/rtnl/tcmsg/sched_hfsc.py | 1 + pyroute2/netlink/rtnl/tcmsg/sched_htb.py | 1 + pyroute2/netlink/rtnl/tcmsg/sched_template.py | 1 + pyroute2/netns/__init__.py | 1 + pyroute2/nftables/main.py | 1 + pyroute2/remote/transport.py | 6 +++--- pyroute2/requests/main.py | 1 + 41 files changed, 55 insertions(+), 24 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0a56118fc..014400a68 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: name: isort (python) args: ['-m', '3', '--tc', '-w', '79', '--profile', 'black'] - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 24.1.1 hooks: - id: black args: ['-C', '-S', '-l', '79'] diff --git a/pr2modules/__init__.py b/pr2modules/__init__.py index 298de8e8d..3e5c6bd02 100644 --- a/pr2modules/__init__.py +++ b/pr2modules/__init__.py @@ -3,6 +3,7 @@ It will be removed in 0.8.x ''' + import sys import warnings diff --git a/pyroute2/bsd/util.py b/pyroute2/bsd/util.py index 2418ced82..907250b5f 100644 --- a/pyroute2/bsd/util.py +++ b/pyroute2/bsd/util.py @@ -6,6 +6,7 @@ Maybe some day it will be ioctl. For now it's ifconfig and netstat. ''' + import re import socket import subprocess diff --git a/pyroute2/dhcp/dhcp4socket.py b/pyroute2/dhcp/dhcp4socket.py index b9fc4e48b..9b2286b08 100644 --- a/pyroute2/dhcp/dhcp4socket.py +++ b/pyroute2/dhcp/dhcp4socket.py @@ -3,6 +3,7 @@ ================ ''' + from pyroute2.common import AddrPool from pyroute2.dhcp.dhcp4msg import dhcp4msg from pyroute2.ext.rawsocket import RawSocket diff --git a/pyroute2/ethtool/ethtool.py b/pyroute2/ethtool/ethtool.py index e91c5d077..22955af57 100644 --- a/pyroute2/ethtool/ethtool.py +++ b/pyroute2/ethtool/ethtool.py @@ -196,11 +196,9 @@ def __new__(cls, speed, duplex, autoneg, supported_ports, supported_modes): @classmethod def from_ioctl(cls, link_settings): - ( - map_supported, - map_advertising, - map_lp_advertising, - ) = IoctlEthtool.get_link_mode_masks(link_settings) + (map_supported, map_advertising, map_lp_advertising) = ( + IoctlEthtool.get_link_mode_masks(link_settings) + ) bits_supported = IoctlEthtool.get_link_mode_bits(map_supported) supported_ports = [] supported_modes = [] diff --git a/pyroute2/ipdb/linkedset.py b/pyroute2/ipdb/linkedset.py index 844e4b1d8..b90bca8e7 100644 --- a/pyroute2/ipdb/linkedset.py +++ b/pyroute2/ipdb/linkedset.py @@ -1,5 +1,6 @@ ''' ''' + import struct import threading from collections import OrderedDict diff --git a/pyroute2/ipdb/routes.py b/pyroute2/ipdb/routes.py index 15e38648b..7eb5fcdfd 100644 --- a/pyroute2/ipdb/routes.py +++ b/pyroute2/ipdb/routes.py @@ -598,9 +598,9 @@ def make_encap(cls, encap): if isinstance(labels, (list, tuple, set)): labels = '/'.join( map( - lambda x: str(x['label']) - if isinstance(x, dict) - else str(x), + lambda x: ( + str(x['label']) if isinstance(x, dict) else str(x) + ), labels, ) ) @@ -659,9 +659,11 @@ def make_nh_key(cls, msg): if field == 'encap' and isinstance(v, (list, tuple, set)): v = '/'.join( map( - lambda x: str(x['label']) - if isinstance(x, dict) - else str(x), + lambda x: ( + str(x['label']) + if isinstance(x, dict) + else str(x) + ), v, ) ) diff --git a/pyroute2/ipdb/transactional.py b/pyroute2/ipdb/transactional.py index 61cc829d7..e65757be4 100644 --- a/pyroute2/ipdb/transactional.py +++ b/pyroute2/ipdb/transactional.py @@ -1,5 +1,6 @@ ''' ''' + import logging import threading diff --git a/pyroute2/iproute/bsd.py b/pyroute2/iproute/bsd.py index 31358e68a..52112f927 100644 --- a/pyroute2/iproute/bsd.py +++ b/pyroute2/iproute/bsd.py @@ -43,6 +43,7 @@ `IPRoute.recv(...)` method returns valid netlink RTNL raw binary payload and `IPRoute.get(...)` returns parsed RTNL messages. ''' + import errno import os import select diff --git a/pyroute2/iproute/windows.py b/pyroute2/iproute/windows.py index 596c20b0f..65cc327e7 100644 --- a/pyroute2/iproute/windows.py +++ b/pyroute2/iproute/windows.py @@ -10,6 +10,7 @@ Using pyroute2 on Windows requires installing `win_inet_pton` module, you can use `pip install win_inet_pton`. ''' + import ctypes import os from socket import AF_INET diff --git a/pyroute2/ipset.py b/pyroute2/ipset.py index 2ee3f9b2b..750c50e65 100644 --- a/pyroute2/ipset.py +++ b/pyroute2/ipset.py @@ -8,6 +8,7 @@ It supports almost all kernel commands (create, destroy, flush, rename, swap, test...) ''' + import errno import socket diff --git a/pyroute2/ndb/main.py b/pyroute2/ndb/main.py index c5446d912..2ab039509 100644 --- a/pyroute2/ndb/main.py +++ b/pyroute2/ndb/main.py @@ -278,6 +278,7 @@ def add_mock_netns(self, netns): # context manager's __exit__() ''' + import atexit import ctypes import ctypes.util diff --git a/pyroute2/ndb/objects/__init__.py b/pyroute2/ndb/objects/__init__.py index 59f44aee3..8afa026dc 100644 --- a/pyroute2/ndb/objects/__init__.py +++ b/pyroute2/ndb/objects/__init__.py @@ -61,6 +61,7 @@ API === ''' + import collections import errno import json diff --git a/pyroute2/ndb/objects/address.py b/pyroute2/ndb/objects/address.py index 719e5d31f..81a16462e 100644 --- a/pyroute2/ndb/objects/address.py +++ b/pyroute2/ndb/objects/address.py @@ -155,6 +155,7 @@ Please notice that address objects are read-only, you may not change them, only remove old ones, and create new. ''' + from pyroute2.netlink.rtnl.ifaddrmsg import ifaddrmsg from pyroute2.requests.address import AddressFieldFilter diff --git a/pyroute2/ndb/objects/route.py b/pyroute2/ndb/objects/route.py index 5143529ee..a2ae3e3a5 100644 --- a/pyroute2/ndb/objects/route.py +++ b/pyroute2/ndb/objects/route.py @@ -107,6 +107,7 @@ See here: :ref:`mpls` ''' + import json import struct import time diff --git a/pyroute2/ndb/report.py b/pyroute2/ndb/report.py index fd17bc2e6..4e9d70792 100644 --- a/pyroute2/ndb/report.py +++ b/pyroute2/ndb/report.py @@ -31,6 +31,7 @@ 2,'eth0','5254.0072.58b2','up' ''' + import json import warnings from itertools import chain diff --git a/pyroute2/ndb/schema.py b/pyroute2/ndb/schema.py index 024f71cc6..418b9391a 100644 --- a/pyroute2/ndb/schema.py +++ b/pyroute2/ndb/schema.py @@ -116,6 +116,7 @@ all the tables from the DB, and NDB will create them from scratch on startup. ''' + import enum import json import random diff --git a/pyroute2/ndb/source.py b/pyroute2/ndb/source.py index a8c4a2c15..f6143db4b 100644 --- a/pyroute2/ndb/source.py +++ b/pyroute2/ndb/source.py @@ -79,6 +79,7 @@ See also: :ref:`remote` ''' + import errno import importlib import queue diff --git a/pyroute2/ndb/transaction.py b/pyroute2/ndb/transaction.py index 1cc72e390..5ab1a422b 100644 --- a/pyroute2/ndb/transaction.py +++ b/pyroute2/ndb/transaction.py @@ -183,6 +183,7 @@ --- ''' + import logging import shlex import shutil diff --git a/pyroute2/netlink/devlink/__init__.py b/pyroute2/netlink/devlink/__init__.py index 8070d8224..dc0a18864 100644 --- a/pyroute2/netlink/devlink/__init__.py +++ b/pyroute2/netlink/devlink/__init__.py @@ -2,6 +2,7 @@ devlink module ============== ''' + from pyroute2.common import map_namespace from pyroute2.netlink import genlmsg, nla from pyroute2.netlink.generic import GenericNetlinkSocket diff --git a/pyroute2/netlink/event/acpi_event.py b/pyroute2/netlink/event/acpi_event.py index d67d57b1d..93b6ca39b 100644 --- a/pyroute2/netlink/event/acpi_event.py +++ b/pyroute2/netlink/event/acpi_event.py @@ -24,6 +24,7 @@ 'type': 32768} ''' + from pyroute2.common import load_dump from pyroute2.netlink import genlmsg, nla from pyroute2.netlink.event import EventSocket diff --git a/pyroute2/netlink/event/dquot.py b/pyroute2/netlink/event/dquot.py index 32b9d1827..9b243e021 100644 --- a/pyroute2/netlink/event/dquot.py +++ b/pyroute2/netlink/event/dquot.py @@ -23,6 +23,7 @@ quota warning 8 for uid 0 on 7:0 ''' + from pyroute2.common import load_dump from pyroute2.netlink import genlmsg from pyroute2.netlink.event import EventSocket diff --git a/pyroute2/netlink/event/thermal.py b/pyroute2/netlink/event/thermal.py index b646b90d3..4d2007cd4 100644 --- a/pyroute2/netlink/event/thermal.py +++ b/pyroute2/netlink/event/thermal.py @@ -1,5 +1,6 @@ ''' ''' + from enum import Enum from pyroute2.netlink import genlmsg diff --git a/pyroute2/netlink/generic/wireguard.py b/pyroute2/netlink/generic/wireguard.py index 8a3bb6b58..3cb1477ed 100644 --- a/pyroute2/netlink/generic/wireguard.py +++ b/pyroute2/netlink/generic/wireguard.py @@ -63,7 +63,6 @@ } ''' - import errno import logging import struct diff --git a/pyroute2/netlink/ipq/__init__.py b/pyroute2/netlink/ipq/__init__.py index 4fe3d4747..06ee374c2 100644 --- a/pyroute2/netlink/ipq/__init__.py +++ b/pyroute2/netlink/ipq/__init__.py @@ -11,6 +11,7 @@ `NF_ACCEPT`, and the packet will be pass the rule. ''' + from pyroute2.netlink import NLM_F_REQUEST, nlmsg from pyroute2.netlink.nlsocket import Marshal, NetlinkSocket diff --git a/pyroute2/netlink/nl80211/__init__.py b/pyroute2/netlink/nl80211/__init__.py index ef57eab35..d835a805c 100644 --- a/pyroute2/netlink/nl80211/__init__.py +++ b/pyroute2/netlink/nl80211/__init__.py @@ -4,6 +4,7 @@ TODO ''' + import datetime import struct @@ -943,9 +944,9 @@ def binary_rsn(self, offset, length, defcipher, defauth): data = data[16:] if len(data) >= 4: - rsn_values[ - "group_mgmt_cipher_suite" - ] = self._get_cipher_list(data) + rsn_values["group_mgmt_cipher_suite"] = ( + self._get_cipher_list(data) + ) data = data[4:] return rsn_values @@ -1064,9 +1065,9 @@ def decode(self): ) if msg_type == NL80211_BSS_ELEMENTS_VHT_OPERATION: - self.value[ - "VHT_OPERATION" - ] = self.binary_vht_operation(offset + 2, length) + self.value["VHT_OPERATION"] = ( + self.binary_vht_operation(offset + 2, length) + ) offset += length + 2 diff --git a/pyroute2/netlink/proxy.py b/pyroute2/netlink/proxy.py index 94cdbb5a3..31fc0a992 100644 --- a/pyroute2/netlink/proxy.py +++ b/pyroute2/netlink/proxy.py @@ -1,6 +1,7 @@ ''' Netlink proxy engine ''' + import errno import logging import struct diff --git a/pyroute2/netlink/rtnl/__init__.py b/pyroute2/netlink/rtnl/__init__.py index 601360a20..0859046d8 100644 --- a/pyroute2/netlink/rtnl/__init__.py +++ b/pyroute2/netlink/rtnl/__init__.py @@ -34,6 +34,7 @@ Module contents: ''' + from pyroute2.common import map_namespace # RTnetlink multicast group flags (for use with bind()) diff --git a/pyroute2/netlink/rtnl/tcmsg/act_skbedit.py b/pyroute2/netlink/rtnl/tcmsg/act_skbedit.py index 24c5ef1be..6cd89170e 100644 --- a/pyroute2/netlink/rtnl/tcmsg/act_skbedit.py +++ b/pyroute2/netlink/rtnl/tcmsg/act_skbedit.py @@ -42,7 +42,6 @@ - queue: integer ''' - from pyroute2.netlink import nla from pyroute2.netlink.rtnl.tcmsg.common import tc_actions diff --git a/pyroute2/netlink/rtnl/tcmsg/cls_u32.py b/pyroute2/netlink/rtnl/tcmsg/cls_u32.py index c68914b5b..6e354e469 100644 --- a/pyroute2/netlink/rtnl/tcmsg/cls_u32.py +++ b/pyroute2/netlink/rtnl/tcmsg/cls_u32.py @@ -54,6 +54,7 @@ # 0xffffff00 = 255.255.255.0 (/24) # 16 = Destination network field bit offset ''' + import struct from socket import htons diff --git a/pyroute2/netlink/rtnl/tcmsg/sched_cake.py b/pyroute2/netlink/rtnl/tcmsg/sched_cake.py index 9b6400225..6f5eff668 100644 --- a/pyroute2/netlink/rtnl/tcmsg/sched_cake.py +++ b/pyroute2/netlink/rtnl/tcmsg/sched_cake.py @@ -72,7 +72,6 @@ - wash: False or True (False by default) ''' - from pyroute2.netlink import nla from pyroute2.netlink.rtnl import TC_H_ROOT diff --git a/pyroute2/netlink/rtnl/tcmsg/sched_choke.py b/pyroute2/netlink/rtnl/tcmsg/sched_choke.py index 4073d9456..0fc1eeeb9 100644 --- a/pyroute2/netlink/rtnl/tcmsg/sched_choke.py +++ b/pyroute2/netlink/rtnl/tcmsg/sched_choke.py @@ -21,6 +21,7 @@ ecn=True) ''' + import logging import struct diff --git a/pyroute2/netlink/rtnl/tcmsg/sched_clsact.py b/pyroute2/netlink/rtnl/tcmsg/sched_clsact.py index c6b28394a..15c95fc40 100644 --- a/pyroute2/netlink/rtnl/tcmsg/sched_clsact.py +++ b/pyroute2/netlink/rtnl/tcmsg/sched_clsact.py @@ -23,6 +23,7 @@ parent="ffff:fff3", classid=1, direct_action=True) ''' + from pyroute2.netlink.rtnl import TC_H_CLSACT parent = TC_H_CLSACT diff --git a/pyroute2/netlink/rtnl/tcmsg/sched_drr.py b/pyroute2/netlink/rtnl/tcmsg/sched_drr.py index 85f34f05d..9ac9dc697 100644 --- a/pyroute2/netlink/rtnl/tcmsg/sched_drr.py +++ b/pyroute2/netlink/rtnl/tcmsg/sched_drr.py @@ -10,6 +10,7 @@ ip.tc('add-class', 'drr', interface, '1:20', quantum=1600) ''' + from pyroute2.netlink import nla from pyroute2.netlink.rtnl import TC_H_ROOT from pyroute2.netlink.rtnl.tcmsg.common import stats2 as c_stats2 diff --git a/pyroute2/netlink/rtnl/tcmsg/sched_hfsc.py b/pyroute2/netlink/rtnl/tcmsg/sched_hfsc.py index 764b4025c..2bcbd36e6 100644 --- a/pyroute2/netlink/rtnl/tcmsg/sched_hfsc.py +++ b/pyroute2/netlink/rtnl/tcmsg/sched_hfsc.py @@ -19,6 +19,7 @@ * `fsc`: link-share curve * `usc`: upper-limit curve ''' + from pyroute2.netlink import nla from pyroute2.netlink.rtnl import RTM_DELQDISC, RTM_NEWQDISC, TC_H_ROOT from pyroute2.netlink.rtnl.tcmsg.common import get_rate, get_time diff --git a/pyroute2/netlink/rtnl/tcmsg/sched_htb.py b/pyroute2/netlink/rtnl/tcmsg/sched_htb.py index 6a6921ec5..373831f7d 100644 --- a/pyroute2/netlink/rtnl/tcmsg/sched_htb.py +++ b/pyroute2/netlink/rtnl/tcmsg/sched_htb.py @@ -59,6 +59,7 @@ target=0x10020, keys=["0x5/0xf+0", "0x10/0xff+33"]) ''' + from pyroute2.netlink import nla from pyroute2.netlink.rtnl import RTM_DELQDISC, RTM_NEWQDISC, TC_H_ROOT from pyroute2.netlink.rtnl.tcmsg.common import ( diff --git a/pyroute2/netlink/rtnl/tcmsg/sched_template.py b/pyroute2/netlink/rtnl/tcmsg/sched_template.py index 5c1c6f7ec..7610028b2 100644 --- a/pyroute2/netlink/rtnl/tcmsg/sched_template.py +++ b/pyroute2/netlink/rtnl/tcmsg/sched_template.py @@ -5,6 +5,7 @@ All the methods, variables and classes are optional, but the naming scheme is fixed. ''' + from pyroute2.netlink import nla from pyroute2.netlink.rtnl import TC_H_ROOT from pyroute2.netlink.rtnl.tcmsg import common diff --git a/pyroute2/netns/__init__.py b/pyroute2/netns/__init__.py index e211de3e1..29327a576 100644 --- a/pyroute2/netns/__init__.py +++ b/pyroute2/netns/__init__.py @@ -79,6 +79,7 @@ SELinux state with `getenforce` command. ''' + import ctypes import ctypes.util import errno diff --git a/pyroute2/nftables/main.py b/pyroute2/nftables/main.py index ef17a62c8..405b90969 100644 --- a/pyroute2/nftables/main.py +++ b/pyroute2/nftables/main.py @@ -1,5 +1,6 @@ ''' ''' + from pyroute2.netlink.nfnetlink import nfgen_msg from pyroute2.netlink.nfnetlink.nftsocket import ( DATA_TYPE_ID_TO_NAME, diff --git a/pyroute2/remote/transport.py b/pyroute2/remote/transport.py index 6505c37c6..11b3a3d11 100644 --- a/pyroute2/remote/transport.py +++ b/pyroute2/remote/transport.py @@ -196,9 +196,9 @@ def stop_server(signum, frame): and ipr._brd_socket is not None ): inputs.append(ipr._brd_socket.fileno()) - broadcasts[ - ipr._brd_socket.fileno() - ] = ipr._brd_socket + broadcasts[ipr._brd_socket.fileno()] = ( + ipr._brd_socket + ) except Exception as e: ret = None error = e diff --git a/pyroute2/requests/main.py b/pyroute2/requests/main.py index e3b9a5115..f1ea1512b 100644 --- a/pyroute2/requests/main.py +++ b/pyroute2/requests/main.py @@ -1,6 +1,7 @@ ''' General request and RTNL object data filters. ''' + import weakref from collections import ChainMap