Skip to content

Commit 26cf7b9

Browse files
committed
Enabled ruff ERA ruleset for eradicating commented-out code
1 parent f589404 commit 26cf7b9

File tree

13 files changed

+16
-25
lines changed

13 files changed

+16
-25
lines changed

cmd2/rl_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def enable_win_vt100(handle: HANDLE) -> bool:
101101
############################################################################################################
102102
# pyreadline3 is incomplete in terms of the Python readline API. Add the missing functions we need.
103103
############################################################################################################
104-
# readline.remove_history_item()
104+
# Add missing `readline.remove_history_item()`
105105
try:
106106
getattr(readline, 'remove_history_item')
107107
except AttributeError:

examples/cmd_as_argument.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CmdLineApp(cmd2.Cmd):
2020
"""Example cmd2 application."""
2121

2222
# Setting this true makes it run a shell command if a cmd2/cmd command doesn't exist
23-
# default_to_shell = True
23+
# default_to_shell = True # noqa: ERA001
2424
MUMBLES = ['like', '...', 'um', 'er', 'hmmm', 'ahh']
2525
MUMBLE_FIRST = ['so', 'like', 'well']
2626
MUMBLE_LAST = ['right?']

examples/decorator_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(self, ip_addr=None, port=None, transcript_files=None) -> None:
3232
self._port = port
3333

3434
# Setting this true makes it run a shell command if a cmd2/cmd command doesn't exist
35-
# self.default_to_shell = True
35+
# self.default_to_shell = True # noqa: ERA001
3636

3737
speak_parser = cmd2.Cmd2ArgumentParser()
3838
speak_parser.add_argument('-p', '--piglatin', action='store_true', help='atinLay')

examples/example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CmdLineApp(cmd2.Cmd):
1818
"""Example cmd2 application."""
1919

2020
# Setting this true makes it run a shell command if a cmd2/cmd command doesn't exist
21-
# default_to_shell = True
21+
# default_to_shell = True # noqa: ERA001
2222
MUMBLES = ['like', '...', 'um', 'er', 'hmmm', 'ahh']
2323
MUMBLE_FIRST = ['so', 'like', 'well']
2424
MUMBLE_LAST = ['right?']

examples/hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class CmdLineApp(cmd2.Cmd):
3838
"""
3939

4040
# Setting this true makes it run a shell command if a cmd2/cmd command doesn't exist
41-
# default_to_shell = True
41+
# default_to_shell = True # noqa: ERA001
4242
def __init__(self, *args, **kwargs) -> None:
4343
super().__init__(*args, **kwargs)
4444

examples/migrating.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
"""A sample cmd application that shows how to trivially migrate a cmd application to use cmd2."""
33

4-
# import cmd2 as cmd
4+
# import cmd2 as cmd # noqa: ERA001
55
import cmd # Comment this line and uncomment the one above to migrate to cmd2
66
import random
77

plugins/ext_test/cmd2_ext_test/cmd2_ext_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def fixture_teardown(self):
6363
6464
:type self: cmd2.Cmd
6565
"""
66-
# assert isinstance(self, cmd2.Cmd) and isinstance(self, ExternalTestMixin)
6766
for func in self._postloop_hooks:
6867
func()
6968
self.postloop()

plugins/ext_test/setup.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,11 @@
22

33
import setuptools
44

5-
#
65
# get the long description from the README file
76
here = os.path.abspath(os.path.dirname(__file__))
87
with open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
98
long_description = f.read()
109

11-
# scm_version = {
12-
# 'root': '../..',
13-
# 'git_describe_command': "git describe --dirty --tags --long --match plugin-ext-test*",
14-
# }
15-
1610
PACKAGE_DATA = {
1711
'cmd2_ext_test': ['py.typed'],
1812
}

plugins/template/setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
import setuptools
44

5-
#
65
# get the long description from the README file
76
here = os.path.abspath(os.path.dirname(__file__))
87
with open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
98
long_description = f.read()
109

1110
setuptools.setup(
1211
name='cmd2-myplugin',
13-
# use_scm_version=True, # use_scm_version doesn't work if setup.py isn't in the repository root
12+
# use_scm_version=True, # use_scm_version doesn't work if setup.py isn't in the repository root # noqa: ERA001
1413
version='2.0.0',
1514
description='A template used to build plugins for cmd2',
1615
long_description=long_description,

plugins/template/tasks.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,19 @@ def wheel(context) -> None:
180180

181181
namespace.add_task(wheel)
182182

183-
#
183+
184184
# these two tasks are commented out so you don't
185185
# accidentally run them and upload this template to pypi
186186
#
187187

188188
# @invoke.task(pre=[sdist, wheel])
189189
# def pypi(context):
190190
# """Build and upload a distribution to pypi"""
191-
# context.run('twine upload dist/*')
192-
# namespace.add_task(pypi)
191+
# context.run('twine upload dist/*') # noqa: ERA001
192+
# namespace.add_task(pypi) # noqa: ERA001
193193

194194
# @invoke.task(pre=[sdist, wheel])
195195
# def pypi_test(context):
196-
# """Build and upload a distribution to https://test.pypi.org"""
197-
# context.run('twine upload --repository-url https://test.pypi.org/legacy/ dist/*')
198-
# namespace.add_task(pypi_test)
196+
# """Build and upload a distribution to https://test.pypi.org""" # noqa: ERA001
197+
# context.run('twine upload --repository-url https://test.pypi.org/legacy/ dist/*') # noqa: ERA001
198+
# namespace.add_task(pypi_test) # noqa: ERA001

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ select = [
173173
"DTZ", # flake8-datetimez (warn about datetime calls where no timezone is specified)
174174
"E", # pycodestyle errors (warn about major stylistic issues like mixing spaces and tabs)
175175
# "EM", # flake8-errmsg (warn about exceptions that use string literals that aren't assigned to a variable first)
176-
# "ERA", # eradicate (warn about commented-out code)
176+
"ERA", # eradicate (warn about commented-out code)
177177
"EXE", # flake8-executable (warn about files with a shebang present that aren't executable or vice versa)
178178
"F", # Pyflakes (a bunch of common warnings for things like unused imports, imports shadowed by variables, etc)
179179
"FA", # flake8-future-annotations (warn if certain from __future__ imports are used but missing)

tests/test_argparse_custom.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def test_apcustom_nargs_help_format(cust_app) -> None:
9393

9494

9595
def test_apcustom_nargs_range_validation(cust_app) -> None:
96-
# nargs = (3,)
96+
# nargs = (3,) # noqa: ERA001
9797
out, err = run_cmd(cust_app, 'range --arg2 one two')
9898
assert 'Error: argument --arg2: expected at least 3 arguments' in err[2]
9999

@@ -103,7 +103,7 @@ def test_apcustom_nargs_range_validation(cust_app) -> None:
103103
out, err = run_cmd(cust_app, 'range --arg2 one two three four')
104104
assert not err
105105

106-
# nargs = (2,3)
106+
# nargs = (2,3) # noqa: ERA001
107107
out, err = run_cmd(cust_app, 'range --arg3 one')
108108
assert 'Error: argument --arg3: expected 2 to 3 arguments' in err[2]
109109

tests/test_transcript.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ def do_speak(self, opts, arg) -> None:
7272
def do_mumble(self, opts, arg) -> None:
7373
"""Mumbles what you tell me to."""
7474
repetitions = opts.repeat or 1
75-
# arg = arg.split()
7675
for _ in range(min(repetitions, self.maxrepeats)):
7776
output = []
7877
if random.random() < 0.33:

0 commit comments

Comments
 (0)