Skip to content

Commit 1a4b13c

Browse files
committed
Removed unnecessary use of pass
1 parent ada27c5 commit 1a4b13c

17 files changed

+6
-54
lines changed

cmd2/ansi.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,11 @@ def __radd__(self, other: Any) -> str:
211211
class FgColor(AnsiSequence):
212212
"""Base class for ANSI Sequences which set foreground text color"""
213213

214-
pass
215214

216215

217216
class BgColor(AnsiSequence):
218217
"""Base class for ANSI Sequences which set background text color"""
219218

220-
pass
221219

222220

223221
####################################################################################

cmd2/cmd2.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,7 +2463,6 @@ def preloop(self) -> None:
24632463
to run hooks before the command loop begins. See
24642464
[Hooks](../features/hooks.md) for more information.
24652465
"""
2466-
pass
24672466

24682467
def postloop(self) -> None:
24692468
"""Hook method executed once when the [cmd2.Cmd.cmdloop][] method is about to return.
@@ -2472,7 +2471,6 @@ def postloop(self) -> None:
24722471
to run hooks after the command loop completes. See
24732472
[Hooks](../features/hooks.md) for more information.
24742473
"""
2475-
pass
24762474

24772475
def parseline(self, line: str) -> tuple[str, str, str]:
24782476
"""Parse the line into a command name and a string containing the arguments.

cmd2/command_definition.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,12 @@ def on_registered(self) -> None:
136136
Subclasses can override this to perform custom steps related to the newly added commands (e.g. setting
137137
them to a disabled state).
138138
"""
139-
pass
140139

141140
def on_unregister(self) -> None:
142141
"""
143142
Called by ``cmd2.Cmd`` as the first step to unregistering a CommandSet. Subclasses can override this to
144143
perform any cleanup steps which require their commands being registered in the CLI.
145144
"""
146-
pass
147145

148146
def on_unregistered(self) -> None:
149147
"""

cmd2/exceptions.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class SkipPostcommandHooks(Exception):
1515
hooks, but not bad enough to print the exception to the user.
1616
"""
1717

18-
pass
1918

2019

2120
class Cmd2ArgparseError(SkipPostcommandHooks):
@@ -26,7 +25,6 @@ class Cmd2ArgparseError(SkipPostcommandHooks):
2625
after parsing fails, just return instead of raising an exception.
2726
"""
2827

29-
pass
3028

3129

