Skip to content

Commit ae04629

Browse files
committed
Removed support for Python 3.7 and added unit testing for 3.12.
1 parent 5ee1f15 commit ae04629

File tree

23 files changed

+75
-96
lines changed

23 files changed

+75
-96
lines changed

.github/CONTRIBUTING.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ We welcome pull requests from cmd2 users and seasoned Python developers alike! F
1010

1111
Remember to feel free to ask for help by leaving a comment within the Issue.
1212

13-
Working on your first pull request? You can learn how from this *free* series
13+
Working on your first pull request? You can learn how from this *free* series
1414
[How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
1515

1616
###### If you've found a bug that is not on the board, [follow these steps](README.md#found-a-bug).
@@ -47,7 +47,7 @@ The tables below list all prerequisites along with the minimum required version
4747

4848
| Prerequisite | Minimum Version |
4949
| --------------------------------------------------- |-----------------|
50-
| [python](https://www.python.org/downloads/) | `3.7` |
50+
| [python](https://www.python.org/downloads/) | `3.8` |
5151
| [pyperclip](https://github.com/asweigart/pyperclip) | `1.6` |
5252
| [setuptools](https://pypi.org/project/setuptools/) | `34.4` |
5353
| [wcwidth](https://pypi.python.org/pypi/wcwidth) | `0.1.7` |
@@ -81,32 +81,32 @@ $ pip freeze | grep pyperclip
8181

8282
If your versions are lower than the prerequisite versions, you should update.
8383

84-
If you do not already have Python installed on your machine, we recommend using the
85-
[Anaconda](https://www.continuum.io/downloads) distribution because it provides an excellent out-of-the-box install on
86-
all platforms (Windows, Mac, and Linux) and because it supports having multiple Python environments (versions of Python)
84+
If you do not already have Python installed on your machine, we recommend using the
85+
[Anaconda](https://www.continuum.io/downloads) distribution because it provides an excellent out-of-the-box install on
86+
all platforms (Windows, Mac, and Linux) and because it supports having multiple Python environments (versions of Python)
8787
installed simultaneously.
8888

8989
### Forking the project
9090

9191
#### Setting up your system
9292

93-
1. Install [Git](https://git-scm.com/) or your favorite Git client. If you aren't comfortable with Git at the
94-
command-line, then both [SmartGit](http://www.syntevo.com/smartgit/) and [GitKraken](https://www.gitkraken.com) are
93+
1. Install [Git](https://git-scm.com/) or your favorite Git client. If you aren't comfortable with Git at the
94+
command-line, then both [SmartGit](http://www.syntevo.com/smartgit/) and [GitKraken](https://www.gitkraken.com) are
9595
excellent cross-platform graphical Git clients.
9696
2. (Optional) [Set up an SSH key](https://help.github.com/articles/generating-an-ssh-key/) for GitHub.
9797
3. Create a parent projects directory on your system. For this guide, it will be assumed that it is `~/src`.
9898

9999
#### Forking cmd2
100100

101101
1. Go to the top-level cmd2 repository: <https://github.com/python-cmd2/cmd2>
102-
2. Click the "Fork" button in the upper right hand corner of the interface
102+
2. Click the "Fork" button in the upper right hand corner of the interface
103103
([more details here](https://help.github.com/articles/fork-a-repo/))
104104
3. After the repository has been forked, you will be taken to your copy of the cmd2 repo at `yourUsername/cmd2`
105105

106106
#### Cloning your fork
107107

108108
1. Open a terminal / command line / Bash shell in your projects directory (_e.g.: `~/src/`_)
109-
2. Clone your fork of cmd2, making sure to replace `yourUsername` with your GitHub username. This will download the
109+
2. Clone your fork of cmd2, making sure to replace `yourUsername` with your GitHub username. This will download the
110110
entire cmd2 repo to your projects directory.
111111

112112
```sh
@@ -164,13 +164,13 @@ Do this prior to every time you create a branch for a PR:
164164
165165
### Creating a branch
166166
167-
Before you start working, you will need to create a separate branch specific to the issue or feature you're working on.
167+
Before you start working, you will need to create a separate branch specific to the issue or feature you're working on.
168168
You will push your work to this branch.
169169
170170
#### Naming your branch
171171
172-
Name the branch something like `fix/xxx` or `feature/xxx` where `xxx` is a short description of the changes or feature
173-
you are attempting to add. For example `fix/script-files` would be a branch where you fix something specific to script
172+
Name the branch something like `fix/xxx` or `feature/xxx` where `xxx` is a short description of the changes or feature
173+
you are attempting to add. For example `fix/script-files` would be a branch where you fix something specific to script
174174
files.
175175
176176
#### Adding your branch
@@ -191,22 +191,22 @@ $ git push origin [name_of_your_new_branch]
191191

192192

193193
### Setting up for cmd2 development
194-
For doing cmd2 development, it is recommended you create a virtual environment using Conda or Virtualenv and install the
194+
For doing cmd2 development, it is recommended you create a virtual environment using Conda or Virtualenv and install the
195195
package from the source.
196196

197197
#### Create a new environment for cmd2 using Pipenv
198-
`cmd2` has support for using [Pipenv](https://docs.pipenv.org/en/latest/) for development.
198+
`cmd2` has support for using [Pipenv](https://docs.pipenv.org/en/latest/) for development.
199199

200200
`Pipenv` essentially combines the features of `pip` and `virtualenv` into a single tool. `cmd2` contains a Pipfile which
201-
makes it extremely easy to setup a `cmd2` development environment using `pipenv`.
201+
makes it extremely easy to setup a `cmd2` development environment using `pipenv`.
202202

203-
To create a virtual environment and install everything needed for `cmd2` development using `pipenv`, do the following
203+
To create a virtual environment and install everything needed for `cmd2` development using `pipenv`, do the following
204204
from a GitHub checkout:
205205
```sh
206206
pipenv install --dev
207207
```
208208

209-
To create a new virtualenv, using a specific version of Python you have installed (and on your PATH), use the
209+
To create a new virtualenv, using a specific version of Python you have installed (and on your PATH), use the
210210
--python VERSION flag, like so:
211211
```sh
212212
pipenv install --dev --python 3.8
@@ -219,8 +219,8 @@ pipenv shell
219219

220220
#### Create a new environment for cmd2 using Conda
221221
```sh
222-
$ conda create -n cmd2_py37 python=3.7
223-
$ conda activate cmd2_py37
222+
$ conda create -n cmd2_py38 python=3.8
223+
$ conda activate cmd2_py38
224224
```
225225

226226
#### Create a new environment for cmd using Virtualenv
@@ -233,15 +233,15 @@ pyenv versions
233233
# Install python version defined
234234
pyenv install 3.8.2
235235
```
236-
With the Python version installed, you can set the virtualenv properly.
236+
With the Python version installed, you can set the virtualenv properly.
237237

238238
```sh
239239
$ cd ~/src/cmd2
240-
$ virtualenv -p $(pyenv root)/versions/3.8.2/ cmd_py38
240+
$ virtualenv -p $(pyenv root)/versions/3.8.2/ cmd_py38
241241
$ source ~/src/cmd2/bin/activate
242242
```
243243

244-
Assuming you cloned the repository to `~/src/cmd2` you can install cmd2 in
244+
Assuming you cloned the repository to `~/src/cmd2` you can install cmd2 in
245245
[editable mode](https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs).
246246
Changes to the source code are immediately available when the python interpreter
247247
imports `cmd2`, there is no need to re-install the module after every change. This
@@ -326,9 +326,9 @@ served (usually [http://localhost:8000](http://localhost:8000)).
326326

327327
### Static code analysis
328328

329-
You should have some sort of [PEP 8](https://www.python.org/dev/peps/pep-0008/)-based linting running in your editor or
329+
You should have some sort of [PEP 8](https://www.python.org/dev/peps/pep-0008/)-based linting running in your editor or
330330
IDE or at the command line before you commit code. `cmd2` uses [flake8](http://flake8.pycqa.org/en/latest/) as part of
331-
its continuous integration (CI) process. [pylint](https://www.pylint.org) is another good Python linter which can be
331+
its continuous integration (CI) process. [pylint](https://www.pylint.org) is another good Python linter which can be
332332
run at the command line but also can integrate with many IDEs and editors.
333333

334334
> Please do not ignore any linting errors in code you write or modify, as they are meant to **help** you and to ensure a clean and simple code base. Don't worry about linting errors in code you don't touch though - cleaning up the legacy code is a work in progress.
@@ -579,7 +579,7 @@ mostly automated. The manual steps are all git operations. Here's the checklist:
579579
1. Make sure all the unit tests pass with `invoke pytest` or `py.test`
580580
1. Make sure latest year in `LICENSE` matches current year
581581
1. Make sure `CHANGELOG.md` describes the version and has the correct release date
582-
1. Add a git tag representing the version number using ``invoke tag x.y.z``
582+
1. Add a git tag representing the version number using ``invoke tag x.y.z``
583583
* Where x, y, and z are all small non-negative integers
584584
1. (Optional) Run `invoke pypi-test` to clean, build, and upload a new release to [Test PyPi](https://test.pypi.org)
585585
1. Run `invoke pypi` to clean, build, and upload a new release to [PyPi](https://pypi.org/)

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ubuntu-latest, macos-latest, windows-latest]
12-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
12+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
1313
fail-fast: false
1414
runs-on: ${{ matrix.os }}
1515
steps:

.github/workflows/doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ubuntu-latest]
15-
python-version: ["3.11"]
15+
python-version: ["3.12"]
1616
fail-fast: false
1717
runs-on: ${{ matrix.os }}
1818
steps:

.github/workflows/format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ubuntu-latest]
15-
python-version: ["3.11"]
15+
python-version: ["3.12"]
1616
fail-fast: false
1717
runs-on: ${{ matrix.os }}
1818
steps:

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ubuntu-latest]
15-
python-version: ["3.11"]
15+
python-version: ["3.12"]
1616
fail-fast: false
1717
runs-on: ${{ matrix.os }}
1818
steps:

.github/workflows/mypy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ubuntu-latest]
15-
python-version: ["3.11"]
15+
python-version: ["3.12"]
1616
fail-fast: false
1717
runs-on: ${{ matrix.os }}
1818
steps:

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
## 2.5.0 (TBD)
22
* Breaking Change
3-
* `cmd2` 2.5 supports Python 3.7+ (removed support for Python 3.6)
3+
* `cmd2` 2.5 supports Python 3.8+ (removed support for Python 3.6 and 3.7)
44
* Bug Fixes
55
* Fixed issue where persistent history file was not saved upon SIGHUP and SIGTERM signals.
66
* Enhancements
77
* Removed dependency on `attrs` and replaced with [dataclasses](https://docs.python.org/3/library/dataclasses.html)
88
* add `allow_clipboard` initialization parameter and attribute to disable ability to
99
add output to the operating system clipboard
10+
* Updated unit tests to be Python 3.12 compliant.
1011
* Deletions (potentially breaking changes)
1112
* Removed `apply_style` from `Cmd.pwarning()`.
1213

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ The developers toolbox
3232
![system schema](https://raw.githubusercontent.com/python-cmd2/cmd2/master/.github/images/graph.drawio.png)
3333

3434

35-
When creating solutions developers have no shortage of tools to create rich and smart user interfaces.
36-
System administrators have long been duct taping together brittle workflows based on a menagerie of simple command line tools created by strangers on github and the guy down the hall.
37-
Unfortunately, when CLIs become significantly complex the ease of command discoverability tends to fade quickly.
38-
On the other hand, Web and traditional desktop GUIs are first in class when it comes to easily discovering functionality.
35+
When creating solutions developers have no shortage of tools to create rich and smart user interfaces.
36+
System administrators have long been duct taping together brittle workflows based on a menagerie of simple command line tools created by strangers on github and the guy down the hall.
37+
Unfortunately, when CLIs become significantly complex the ease of command discoverability tends to fade quickly.
38+
On the other hand, Web and traditional desktop GUIs are first in class when it comes to easily discovering functionality.
3939
The price we pay for beautifully colored displays is complexity required to aggregate disperate applications into larger systems.
40-
`cmd2` fills the niche between high [ease of command discovery](https://clig.dev/#ease-of-discovery) applications and smart workflow automation systems.
40+
`cmd2` fills the niche between high [ease of command discovery](https://clig.dev/#ease-of-discovery) applications and smart workflow automation systems.
4141

42-
The `cmd2` framework provides a great mixture of both worlds. Application designers can easily create complex applications and rely on the cmd2 library to offer effortless user facing help and extensive tab completion.
42+
The `cmd2` framework provides a great mixture of both worlds. Application designers can easily create complex applications and rely on the cmd2 library to offer effortless user facing help and extensive tab completion.
4343
When users become comfortable with functionality, cmd2 turns into a feature rich library enabling a smooth transition to full automation. If designed with enough forethought, a well implemented cmd2 application can serve as a boutique workflow tool. `cmd2` pulls off this flexibility based on two pillars of philosophy:
4444

4545
* Tab Completion
@@ -78,7 +78,7 @@ On all operating systems, the latest stable version of `cmd2` can be installed u
7878
pip install -U cmd2
7979
```
8080

81-
cmd2 works with Python 3.7+ on Windows, macOS, and Linux. It is pure Python code with few 3rd-party dependencies.
81+
cmd2 works with Python 3.8+ on Windows, macOS, and Linux. It is pure Python code with few 3rd-party dependencies.
8282

8383
For information on other installation options, see
8484
[Installation Instructions](https://cmd2.readthedocs.io/en/latest/overview/installation.html) in the cmd2
@@ -97,7 +97,7 @@ The best way to learn the cmd2 api is to delve into the example applications loc
9797
Tutorials
9898
---------
9999

100-
* PyOhio 2019 presentation:
100+
* PyOhio 2019 presentation:
101101
* [video](https://www.youtube.com/watch?v=pebeWrTqIIw)
102102
* [slides](https://github.com/python-cmd2/talks/blob/master/PyOhio_2019/cmd2-PyOhio_2019.pdf)
103103
* [example code](https://github.com/python-cmd2/talks/tree/master/PyOhio_2019/examples)
@@ -161,4 +161,4 @@ Projects using cmd2
161161
Possibly defunct but still good examples
162162

163163
* [JSShell](https://github.com/Den1al/JSShell)
164-
* [FLASHMINGO](https://github.com/fireeye/flashmingo)
164+
* [FLASHMINGO](https://github.com/fireeye/flashmingo)

cmd2/argparse_custom.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,10 @@ def my_completer(self, text, line, begidx, endidx, arg_tokens)
270270
constants,
271271
)
272272

273-
try:
274-
from typing import (
275-
Protocol,
276-
runtime_checkable,
277-
)
278-
except ImportError:
279-
# Remove these imports when we no longer support Python 3.7
280-
from typing_extensions import ( # type: ignore[assignment]
281-
Protocol,
282-
runtime_checkable,
283-
)
273+
from typing import (
274+
Protocol,
275+
runtime_checkable,
276+
)
284277

285278

286279
if TYPE_CHECKING: # pragma: no cover

docs/features/argument_processing.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ Here's what it looks like::
7878
.. warning::
7979

8080
It is important that each command which uses the ``@with_argparser``
81-
decorator be passed a unique instance of a parser. This limitation is due
82-
to bugs in CPython prior to Python 3.7 which make it impossible to make a
83-
deep copy of an instance of a ``argparse.ArgumentParser``.
81+
decorator be passed a unique instance of a parser since command-specific
82+
changes could be made to it.
8483

8584

8685
.. note::

docs/overview/installation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Installation Instructions
77
.. _setuptools: https://pypi.org/project/setuptools
88
.. _PyPI: https://pypi.org
99

10-
``cmd2`` works on Linux, macOS, and Windows. It requires Python 3.7 or
10+
``cmd2`` works on Linux, macOS, and Windows. It requires Python 3.8 or
1111
higher, pip_, and setuptools_. If you've got all that, then you can just:
1212

1313
.. code-block:: shell
@@ -30,7 +30,7 @@ higher, pip_, and setuptools_. If you've got all that, then you can just:
3030
Prerequisites
3131
-------------
3232

33-
If you have Python 3 >=3.7 installed from `python.org
33+
If you have Python 3 >=3.8 installed from `python.org
3434
<https://www.python.org>`_, you will already have pip_ and setuptools_, but may
3535
need to upgrade to the latest versions:
3636

noxfile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import nox
22

33

4-
@nox.session(python=['3.11'])
4+
@nox.session(python=['3.12'])
55
def docs(session):
66
session.install(
77
'sphinx',
@@ -17,7 +17,7 @@ def docs(session):
1717
)
1818

1919

20-
@nox.session(python=['3.7', '3.8', '3.9', '3.10', '3.11'])
20+
@nox.session(python=['3.8', '3.9', '3.10', '3.11', '3.12'])
2121
@nox.parametrize('plugin', [None, 'ext_test', 'template', 'coverage'])
2222
def tests(session, plugin):
2323
if plugin is None:
@@ -41,7 +41,7 @@ def tests(session, plugin):
4141
)
4242

4343

44-
@nox.session(python=['3.8', '3.9', '3.10', '3.11'])
44+
@nox.session(python=['3.8', '3.9', '3.10', '3.11', '3.12'])
4545
@nox.parametrize('step', ['mypy', 'flake8'])
4646
def validate(session, step):
4747
session.install('invoke', './[validate]')

plugins/ext_test/build-pyenvs.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# version numbers are: major.minor.patch
99
#
1010
# this script will delete and recreate existing virtualenvs named
11-
# cmd2-3.7, etc. It will also create a .python-version
11+
# cmd2-3.8, etc. It will also create a .python-version
1212
#
1313
# Prerequisites:
1414
# - *nix-ish environment like macOS or Linux
@@ -23,7 +23,7 @@
2323
# virtualenvs will be added to '.python-version'. Feel free to modify
2424
# this list, but note that this script intentionally won't install
2525
# dev, rc, or beta python releases
26-
declare -a pythons=("3.7" "3.8" "3.9", "3.10", "3.11")
26+
declare -a pythons=("3.8" "3.9", "3.10", "3.11", "3.12")
2727

2828
# function to find the latest patch of a minor version of python
2929
function find_latest_version {

plugins/ext_test/cmd2_ext_test/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@
55
Allows developers to exercise their cmd2 application using the PyScript interface
66
"""
77

8-
try:
9-
# For python 3.8 and later
10-
import importlib.metadata as importlib_metadata
11-
except ImportError: # pragma: no cover
12-
# Remove this import when we no longer support Python 3.7
13-
# MyPy Issue # 1153 causes a spurious error that must be ignored
14-
import importlib_metadata # type: ignore
8+
import importlib.metadata as importlib_metadata
159

1610
try:
1711
__version__ = importlib_metadata.version(__name__)

plugins/ext_test/noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import nox
22

33

4-
@nox.session(python=['3.7', '3.8', '3.9', '3.10', '3.11'])
4+
@nox.session(python=['3.8', '3.9', '3.10', '3.11', '3.12'])
55
def tests(session):
66
session.install('invoke', './[test]')
77
session.run('invoke', 'pytest', '--junit', '--no-pty')

0 commit comments

Comments
 (0)