Skip to content

Commit e26278b

Browse files
committed
Merge branch 'master' into 3.0.0
Thorny merge. What complicated it was the macro stuff being deleted in 3.0 but present in master.
2 parents 57d08e7 + 3eccbec commit e26278b

File tree

112 files changed

+2979
-3680
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+2979
-3680
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
- Breaking Change
1717
- `cmd2` 2.6 supports Python 3.9+ (removed support for Python 3.8)
18+
- Renamed methods in `cmd2.ansi.Cursor` to make it clear they are intended for internal use only as was documented
1819
- Enhancements
1920
- Add support for Python 3.14
2021

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ check: ## Run code quality tools.
1313
@echo "🚀 Static type checking: Running mypy"
1414
@uv run mypy
1515

16+
.PHONY: format
17+
format: ## Perform ruff formatting
18+
@uv run ruff format
19+
20+
.PHONY: lint
21+
lint: ## Perform ruff linting
22+
@uv run ruff check --fix
23+
24+
.PHONY: typecheck
25+
typecheck: ## Perform type checking
26+
@uv run mypy
27+
1628
.PHONY: test
1729
test: ## Test the code with pytest.
1830
@echo "🚀 Testing code: Running pytest"

cmd2/__init__.py

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
#
2-
# -*- coding: utf-8 -*-
3-
# flake8: noqa F401
41
"""This simply imports certain things for backwards compatibility."""
52

3+
import argparse
64
import importlib.metadata as importlib_metadata
5+
import sys
76

87
try:
98
__version__ = importlib_metadata.version(__name__)
109
except importlib_metadata.PackageNotFoundError: # pragma: no cover
1110
# package is not installed
1211
pass
1312

14-
from . import plugin
1513
from .ansi import (
1614
Bg,
1715
Cursor,
@@ -31,21 +29,20 @@
3129
register_argparse_argument_parameter,
3230
set_default_argument_parser_type,
3331
)
32+
33+
# Check if user has defined a module that sets a custom value for argparse_custom.DEFAULT_ARGUMENT_PARSER.
34+
# Do this before loading cmd2.Cmd class so its commands use the custom parser.
35+
cmd2_parser_module = getattr(argparse, 'cmd2_parser_module', None)
36+
if cmd2_parser_module is not None:
37+
import importlib
38+
39+
importlib.import_module(cmd2_parser_module)
40+
41+
from . import plugin
3442
from .cmd2 import Cmd
35-
from .command_definition import (
36-
CommandSet,
37-
with_default_category,
38-
)
39-
from .constants import (
40-
COMMAND_NAME,
41-
DEFAULT_SHORTCUTS,
42-
)
43-
from .decorators import (
44-
as_subcommand_to,
45-
with_argparser,
46-
with_argument_list,
47-
with_category,
48-
)
43+
from .command_definition import CommandSet, with_default_category
44+
from .constants import COMMAND_NAME, DEFAULT_SHORTCUTS
45+
from .decorators import as_subcommand_to, with_argparser, with_argument_list, with_category
4946
from .exceptions import (
5047
Cmd2ArgparseError,
5148
CommandSetRegistrationError,
@@ -55,12 +52,7 @@
5552
)
5653
from .parsing import Statement
5754
from .py_bridge import CommandResult
58-
from .utils import (
59-
CompletionMode,
60-
CustomCompletionSettings,
61-
Settable,
62-
categorize,
63-
)
55+
from .utils import CompletionMode, CustomCompletionSettings, Settable, categorize
6456

6557
__all__: list[str] = [
6658
'COMMAND_NAME',

0 commit comments

Comments
 (0)