Skip to content

Commit 5b4df21

Browse files
committed
chore: reduce nesting if/elif/else blocks; uneeded var assignment
also add lint hint Leave chained if/elif/else blocks after returns if it doesn't reduce nesting.
1 parent 6f245f0 commit 5b4df21

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

roundup/admin.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,18 +1498,18 @@ def do_pragma(self, args):
14981498
raise UsageError(_(
14991499
'Argument must be setting=value, was given: %s.') %
15001500
args[0])
1501-
else:
1502-
print(_("Current settings and values "
1503-
"(NYI - not yet implemented):"))
1504-
is_verbose = self.settings['verbose']
1505-
for key in sorted(self.settings.keys()):
1506-
if key.startswith('_') and not is_verbose:
1507-
continue
1508-
print(" %s=%s" % (key, self.settings[key]))
1509-
if is_verbose:
1510-
print(" %s" % self.settings_help[key])
15111501

1512-
return
1502+
print(_("Current settings and values "
1503+
"(NYI - not yet implemented):"))
1504+
is_verbose = self.settings['verbose']
1505+
for key in sorted(self.settings.keys()):
1506+
if key.startswith('_') and not is_verbose:
1507+
continue
1508+
print(" %s=%s" % (key, self.settings[key]))
1509+
if is_verbose:
1510+
print(" %s" % self.settings_help[key])
1511+
1512+
return
15131513

15141514
if setting not in self.settings:
15151515
raise UsageError(_('Unknown setting %s. Try "pragma list".')
@@ -1720,8 +1720,8 @@ def do_security(self, args):
17201720
for p in permission.properties:
17211721
if p in class_props:
17221722
continue
1723-
else:
1724-
bad_props.append(p)
1723+
1724+
bad_props.append(p)
17251725
if bad_props:
17261726
sys.stdout.write(_(
17271727
'\n **Invalid properties for %(class)s: '
@@ -2012,8 +2012,7 @@ def run_command(self, args):
20122012

20132013
if command in ['genconfig', 'templates']:
20142014
try:
2015-
ret = function(args[1:])
2016-
return ret
2015+
return function(args[1:])
20172016
except UsageError as message:
20182017
return self.usageError_feedback(message, function)
20192018

@@ -2135,7 +2134,7 @@ def main(self): # noqa: PLR0912, PLR0911
21352134
self.print_designator = 0
21362135
self.verbose = 0
21372136
for opt, arg in opts:
2138-
if opt == '-h':
2137+
if opt == '-h': # noqa: RET505 - allow elif after returns
21392138
self.usage()
21402139
return 0
21412140
elif opt == '-v':

0 commit comments

Comments
 (0)