3230
class CommandSetRegistrationError(Exception):
@@ -35,7 +33,6 @@ class CommandSetRegistrationError(Exception):
3533
from a cmd2 application.
3634
"""
3735

38-
pass
3936

4037

4138
class CompletionError(Exception):
@@ -86,22 +83,18 @@ def __init__(self, *args: Any, wrapped_ex: BaseException) -> None:
8683
class Cmd2ShlexError(Exception):
8784
"""Raised when shlex fails to parse a command line string in StatementParser"""
8885

89-
pass
9086

9187

9288
class EmbeddedConsoleExit(SystemExit):
9389
"""Custom exception class for use with the py command."""
9490

95-
pass
9691

9792

9893
class EmptyStatement(Exception):
9994
"""Custom exception class for handling behavior when the user just presses <Enter>."""
10095

101-
pass
10296

10397

10498
class RedirectionError(Exception):
10599
"""Custom exception class for when redirecting or piping output fails"""
106100

107-
pass

examples/alias_startup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def __init__(self):
1818

1919
def do_nothing(self, args):
2020
"""This command does nothing and produces no output."""
21-
pass
2221

2322

2423
if __name__ == '__main__':

examples/async_printing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def _get_alerts(self) -> list[str]:
108108
if rand_num > 2:
109109
return []
110110

111-
for i in range(0, rand_num):
111+
for i in range(rand_num):
112112
self._alert_count += 1
113113
alerts.append(f"Alert {self._alert_count}")
114114

examples/default_categories.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
class MyBaseCommandSet(CommandSet):
1515
"""Defines a default category for all sub-class CommandSets"""
1616

17-
pass
1817

1918

2019
class ChildInheritsParentCategories(MyBaseCommandSet):

plugins/tasks.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
@invoke.task()
4040
def pytest(_):
4141
"""Run tests and code coverage using pytest"""
42-
pass
4342

4443

4544
namespace.add_task(pytest)
@@ -48,7 +47,6 @@ def pytest(_):
4847
@invoke.task(pre=[ext_test_tasks.pytest_clean])
4948
def pytest_clean(_):
5049
"""Remove pytest cache and code coverage files and directories"""
51-
pass
5250

5351

5452
namespace_clean.add_task(pytest_clean, 'pytest')
@@ -57,7 +55,6 @@ def pytest_clean(_):
5755
@invoke.task(pre=[ext_test_tasks.mypy])
5856
def mypy(_):
5957
"""Run mypy optional static type checker"""
60-
pass
6158

6259

6360
namespace.add_task(mypy)
@@ -67,7 +64,6 @@ def mypy(_):
6764
def mypy_clean(_):
6865
"""Remove mypy cache directory"""
6966
# pylint: disable=unused-argument
70-
pass
7167

7268

7369
namespace_clean.add_task(mypy_clean, 'mypy')
@@ -85,7 +81,6 @@ def mypy_clean(_):
8581
@invoke.task(pre=[ext_test_tasks.build_clean])
8682
def build_clean(_):
8783
"""Remove the build directory"""
88-
pass
8984

9085

9186
namespace_clean.add_task(build_clean, 'build')
@@ -94,7 +89,6 @@ def build_clean(_):
9489
@invoke.task(pre=[ext_test_tasks.dist_clean])
9590
def dist_clean(_):
9691
"""Remove the dist directory"""
97-
pass
9892

9993

10094
namespace_clean.add_task(dist_clean, 'dist')
@@ -108,7 +102,6 @@ def dist_clean(_):
108102
def clean_all(_):
109103
"""Run all clean tasks"""
110104
# pylint: disable=unused-argument
111-
pass
112105

113106

114107
namespace_clean.add_task(clean_all, 'all')
@@ -117,7 +110,6 @@ def clean_all(_):
117110
@invoke.task(pre=[clean_all], post=[ext_test_tasks.sdist])
118111
def sdist(_):
119112
"""Create a source distribution"""
120-
pass
121113

122114

123115
namespace.add_task(sdist)
@@ -126,7 +118,6 @@ def sdist(_):
126118
@invoke.task(pre=[clean_all], post=[ext_test_tasks.wheel])
127119
def wheel(_):
128120
"""Build a wheel distribution"""
129-
pass
130121

131122

132123
namespace.add_task(wheel)

plugins/template/tasks.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ def bytecode_clean(context):
160160
def clean_all(context):
161161
"""Run all clean tasks"""
162162
# pylint: disable=unused-argument
163-
pass
164163

165164

166165
namespace_clean.add_task(clean_all, 'all')

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ select = [
194194
"PD", # pandas-vet (Pandas specific rules)
195195
"PERF", # Perflint (warn about performance issues)
196196
"PGH", # pygrep-hooks (force specific rule codes when ignoring type or linter issues on a line)
197-
# "PIE", # flake8-pie (eliminate unnecessary use of pass, range starting at 0, etc.)
198-
"PLC", # Pylint Conventions
199-
"PLE", # Pylint Errors
197+
"PIE", # flake8-pie (eliminate unnecessary use of pass, range starting at 0, etc.)
198+
"PLC", # Pylint Conventions
199+
"PLE", # Pylint Errors
200200
# "PLR", # Pylint Refactoring suggestions
201201
# "PLW", # Pylint Warnings
202202
# "PT", # flake8-pytest-style (warnings about unit test best practices)

tasks.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ def ruff_clean(context):
260260
def clean_all(_):
261261
"""Run all clean tasks"""
262262
# pylint: disable=unused-argument
263-
pass
264263

265264

266265
namespace_clean.add_task(clean_all, 'all')

tests/test_argparse_completer.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def choices_provider(self) -> List[str]:
130130
def completion_item_method(self) -> List[CompletionItem]:
131131
"""Choices method that returns CompletionItems"""
132132
items = []
133-
for i in range(0, 10):
133+
for i in range(10):
134134
main_str = 'main_str{}'.format(i)
135135
items.append(CompletionItem(main_str, description='blah blah'))
136136
return items
@@ -775,7 +775,7 @@ def test_completion_items(ac_app):
775775
)
776776
def test_max_completion_items(ac_app, num_aliases, show_description):
777777
# Create aliases
778-
for i in range(0, num_aliases):
778+
for i in range(num_aliases):
779779
run_cmd(ac_app, 'alias create fake_alias{} help'.format(i))
780780

781781
assert len(ac_app.aliases) == num_aliases
@@ -1232,7 +1232,6 @@ def __init__(self):
12321232
@with_argparser(default_completer_parser)
12331233
def do_default_completer(self, args: argparse.Namespace) -> None:
12341234
"""Test command"""
1235-
pass
12361235

12371236
# Parser that's used to test setting a custom completer at the parser level
12381237
custom_completer_parser = Cmd2ArgumentParser(
@@ -1243,7 +1242,6 @@ def do_default_completer(self, args: argparse.Namespace) -> None:
12431242
@with_argparser(custom_completer_parser)
12441243
def do_custom_completer(self, args: argparse.Namespace) -> None:
12451244
"""Test command"""
1246-
pass
12471245

12481246
# Test as_subcommand_to decorator with custom completer
12491247
top_parser = Cmd2ArgumentParser(description="Top Command")

tests/test_cmd2.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,14 +1186,12 @@ def __init__(self, *args, **kwargs):
11861186

11871187
def do_squat(self, arg):
11881188
"""This docstring help will never be shown because the help_squat method overrides it."""
1189-
pass
11901189

11911190
def help_squat(self):
11921191
self.stdout.write('This command does diddly squat...\n')
11931192

11941193
def do_edit(self, arg):
11951194
"""This overrides the edit command and does nothing."""
1196-
pass
11971195

11981196
# This command will be in the "undocumented" section of the help menu
11991197
def do_undoc(self, arg):
@@ -1206,14 +1204,12 @@ def do_multiline_docstr(self, arg):
12061204
and there are no
12071205
tabs
12081206
"""
1209-
pass
12101207

