From: Donald Hunter <donald.hunter@gmail.com>
To: "Donald Hunter" <donald.hunter@gmail.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Paolo Abeni" <pabeni@redhat.com>,
"Simon Horman" <horms@kernel.org>,
"Matthieu Baerts (NGI0)" <matttbe@kernel.org>,
"Gal Pressman" <gal@nvidia.com>,
"Jan Stancek" <jstancek@redhat.com>,
"Hangbin Liu" <liuhangbin@gmail.com>,
"Nimrod Oren" <noren@nvidia.com>,
netdev@vger.kernel.org, "Jonathan Corbet" <corbet@lwn.net>,
"Asbjørn Sloth Tønnesen" <ast@fiberby.net>,
"Mauro Carvalho Chehab" <mchehab+huawei@kernel.org>,
"Jacob Keller" <jacob.e.keller@intel.com>,
"Ruben Wauters" <rubenru09@aol.com>,
linux-doc@vger.kernel.org
Subject: [PATCH net-next v1 08/13] tools: ynl: ethtool: fix pylint issues
Date: Wed, 7 Jan 2026 12:21:38 +0000 [thread overview]
Message-ID: <20260107122143.93810-9-donald.hunter@gmail.com> (raw)
In-Reply-To: <20260107122143.93810-1-donald.hunter@gmail.com>
Fix or suppress all the pylint issues in ethtool.py, except for
TODO (fixme) items.
Suppress:
- too-many-locals
- too-many-branches
- too-many-statements
- too-many-return-statements
- import-error
Fix:
- missing-module-docstring
- redefined-outer-name
- dangerous-default-value
- use-dict-literal
- missing-function-docstring
- global-variable-undefined
- expression-not-assigned
- inconsistent-return-statements
- wrong-import-order
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
---
tools/net/ynl/pyynl/ethtool.py | 46 +++++++++++++++++++++++-----------
1 file changed, 31 insertions(+), 15 deletions(-)
diff --git a/tools/net/ynl/pyynl/ethtool.py b/tools/net/ynl/pyynl/ethtool.py
index 40a8ba8d296f..f1a2a2a89985 100755
--- a/tools/net/ynl/pyynl/ethtool.py
+++ b/tools/net/ynl/pyynl/ethtool.py
@@ -1,5 +1,10 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+#
+# pylint: disable=too-many-locals, too-many-branches, too-many-statements
+# pylint: disable=too-many-return-statements
+
+""" YNL ethtool utility """
import argparse
import pathlib
@@ -10,8 +15,10 @@ import os
# pylint: disable=no-name-in-module,wrong-import-position
sys.path.append(pathlib.Path(__file__).resolve().parent.as_posix())
-from lib import YnlFamily
+# pylint: disable=import-error
from cli import schema_dir, spec_dir
+from lib import YnlFamily
+
def args_to_req(ynl, op_name, args, req):
"""
@@ -49,7 +56,8 @@ def print_field(reply, *desc):
return
if len(desc) == 0:
- return print_field(reply, *zip(reply.keys(), reply.keys()))
+ print_field(reply, *zip(reply.keys(), reply.keys()))
+ return
for spec in desc:
try:
@@ -89,11 +97,12 @@ def doit(ynl, args, op_name):
args_to_req(ynl, op_name, args.args, req)
ynl.do(op_name, req)
-def dumpit(ynl, args, op_name, extra = {}):
+def dumpit(ynl, args, op_name, extra=None):
"""
Prepare request header, parse arguments and dumpit (filtering out the
devices we're not interested in).
"""
+ extra = extra or {}
reply = ynl.dump(op_name, { 'header': {} } | extra)
if not reply:
return {}
@@ -115,9 +124,9 @@ def bits_to_dict(attr):
"""
ret = {}
if 'bits' not in attr:
- return dict()
+ return {}
if 'bit' not in attr['bits']:
- return dict()
+ return {}
for bit in attr['bits']['bit']:
if bit['name'] == '':
continue
@@ -127,6 +136,8 @@ def bits_to_dict(attr):
return ret
def main():
+ """ YNL ethtool utility """
+
parser = argparse.ArgumentParser(description='ethtool wannabe')
parser.add_argument('--json', action=argparse.BooleanOptionalAction)
parser.add_argument('--show-priv-flags', action=argparse.BooleanOptionalAction)
@@ -156,7 +167,7 @@ def main():
# TODO: rss-get
parser.add_argument('device', metavar='device', type=str)
parser.add_argument('args', metavar='args', type=str, nargs='*')
- global args
+
args = parser.parse_args()
spec = os.path.join(spec_dir(), 'ethtool.yaml')
@@ -170,13 +181,16 @@ def main():
return
if args.set_eee:
- return doit(ynl, args, 'eee-set')
+ doit(ynl, args, 'eee-set')
+ return
if args.set_pause:
- return doit(ynl, args, 'pause-set')
+ doit(ynl, args, 'pause-set')
+ return
if args.set_coalesce:
- return doit(ynl, args, 'coalesce-set')
+ doit(ynl, args, 'coalesce-set')
+ return
if args.set_features:
# TODO: parse the bitmask
@@ -184,10 +198,12 @@ def main():
return
if args.set_channels:
- return doit(ynl, args, 'channels-set')
+ doit(ynl, args, 'channels-set')
+ return
if args.set_ring:
- return doit(ynl, args, 'rings-set')
+ doit(ynl, args, 'rings-set')
+ return
if args.show_priv_flags:
flags = bits_to_dict(dumpit(ynl, args, 'privflags-get')['flags'])
@@ -338,25 +354,25 @@ def main():
print(f'Time stamping parameters for {args.device}:')
print('Capabilities:')
- [print(f'\t{v}') for v in bits_to_dict(tsinfo['timestamping'])]
+ _ = [print(f'\t{v}') for v in bits_to_dict(tsinfo['timestamping'])]
print(f'PTP Hardware Clock: {tsinfo.get("phc-index", "none")}')
if 'tx-types' in tsinfo:
print('Hardware Transmit Timestamp Modes:')
- [print(f'\t{v}') for v in bits_to_dict(tsinfo['tx-types'])]
+ _ = [print(f'\t{v}') for v in bits_to_dict(tsinfo['tx-types'])]
else:
print('Hardware Transmit Timestamp Modes: none')
if 'rx-filters' in tsinfo:
print('Hardware Receive Filter Modes:')
- [print(f'\t{v}') for v in bits_to_dict(tsinfo['rx-filters'])]
+ _ = [print(f'\t{v}') for v in bits_to_dict(tsinfo['rx-filters'])]
else:
print('Hardware Receive Filter Modes: none')
if 'stats' in tsinfo and tsinfo['stats']:
print('Statistics:')
- [print(f'\t{k}: {v}') for k, v in tsinfo['stats'].items()]
+ _ = [print(f'\t{k}: {v}') for k, v in tsinfo['stats'].items()]
return
--
2.52.0
next prev parent reply other threads:[~2026-01-07 12:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-07 12:21 [PATCH net-next v1 00/13] tools: ynl: clean up pylint issues Donald Hunter
2026-01-07 12:21 ` [PATCH net-next v1 01/13] tools: ynl: pylint suppressions and docstrings Donald Hunter
2026-01-07 12:21 ` [PATCH net-next v1 02/13] tools: ynl: fix pylint redefinition, encoding errors Donald Hunter
2026-01-07 12:21 ` [PATCH net-next v1 03/13] tools: ynl: fix pylint exception warnings Donald Hunter
2026-01-07 12:21 ` [PATCH net-next v1 04/13] tools: ynl: fix pylint dict, indentation, long lines, uninitialised Donald Hunter
2026-01-07 12:21 ` [PATCH net-next v1 05/13] tools: ynl: fix pylint misc warnings Donald Hunter
2026-01-07 12:21 ` [PATCH net-next v1 06/13] tools: ynl: fix pylint global variable related warnings Donald Hunter
2026-01-07 12:21 ` [PATCH net-next v1 07/13] tools: ynl: fix logic errors reported by pylint Donald Hunter
2026-01-07 12:21 ` Donald Hunter [this message]
2026-01-07 12:21 ` [PATCH net-next v1 09/13] tools: ynl: fix pylint issues in ynl_gen_rst Donald Hunter
2026-01-07 12:21 ` [PATCH net-next v1 10/13] tools: ynl-gen-c: suppress unhelpful pylint messages Donald Hunter
2026-01-07 12:21 ` [PATCH net-next v1 11/13] tools: ynl-gen-c: fix pylint warnings for returns, unused, redefined Donald Hunter
2026-01-07 12:21 ` [PATCH net-next v1 12/13] tools: ynl-gen-c: fix pylint None, type, dict, generators, init Donald Hunter
2026-01-07 12:21 ` [PATCH net-next v1 13/13] tools: ynl-gen-c: Fix remaining pylint warnings Donald Hunter
2026-01-07 16:45 ` Jakub Kicinski
2026-01-07 22:32 ` Donald Hunter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260107122143.93810-9-donald.hunter@gmail.com \
--to=donald.hunter@gmail.com \
--cc=ast@fiberby.net \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=jstancek@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=liuhangbin@gmail.com \
--cc=matttbe@kernel.org \
--cc=mchehab+huawei@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=noren@nvidia.com \
--cc=pabeni@redhat.com \
--cc=rubenru09@aol.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox