Skip to content

Commit

Permalink
Merge branch 'master' into 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tleonhardt committed Nov 2, 2024
2 parents 5ce8407 + 0b4e8b0 commit 499d9ba
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4 # https://github.com/actions/checkout
- uses: actions/setup-python@v5 # https://github.com/actions/setup-python
- uses: actions/checkout@v4 # https://github.com/actions/checkout
- uses: actions/setup-python@v5 # https://github.com/actions/setup-python
with:
python-version: 3.13
allow-prereleases: true
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
See [custom_parser.py](https://github.com/python-cmd2/cmd2/blob/master/examples/custom_parser.py)
example for more details.

# 2.5.1 (November 2, 2024)
* Bug Fixes
* Fixed readline bug when using `ipy` command with `gnureadline` and Python 3.13

## 2.5.0 (October 23, 2024)
* Breaking Change
* `cmd2` 2.5 supports Python 3.8+ (removed support for Python 3.6 and 3.7)
Expand Down
17 changes: 14 additions & 3 deletions cmd2/cmd2.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@
StatementParser,
shlex_split,
)

# NOTE: When using gnureadline with Python 3.13, start_ipython needs to be imported before any readline-related stuff
try:
from IPython import start_ipython # type: ignore[import]
except ImportError:
pass

from .rl_utils import (
RlType,
rl_escape_prompt,
Expand Down Expand Up @@ -4331,9 +4338,13 @@ def do_ipy(self, _: argparse.Namespace) -> Optional[bool]: # pragma: no cover
# Detect whether IPython is installed
try:
import traitlets.config.loader as TraitletsLoader # type: ignore[import]
from IPython import ( # type: ignore[import]
start_ipython,
)

# Allow users to install ipython from a cmd2 prompt when needed and still have ipy command work
try:
start_ipython # noqa F823
except NameError:
from IPython import start_ipython # type: ignore[import]

from IPython.terminal.interactiveshell import ( # type: ignore[import]
TerminalInteractiveShell,
)
Expand Down
Empty file modified cmd2/parsing.py
100755 → 100644
Empty file.
6 changes: 3 additions & 3 deletions docs/features/prompt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ attribute. This contains the string which should be printed as a prompt
for user input. See the Pirate_ example for the simple use case of statically
setting the prompt.

.. _Pirate: https://github.com/python-cmd2/cmd2/blob/master/examples/pirate.py#L33
.. _Pirate: https://github.com/python-cmd2/cmd2/blob/master/examples/pirate.py#L39

Continuation Prompt
-------------------
Expand All @@ -24,7 +24,7 @@ subsequent lines of input is defined by the
:attr:`cmd2.Cmd.continuation_prompt` attribute.See the Initialization_ example
for a demonstration of customizing the continuation prompt.

.. _Initialization: https://github.com/python-cmd2/cmd2/blob/master/examples/initialization.py#L33
.. _Initialization: https://github.com/python-cmd2/cmd2/blob/master/examples/initialization.py#L42

Updating the prompt
-------------------
Expand All @@ -34,7 +34,7 @@ the :ref:`Application Lifecycle Hooks <features/hooks:Hooks>` such as a
:ref:`Postcommand hook <features/hooks:Postcommand Hooks>`. See
PythonScripting_ for an example of dynamically updating the prompt.

.. _PythonScripting: https://github.com/python-cmd2/cmd2/blob/master/examples/python_scripting.py#L34-L48
.. _PythonScripting: https://github.com/python-cmd2/cmd2/blob/master/examples/python_scripting.py#L38-L55

Asynchronous Feedback
---------------------
Expand Down
Empty file modified examples/argparse_completion.py
100644 → 100755
Empty file.
Empty file modified examples/default_categories.py
100644 → 100755
Empty file.
Empty file modified examples/modular_commands_basic.py
100644 → 100755
Empty file.
Empty file modified examples/modular_commands_dynamic.py
100644 → 100755
Empty file.
Empty file modified examples/modular_commands_main.py
100644 → 100755
Empty file.
Empty file modified examples/modular_subcommands.py
100644 → 100755
Empty file.
Empty file modified examples/read_input.py
100644 → 100755
Empty file.
10 changes: 10 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,13 @@ def format(context):


namespace.add_task(format)


@invoke.task()
def ruff_clean(context):
"""Remove .ruff_cache directory"""
with context.cd(TASK_ROOT_STR):
context.run("ruff clean")


namespace_clean.add_task(ruff_clean, 'ruff')

0 comments on commit 499d9ba

Please sign in to comment.