Skip to content

Commit 6d00a49

Browse files
committed
Bunch of random clenaups and fixes
1 parent 4049c1d commit 6d00a49

38 files changed

+13
-78
lines changed

cmd2/argparse_custom.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ def _ArgumentParser_check_value(self: argparse.ArgumentParser, action: argparse.
977977
############################################################################################################
978978

979979

980-
def _SubParsersAction_remove_parser(self: argparse._SubParsersAction, name: str) -> None: # type: ignore
980+
def _SubParsersAction_remove_parser(self: argparse._SubParsersAction, name: str) -> None: # type: ignore[type-arg]
981981
"""
982982
Removes a sub-parser from a sub-parsers group. Used to remove subcommands from a parser.
983983
@@ -1289,7 +1289,7 @@ def __init__(
12891289

12901290
self.set_ap_completer_type(ap_completer_type) # type: ignore[attr-defined]
12911291

1292-
def add_subparsers(self, **kwargs: Any) -> argparse._SubParsersAction: # type: ignore
1292+
def add_subparsers(self, **kwargs: Any) -> argparse._SubParsersAction: # type: ignore[type-arg]
12931293
"""
12941294
Custom override. Sets a default title if one was not given.
12951295

cmd2/cmd2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4599,7 +4599,7 @@ def do_ipy(self, _: argparse.Namespace) -> Optional[bool]: # pragma: no cover
45994599

46004600
# Allow users to install ipython from a cmd2 prompt when needed and still have ipy command work
46014601
try:
4602-
start_ipython # noqa F823
4602+
start_ipython # noqa: F823
46034603
except NameError:
46044604
from IPython import start_ipython # type: ignore[import]
46054605

@@ -4636,7 +4636,7 @@ def do_ipy(self, _: argparse.Namespace) -> Optional[bool]: # pragma: no cover
46364636
local_vars['self'] = self
46374637

46384638
# Configure IPython
4639-
config = TraitletsLoader.Config() # type: ignore
4639+
config = TraitletsLoader.Config()
46404640
config.InteractiveShell.banner2 = (
46414641
'Entering an IPython shell. Type exit, quit, or Ctrl-D to exit.\n'
46424642
f'Run CLI commands with: {self.py_bridge_name}("command ...")\n'

cmd2/constants.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#
21
"""This module contains constants used throughout ``cmd2``."""
32

43
# Unless documented in https://cmd2.readthedocs.io/en/latest/api/index.html

cmd2/parsing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#
21
"""Statement parsing classes for cmd2"""
32

43
import re

cmd2/plugin.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#
21
"""Classes for the cmd2 plugin system"""
32

43
from dataclasses import (

cmd2/transcript.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#
21
"""Machinery for running and validating transcripts.
32
43
If the user wants to run a transcript (see docs/transcript.rst),

examples/modular_commands/commandset_complex.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa E302
31
"""
42
Test CommandSet
53
"""

examples/override_parser.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/usr/bin/env python
2-
# coding=utf-8
3-
# flake8: noqa F402
42
"""
53
The standard parser used by cmd2 built-in commands is Cmd2ArgumentParser.
64
The following code shows how to override it with your own parser class.

examples/scripts/conditional.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa F821
31
"""
42
This is a Python script intended to be used with the "python_scripting.py" cmd2 example application.
53

examples/scripts/save_help_text.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa F821
31
"""
42
A cmd2 script that saves the help text for every command, subcommand, and topic to a file.
53
This is meant to be run within a cmd2 session using run_pyscript.
@@ -29,9 +27,7 @@ def get_sub_commands(parser: argparse.ArgumentParser) -> List[str]:
2927
sub_cmds.append(sub_cmd)
3028

3129
# Look for nested subcommands
32-
for nested_sub_cmd in get_sub_commands(sub_cmd_parser):
33-
sub_cmds.append('{} {}'.format(sub_cmd, nested_sub_cmd))
34-
30+
sub_cmds.extend(f'{sub_cmd} {nested_sub_cmd}' for nested_sub_cmd in get_sub_commands(sub_cmd_parser))
3531
break
3632

3733
sub_cmds.sort()

plugins/tasks.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#
2-
# coding=utf-8
3-
# flake8: noqa E302
41
"""Development related tasks to be run with 'invoke'.
52
63
Make sure you satisfy the following Python module requirements if you are trying to publish a release to PyPI:
@@ -147,7 +144,7 @@ def lint(context):
147144

148145
# ruff formatter
149146
@invoke.task(pre=[ext_test_tasks.format])
150-
def format(context):
147+
def format(context): # noqa: A001
151148
"""Run formatter"""
152149
with context.cd(TASK_ROOT_STR):
153150
context.run("ruff format --check")

pyproject.toml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ select = [
193193
"NPY", # NumPy specific rules
194194
"PD", # pandas-vet (Pandas specific rules)
195195
"PERF", # Perflint (warn about performance issues)
196-
# "PGH", # pygrep-hooks (force specific rule codes when ignoring type or linter issues on a line)
196+
# "PGH", # pygrep-hooks (force specific rule codes when ignoring type or linter issues on a line)
197197
# "PIE", # flake8-pie (eliminate unnecessary use of pass, range starting at 0, etc.)
198198
"PLC", # Pylint Conventions
199199
"PLE", # Pylint Errors
@@ -270,16 +270,13 @@ per-file-ignores."examples/unicode_commands.py" = [
270270
"PLC2401", # non-ASCII characters in function names
271271
]
272272

273-
per-file-ignores."plugins/ext_test/*.py" = [
274-
"INP001", # Module is part of an implicit namespace
275-
]
276-
277-
per-file-ignores."plugins/template/*.py" = [
273+
per-file-ignores."plugins/*.py" = [
278274
"INP001", # Module is part of an implicit namespace
279275
]
280276

281277
per-file-ignores."tests/pyscript/*.py" = [
282-
"F821", # Undefined name `app`
278+
"F821", # Undefined name `app`
279+
"INP001", # Module is part of an implicit namespace
283280
]
284281

285282
per-file-ignores."tests/pyscript/raises_exception.py" = [

tasks.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#
2-
# coding=utf-8
3-
# flake8: noqa E302
41
"""Development related tasks to be run with 'invoke'.
52
63
Make sure you satisfy the following Python module requirements if you are trying to publish a release to PyPI:
@@ -74,8 +71,8 @@ def pytest(context, junit=False, pty=True, base=False, isolated=False):
7471
context.run(tests_cmd, pty=pty)
7572
if isolated:
7673
for root, dirnames, _ in os.walk(str(TASK_ROOT / 'tests_isolated')):
77-
for dir in dirnames:
78-
if dir.startswith('test_'):
74+
for dir_name in dirnames:
75+
if dir_name.startswith('test_'):
7976
context.run(command_str + ' tests_isolated/' + dir)
8077

8178

@@ -235,7 +232,7 @@ def lint(context):
235232

236233
# ruff fast formatter
237234
@invoke.task()
238-
def format(context):
235+
def format(context): # noqa: A001
239236
"""Run ruff format --check"""
240237
with context.cd(TASK_ROOT_STR):
241238
context.run("ruff format --check")

tests/pyscript/echo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# flake8: noqa F821
21
# Tests echo argument to app()
32
app.cmd_echo = False
43

tests/pyscript/environment.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# flake8: noqa F821
21
# Tests that cmd2 populates __name__, __file__, and sets sys.path[0] to our directory
32
import os
43
import sys

tests/pyscript/help.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# flake8: noqa F821
21
app.cmd_echo = True
32
app('help')
43

tests/pyscript/py_locals.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# flake8: noqa F821
21
# Tests how much a pyscript can affect cmd2.Cmd.py_locals
32

43
del [locals()["test_var"]]

tests/pyscript/pyscript_dir.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# flake8: noqa F821
21
out = dir(app)
32
out.sort()
43
print(out)

tests/pyscript/recursive.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#!/usr/bin/env python
2-
# coding=utf-8
3-
# flake8: noqa F821
41
"""
52
Example demonstrating that calling run_pyscript recursively inside another Python script isn't allowed
63
"""

tests/pyscript/self_in_py.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# flake8: noqa F821
21
# Tests self_in_py in pyscripts
32
if 'self' in globals():
43
print("I see self")

tests/pyscript/stdout_capture.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# flake8: noqa F821
21
# This script demonstrates when output of a command finalization hook is captured by a pyscript app() call
32
import sys
43

tests/pyscript/stop.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# flake8: noqa F821
21
app.cmd_echo = True
32
app('help')
43

tests/test_ansi.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa E302
31
"""
42
Unit testing for cmd2/ansi.py module
53
"""

tests/test_argparse.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa E302
31
"""
42
Cmd2 testing for argument parsing
53
"""

tests/test_argparse_completer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa E302
31
"""
42
Unit/functional testing for argparse completer in cmd2
53
"""

tests/test_argparse_custom.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# flake8: noqa E302
21
"""
32
Unit/functional testing for argparse customizations in cmd2
43
"""

tests/test_cmd2.py

100755100644
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa E302
31
"""
42
Cmd2 unit/functional testing
53
"""

tests/test_completion.py

100755100644
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa E302
31
"""
42
Unit/functional testing for readline tab completion functions in the cmd2.py module.
53

tests/test_history.py

100755100644
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa E302
31
"""
42
Test history functions of cmd2
53
"""

tests/test_parsing.py

100755100644
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa E302
31
"""
42
Test the parsing logic in parsing.py
53
"""

tests/test_plugin.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa E302
31
"""
42
Test plugin infrastructure and hooks.
53
"""

tests/test_run_pyscript.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa E302
31
"""
42
Unit/functional testing for run_pytest in cmd2
53
"""

tests/test_table_creator.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa E501
31
"""
42
Unit testing for cmd2/table_creator.py module
53
"""

tests/test_transcript.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa E302
31
"""
42
Cmd2 functional testing based on transcript
53
"""

tests/test_utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa E302
31
"""
42
Unit testing for cmd2/utils.py module.
53
"""

tests/test_utils_defining_class.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa E302
31
"""
42
Unit testing for get_defining_class in cmd2/utils.py module.
53
"""

tests_isolated/test_commandset/test_argparse_subcommands.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa E302
31
"""
42
reproduces test_argparse.py except with SubCommands
53
"""

tests_isolated/test_commandset/test_commandset.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding=utf-8
2-
# flake8: noqa E302
31
"""
42
Test CommandSet
53
"""

0 commit comments

Comments
 (0)