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 05/13] tools: ynl: fix pylint misc warnings
Date: Wed, 7 Jan 2026 12:21:35 +0000 [thread overview]
Message-ID: <20260107122143.93810-6-donald.hunter@gmail.com> (raw)
In-Reply-To: <20260107122143.93810-1-donald.hunter@gmail.com>
Fix pylint warnings for:
- unused-argument
- consider-using-in
- consider-using-get
- consider-using-f-string
- protected-access
- unidiomatic-typecheck
- no-else-return
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
---
tools/net/ynl/pyynl/lib/doc_generator.py | 3 +--
tools/net/ynl/pyynl/lib/nlspec.py | 5 ++---
tools/net/ynl/pyynl/lib/ynl.py | 16 ++++++++--------
3 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/tools/net/ynl/pyynl/lib/doc_generator.py b/tools/net/ynl/pyynl/lib/doc_generator.py
index 3a16b8eb01ca..d1afff9d9956 100644
--- a/tools/net/ynl/pyynl/lib/doc_generator.py
+++ b/tools/net/ynl/pyynl/lib/doc_generator.py
@@ -109,8 +109,7 @@ class RstFormatters:
'fixed-header': 'definition',
'nested-attributes': 'attribute-set',
'struct': 'definition'}
- if prefix in mappings:
- prefix = mappings[prefix]
+ prefix = mappings.get(prefix, prefix)
return f":ref:`{namespace}-{prefix}-{name}`"
def rst_header(self) -> str:
diff --git a/tools/net/ynl/pyynl/lib/nlspec.py b/tools/net/ynl/pyynl/lib/nlspec.py
index fcd4106d0cfa..f3173146b64b 100644
--- a/tools/net/ynl/pyynl/lib/nlspec.py
+++ b/tools/net/ynl/pyynl/lib/nlspec.py
@@ -105,8 +105,7 @@ class SpecEnumEntry(SpecElement):
def user_value(self, as_flags=None):
if self.enum_set['type'] == 'flags' or as_flags:
return 1 << self.value
- else:
- return self.value
+ return self.value
class SpecEnumSet(SpecElement):
@@ -194,7 +193,7 @@ class SpecAttr(SpecElement):
self.sub_message = yaml.get('sub-message')
self.selector = yaml.get('selector')
- self.is_auto_scalar = self.type == "sint" or self.type == "uint"
+ self.is_auto_scalar = self.type in ("sint", "uint")
class SpecAttrSet(SpecElement):
diff --git a/tools/net/ynl/pyynl/lib/ynl.py b/tools/net/ynl/pyynl/lib/ynl.py
index 49c35568ceba..2ad954f885f3 100644
--- a/tools/net/ynl/pyynl/lib/ynl.py
+++ b/tools/net/ynl/pyynl/lib/ynl.py
@@ -415,7 +415,7 @@ class NetlinkProtocol:
nlmsg = struct.pack("HHII", nl_type, nl_flags, seq, 0)
return nlmsg
- def message(self, flags, command, version, seq=None):
+ def message(self, flags, command, _version, seq=None):
return self._message(command, flags, seq)
def _decode(self, nl_msg):
@@ -425,7 +425,7 @@ class NetlinkProtocol:
msg = self._decode(nl_msg)
if op is None:
op = ynl.rsp_by_value[msg.cmd()]
- fixed_header_size = ynl._struct_size(op.fixed_header)
+ fixed_header_size = ynl.struct_size(op.fixed_header)
msg.raw_attrs = NlAttrs(msg.raw, fixed_header_size)
return msg
@@ -755,7 +755,7 @@ class YnlFamily(SpecFamily):
def _rsp_add(self, rsp, name, is_multi, decoded):
if is_multi is None:
- if name in rsp and type(rsp[name]) is not list:
+ if name in rsp and not isinstance(rsp[name], list):
rsp[name] = [rsp[name]]
is_multi = True
else:
@@ -788,7 +788,7 @@ class YnlFamily(SpecFamily):
offset = 0
if msg_format.fixed_header:
decoded.update(self._decode_struct(attr.raw, msg_format.fixed_header))
- offset = self._struct_size(msg_format.fixed_header)
+ offset = self.struct_size(msg_format.fixed_header)
if msg_format.attr_set:
if msg_format.attr_set in self.attr_sets:
subdict = self._decode(NlAttrs(attr.raw, offset), msg_format.attr_set)
@@ -908,7 +908,7 @@ class YnlFamily(SpecFamily):
return
msg = self.nlproto.decode(self, NlMsg(request, 0, op.attr_set), op)
- offset = self.nlproto.msghdr_size() + self._struct_size(op.fixed_header)
+ offset = self.nlproto.msghdr_size() + self.struct_size(op.fixed_header)
search_attrs = SpaceAttrs(op.attr_set, vals)
path = self._decode_extack_path(msg.raw_attrs, op.attr_set, offset,
extack['bad-attr-offs'], search_attrs)
@@ -916,14 +916,14 @@ class YnlFamily(SpecFamily):
del extack['bad-attr-offs']
extack['bad-attr'] = path
- def _struct_size(self, name):
+ def struct_size(self, name):
if name:
members = self.consts[name].members
size = 0
for m in members:
if m.type in ['pad', 'binary']:
if m.struct:
- size += self._struct_size(m.struct)
+ size += self.struct_size(m.struct)
else:
size += m.len
else:
@@ -987,7 +987,7 @@ class YnlFamily(SpecFamily):
def _formatted_string(self, raw, display_hint):
if display_hint == 'mac':
- formatted = ':'.join('%02x' % b for b in raw)
+ formatted = ':'.join(f'{b:x}' for b in raw)
elif display_hint == 'hex':
if isinstance(raw, int):
formatted = hex(raw)
--
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 ` Donald Hunter [this message]
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 ` [PATCH net-next v1 08/13] tools: ynl: ethtool: fix pylint issues Donald Hunter
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-6-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