Skip to content

Commit

Permalink
ci: Merge pull request #1167 from svinota/ci-update
Browse files Browse the repository at this point in the history
ci update

* flake8 7.0.0
* pre-commit-hooks 4.5.0
* isort 5.13.2
* black 24.1.1

Bug-Url: #1167
  • Loading branch information
svinota authored Feb 5, 2024
2 parents 68a5c1b + 7340c49 commit 53d4844
Show file tree
Hide file tree
Showing 45 changed files with 66 additions and 32 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
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
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
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']
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 7.0.0
hooks:
- id: flake8
files: \.py$
Expand Down
1 change: 1 addition & 0 deletions pr2modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
It will be removed in 0.8.x
'''

import sys
import warnings

Expand Down
1 change: 1 addition & 0 deletions pyroute2/bsd/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Maybe some day it will be ioctl. For now it's ifconfig and netstat.
'''

import re
import socket
import subprocess
Expand Down
4 changes: 3 additions & 1 deletion pyroute2/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions pyroute2/dhcp/dhcp4socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
================
'''

from pyroute2.common import AddrPool
from pyroute2.dhcp.dhcp4msg import dhcp4msg
from pyroute2.ext.rawsocket import RawSocket
Expand Down
8 changes: 3 additions & 5 deletions pyroute2/ethtool/ethtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
1 change: 1 addition & 0 deletions pyroute2/ipdb/linkedset.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'''
'''

import struct
import threading
from collections import OrderedDict
Expand Down
18 changes: 10 additions & 8 deletions pyroute2/ipdb/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)
Expand Down Expand Up @@ -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,
)
)
Expand Down Expand Up @@ -727,7 +729,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)
Expand Down Expand Up @@ -822,7 +824,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
Expand Down
1 change: 1 addition & 0 deletions pyroute2/ipdb/transactional.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'''
'''

import logging
import threading

Expand Down
1 change: 1 addition & 0 deletions pyroute2/iproute/bsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pyroute2/iproute/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pyroute2/ipset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
It supports almost all kernel commands (create, destroy, flush,
rename, swap, test...)
'''

import errno
import socket

Expand Down
1 change: 1 addition & 0 deletions pyroute2/ndb/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ def add_mock_netns(self, netns):
# context manager's __exit__()
'''

import atexit
import ctypes
import ctypes.util
Expand Down
1 change: 1 addition & 0 deletions pyroute2/ndb/objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
API
===
'''

import collections
import errno
import json
Expand Down
1 change: 1 addition & 0 deletions pyroute2/ndb/objects/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions pyroute2/ndb/objects/route.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
See here: :ref:`mpls`
'''

import json
import struct
import time
Expand Down
1 change: 1 addition & 0 deletions pyroute2/ndb/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
2,'eth0','5254.0072.58b2','up'
'''

import json
import warnings
from itertools import chain
Expand Down
1 change: 1 addition & 0 deletions pyroute2/ndb/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pyroute2/ndb/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
See also: :ref:`remote`
'''

import errno
import importlib
import queue
Expand Down
1 change: 1 addition & 0 deletions pyroute2/ndb/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
---
'''

import logging
import shlex
import shutil
Expand Down
1 change: 1 addition & 0 deletions pyroute2/netlink/devlink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
devlink module
==============
'''

from pyroute2.common import map_namespace
from pyroute2.netlink import genlmsg, nla
from pyroute2.netlink.generic import GenericNetlinkSocket
Expand Down
2 changes: 1 addition & 1 deletion pyroute2/netlink/diag/ss2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pyroute2/netlink/event/acpi_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
'type': 32768}
'''

from pyroute2.common import load_dump
from pyroute2.netlink import genlmsg, nla
from pyroute2.netlink.event import EventSocket
Expand Down
1 change: 1 addition & 0 deletions pyroute2/netlink/event/dquot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pyroute2/netlink/event/thermal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'''
'''

from enum import Enum

from pyroute2.netlink import genlmsg
Expand Down
1 change: 0 additions & 1 deletion pyroute2/netlink/generic/wireguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
}
'''


import errno
import logging
import struct
Expand Down
1 change: 1 addition & 0 deletions pyroute2/netlink/ipq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 7 additions & 6 deletions pyroute2/netlink/nl80211/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
TODO
'''

import datetime
import struct

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions pyroute2/netlink/proxy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'''
Netlink proxy engine
'''

import errno
import logging
import struct
Expand Down
1 change: 1 addition & 0 deletions pyroute2/netlink/rtnl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
Module contents:
'''

from pyroute2.common import map_namespace

# RTnetlink multicast group flags (for use with bind())
Expand Down
1 change: 0 additions & 1 deletion pyroute2/netlink/rtnl/tcmsg/act_skbedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
- queue: integer
'''


from pyroute2.netlink import nla
from pyroute2.netlink.rtnl.tcmsg.common import tc_actions

Expand Down
1 change: 1 addition & 0 deletions pyroute2/netlink/rtnl/tcmsg/cls_u32.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
# 0xffffff00 = 255.255.255.0 (/24)
# 16 = Destination network field bit offset
'''

import struct
from socket import htons

Expand Down
2 changes: 1 addition & 1 deletion pyroute2/netlink/rtnl/tcmsg/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion pyroute2/netlink/rtnl/tcmsg/sched_cake.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
- wash: False or True (False by default)
'''


from pyroute2.netlink import nla
from pyroute2.netlink.rtnl import TC_H_ROOT

Expand Down
1 change: 1 addition & 0 deletions pyroute2/netlink/rtnl/tcmsg/sched_choke.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
ecn=True)
'''

import logging
import struct

Expand Down
1 change: 1 addition & 0 deletions pyroute2/netlink/rtnl/tcmsg/sched_clsact.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
parent="ffff:fff3", classid=1, direct_action=True)
'''

from pyroute2.netlink.rtnl import TC_H_CLSACT

parent = TC_H_CLSACT
Expand Down
1 change: 1 addition & 0 deletions pyroute2/netlink/rtnl/tcmsg/sched_drr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pyroute2/netlink/rtnl/tcmsg/sched_hfsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 53d4844

Please sign in to comment.