Skip to content

Commit d8e0e25

Browse files
matttbekuba-moo
authored andcommitted
tools: ynl: remove f-string without any placeholders
'f-strings' without any placeholders don't need to be marked as such according to Ruff. This 'f' can be safely removed. This is linked to Ruff error F541 [1]: f-strings are a convenient way to format strings, but they are not necessary if there are no placeholder expressions to format. In this case, a regular string should be used instead, as an f-string without placeholders can be confusing for readers, who may expect such a placeholder to be present. Link: https://docs.astral.sh/ruff/rules/f-string-missing-placeholders/ [1] Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Reviewed-by: Donald Hunter <[email protected]> Reviewed-by: Asbjørn Sloth Tønnesen <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 02962dd commit d8e0e25

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

tools/net/ynl/pyynl/ethtool.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,14 @@ def main():
254254
reply = dumpit(ynl, args, 'channels-get')
255255
print(f'Channel parameters for {args.device}:')
256256

257-
print(f'Pre-set maximums:')
257+
print('Pre-set maximums:')
258258
print_field(reply,
259259
('rx-max', 'RX'),
260260
('tx-max', 'TX'),
261261
('other-max', 'Other'),
262262
('combined-max', 'Combined'))
263263

264-
print(f'Current hardware settings:')
264+
print('Current hardware settings:')
265265
print_field(reply,
266266
('rx-count', 'RX'),
267267
('tx-count', 'TX'),
@@ -275,14 +275,14 @@ def main():
275275

276276
print(f'Ring parameters for {args.device}:')
277277

278-
print(f'Pre-set maximums:')
278+
print('Pre-set maximums:')
279279
print_field(reply,
280280
('rx-max', 'RX'),
281281
('rx-mini-max', 'RX Mini'),
282282
('rx-jumbo-max', 'RX Jumbo'),
283283
('tx-max', 'TX'))
284284

285-
print(f'Current hardware settings:')
285+
print('Current hardware settings:')
286286
print_field(reply,
287287
('rx', 'RX'),
288288
('rx-mini', 'RX Mini'),
@@ -297,7 +297,7 @@ def main():
297297
return
298298

299299
if args.statistics:
300-
print(f'NIC statistics:')
300+
print('NIC statistics:')
301301

302302
# TODO: pass id?
303303
strset = dumpit(ynl, args, 'strset-get')

tools/net/ynl/pyynl/ynl_gen_c.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ def struct_member(self, ri):
485485
ri.cw.p(f"char *{self.c_name};")
486486

487487
def _attr_typol(self):
488-
typol = f'.type = YNL_PT_NUL_STR, '
488+
typol = '.type = YNL_PT_NUL_STR, '
489489
if self.is_selector:
490490
typol += '.is_selector = 1, '
491491
return typol
@@ -539,7 +539,7 @@ def struct_member(self, ri):
539539
ri.cw.p(f"void *{self.c_name};")
540540

541541
def _attr_typol(self):
542-
return f'.type = YNL_PT_BINARY,'
542+
return '.type = YNL_PT_BINARY,'
543543

544544
def _attr_policy(self, policy):
545545
if len(self.checks) == 0:
@@ -636,7 +636,7 @@ def _complex_member_type(self, ri):
636636
return "struct nla_bitfield32"
637637

638638
def _attr_typol(self):
639-
return f'.type = YNL_PT_BITFIELD32, '
639+
return '.type = YNL_PT_BITFIELD32, '
640640

641641
def _attr_policy(self, policy):
642642
if not 'enum' in self.attr:
@@ -909,7 +909,7 @@ def _attr_get(self, ri, var):
909909
else:
910910
sel_var = f"{var}->{sel}"
911911
get_lines = [f'if (!{sel_var})',
912-
f'return ynl_submsg_failed(yarg, "%s", "%s");' %
912+
'return ynl_submsg_failed(yarg, "%s", "%s");' %
913913
(self.name, self['selector']),
914914
f"if ({self.nested_render_name}_parse(&parg, {sel_var}, attr))",
915915
"return YNL_PARSE_CB_ERROR;"]
@@ -1563,7 +1563,7 @@ def __init__(self, cw, family, ku_space, op, op_mode, attr_set=None):
15631563
if family.is_classic():
15641564
self.fixed_hdr_len = f"sizeof(struct {c_lower(fixed_hdr)})"
15651565
else:
1566-
raise Exception(f"Per-op fixed header not supported, yet")
1566+
raise Exception("Per-op fixed header not supported, yet")
15671567

15681568

15691569
# 'do' and 'dump' response parsing is identical
@@ -2099,7 +2099,7 @@ def _multi_parse(ri, struct, init_lines, local_vars):
20992099
if ri.family.is_classic():
21002100
iter_line = f"ynl_attr_for_each(attr, nlh, sizeof({struct.fixed_header}))"
21012101
else:
2102-
raise Exception(f"Per-op fixed header not supported, yet")
2102+
raise Exception("Per-op fixed header not supported, yet")
21032103

21042104
array_nests = set()
21052105
multi_attrs = set()
@@ -2502,7 +2502,7 @@ def print_free_prototype(ri, direction, suffix=';'):
25022502

25032503
def print_nlflags_set(ri, direction):
25042504
name = op_prefix(ri, direction)
2505-
ri.cw.write_func_prot(f'static inline void', f"{name}_set_nlflags",
2505+
ri.cw.write_func_prot('static inline void', f"{name}_set_nlflags",
25062506
[f"struct {name} *req", "__u16 nl_flags"])
25072507
ri.cw.block_start()
25082508
ri.cw.p('req->_nlmsg_flags = nl_flags;')
@@ -2533,7 +2533,7 @@ def _print_type(ri, direction, struct):
25332533
line = attr.presence_member(ri.ku_space, type_filter)
25342534
if line:
25352535
if not meta_started:
2536-
ri.cw.block_start(line=f"struct")
2536+
ri.cw.block_start(line="struct")
25372537
meta_started = True
25382538
ri.cw.p(line)
25392539
if meta_started:
@@ -2697,7 +2697,7 @@ def print_dump_type_free(ri):
26972697
ri.cw.nl()
26982698

26992699
_free_type_members(ri, 'rsp', ri.struct['reply'], ref='obj.')
2700-
ri.cw.p(f'free(rsp);')
2700+
ri.cw.p('free(rsp);')
27012701
ri.cw.block_end()
27022702
ri.cw.block_end()
27032703
ri.cw.nl()
@@ -2708,7 +2708,7 @@ def print_ntf_type_free(ri):
27082708
ri.cw.block_start()
27092709
_free_type_members_iter(ri, ri.struct['reply'])
27102710
_free_type_members(ri, 'rsp', ri.struct['reply'], ref='obj.')
2711-
ri.cw.p(f'free(rsp);')
2711+
ri.cw.p('free(rsp);')
27122712
ri.cw.block_end()
27132713
ri.cw.nl()
27142714

@@ -3322,7 +3322,7 @@ def render_user_family(family, cw, prototype):
33223322
cw.block_start(f'{symbol} = ')
33233323
cw.p(f'.name\t\t= "{family.c_name}",')
33243324
if family.is_classic():
3325-
cw.p(f'.is_classic\t= true,')
3325+
cw.p('.is_classic\t= true,')
33263326
cw.p(f'.classic_id\t= {family.get("protonum")},')
33273327
if family.is_classic():
33283328
if family.fixed_header:

0 commit comments

Comments
 (0)