12111208
parser_cmd_parser = cmd2.Cmd2ArgumentParser(description="This is the description.")
12121209

12131210
@cmd2.with_argparser(parser_cmd_parser)
12141211
def do_parser_cmd(self, args):
12151212
"""This is the docstring."""
1216-
pass
12171213

12181214

12191215
@pytest.fixture
@@ -1268,7 +1264,6 @@ def __init__(self, *args, **kwargs):
12681264
@cmd2.with_category('Some Category')
12691265
def do_diddly(self, arg):
12701266
"""This command does diddly"""
1271-
pass
12721267

12731268
# This command will be in the "Some Category" section of the help menu even though it has no docstring
12741269
@cmd2.with_category("Some Category")
@@ -1277,14 +1272,12 @@ def do_cat_nodoc(self, arg):
12771272

12781273
def do_squat(self, arg):
12791274
"""This docstring help will never be shown because the help_squat method overrides it."""
1280-
pass
12811275

12821276
def help_squat(self):
12831277
self.stdout.write('This command does diddly squat...\n')
12841278

12851279
def do_edit(self, arg):
12861280
"""This overrides the edit command and does nothing."""
1287-
pass
12881281

12891282
cmd2.categorize((do_squat, do_edit), 'Custom Category')
12901283

tests/test_completion.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ def complete_test_multiline(self, text, line, begidx, endidx):
107107

108108
def do_test_no_completer(self, args):
109109
"""Completing this should result in completedefault() being called"""
110-
pass
111110

112111
def complete_foo_val(self, text, line, begidx, endidx, arg_tokens):
113112
"""Supports unit testing cmd2.Cmd2.complete_set_val to confirm it passes all tokens in the set command"""

tests/test_plugin.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ def prepost_hook_two(self) -> None:
4949

5050
def prepost_hook_too_many_parameters(self, param) -> None:
5151
"""A preloop or postloop hook with too many parameters"""
52-
pass
5352

5453
def prepost_hook_with_wrong_return_annotation(self) -> bool:
5554
"""A preloop or postloop hook with incorrect return type"""
56-
pass
5755

5856
###
5957
#
@@ -93,23 +91,18 @@ def postparse_hook_exception(self, data: cmd2.plugin.PostparsingData) -> cmd2.pl
9391

9492
def postparse_hook_too_many_parameters(self, data1, data2) -> cmd2.plugin.PostparsingData:
9593
"""A postparsing hook with too many parameters"""
96-
pass
9794

9895
def postparse_hook_undeclared_parameter_annotation(self, data) -> cmd2.plugin.PostparsingData:
9996
"""A postparsing hook with an undeclared parameter type"""
100-
pass
10197

10298
def postparse_hook_wrong_parameter_annotation(self, data: str) -> cmd2.plugin.PostparsingData:
10399
"""A postparsing hook with the wrong parameter type"""
104-
pass
105100

106101
def postparse_hook_undeclared_return_annotation(self, data: cmd2.plugin.PostparsingData):
107102
"""A postparsing hook with an undeclared return type"""
108-
pass
109103

110104
def postparse_hook_wrong_return_annotation(self, data: cmd2.plugin.PostparsingData) -> str:
111105
"""A postparsing hook with the wrong return type"""
112-
pass
113106

114107
###
115108
#
@@ -138,7 +131,6 @@ def precmd_hook_exception(self, data: plugin.PrecommandData) -> plugin.Precomman
138131

139132
def precmd_hook_not_enough_parameters(self) -> plugin.PrecommandData:
140133
"""A precommand hook with no parameters"""
141-
pass
142134

143135
def precmd_hook_too_many_parameters(self, one: plugin.PrecommandData, two: str) -> plugin.PrecommandData:
144136
"""A precommand hook with too many parameters"""
@@ -181,7 +173,6 @@ def postcmd_hook_exception(self, data: plugin.PostcommandData) -> plugin.Postcom
181173

182174
def postcmd_hook_not_enough_parameters(self) -> plugin.PostcommandData:
183175
"""A precommand hook with no parameters"""
184-
pass
185176

186177
def postcmd_hook_too_many_parameters(self, one: plugin.PostcommandData, two: str) -> plugin.PostcommandData:
187178
"""A precommand hook with too many parameters"""
@@ -247,7 +238,6 @@ def cmdfinalization_hook_passthrough_exception(
247238

248239
def cmdfinalization_hook_not_enough_parameters(self) -> plugin.CommandFinalizationData:
249240
"""A command finalization hook with no parameters."""
250-
pass
251241

252242
def cmdfinalization_hook_too_many_parameters(
253243
self, one: plugin.CommandFinalizationData, two: str

tests/test_transcript.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ def do_mumble(self, opts, arg):
8888

8989
def do_nothing(self, statement):
9090
"""Do nothing and output nothing"""
91-
pass
9291

9392
def do_keyboard_interrupt(self, _):
9493
raise KeyboardInterrupt('Interrupting this command')

tests_isolated/test_commandset/test_commandset.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,6 @@ def __init__(self, *args, **kwargs):
10091009
@cmd2.with_argparser(cut_parser)
10101010
def do_cut(self, ns: argparse.Namespace):
10111011
"""Cut something"""
1012-
pass
10131012

10141013
banana_parser = cmd2.Cmd2ArgumentParser()
10151014
banana_parser.add_argument('direction', choices=['discs', 'lengthwise'])

0 commit comments

Comments
 (0)