Skip to content

Commit db27195

Browse files
committed
Merge branch '3.0.0' into rich_phase_1
2 parents 7d70dc5 + 83fbadc commit db27195

File tree

16 files changed

+179
-91
lines changed

16 files changed

+179
-91
lines changed

.github/CONTRIBUTING.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ $ pip freeze | grep pyperclip
8989

9090
If your versions are lower than the prerequisite versions, you should update.
9191

92-
If you do not already have Python installed on your machine, we recommend using [uv](https://github.com/astral-sh/uv)
92+
If you do not already have Python installed on your machine, we recommend using [uv](https://github.com/astral-sh/uv)
9393
for all of your Python needs because it is extremely fast, meets all Python installation and packaging needs, and works
9494
on all platforms (Windows, Mac, and Linux). You can install `uv` using instructions at the link above.
9595

@@ -222,7 +222,13 @@ To create a virtual environment and install everything needed for `cmd2` develop
222222
from a GitHub checkout:
223223

224224
```sh
225-
uv venv
225+
make install
226+
```
227+
228+
To install the recommended Git pre-commit hooks for auto-formatting locally, do the following:
229+
230+
```sh
231+
uv run pre-commit run -a
226232
```
227233

228234
To create a new virtualenv, using a specific version of Python you have installed, use the

.github/workflows/doc.yml

Lines changed: 6 additions & 6 deletions
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.12"]
15+
python-version: ["3.13"]
1616
fail-fast: false
1717
runs-on: ${{ matrix.os }}
1818
steps:
@@ -21,11 +21,11 @@ jobs:
2121
# Only a single commit is fetched by default, for the ref/SHA that triggered the workflow.
2222
# Set fetch-depth: 0 to fetch all history for all branches and tags.
2323
fetch-depth: 0 # Needed for setuptools_scm to work correctly
24-
- name: Set up Python
25-
uses: actions/setup-python@v5 # https://github.com/actions/setup-python
24+
- name: Install uv and set the python version
25+
uses: astral-sh/setup-uv@v5
2626
with:
2727
python-version: ${{ matrix.python-version }}
28-
- name: Install python prerequisites
29-
run: pip install -U --user pip setuptools setuptools-scm griffe_typingdoc mkdocs-include-markdown-plugin mkdocs-macros-plugin mkdocs-material mkdocstrings[python] . plugins/ext_test
28+
- name: Install the project
29+
run: uv sync --group docs
3030
- name: MkDocs documentation build
31-
run: mkdocs build
31+
run: uv run mkdocs build -s

.github/workflows/format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ jobs:
1616
# Only a single commit is fetched by default, for the ref/SHA that triggered the workflow.
1717
# Set fetch-depth: 0 to fetch all history for all branches and tags.
1818
fetch-depth: 0 # Needed for setuptools_scm to work correctly
19-
- run: pip install --user ruff
19+
- uses: astral-sh/ruff-action@v3
2020
- run: ruff format --check

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ jobs:
1616
# Only a single commit is fetched by default, for the ref/SHA that triggered the workflow.
1717
# Set fetch-depth: 0 to fetch all history for all branches and tags.
1818
fetch-depth: 0 # Needed for setuptools_scm to work correctly
19-
- run: pip install --user ruff
19+
- uses: astral-sh/ruff-action@v3
2020
- run: ruff check --output-format=github .

.github/workflows/mypy.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v4 # https://github.com/actions/checkout
15-
- uses: actions/setup-python@v5 # https://github.com/actions/setup-python
1615
with:
17-
python-version: 3.13
18-
allow-prereleases: true
1916
# Only a single commit is fetched by default, for the ref/SHA that triggered the workflow.
2017
# Set fetch-depth: 0 to fetch all history for all branches and tags.
2118
fetch-depth: 0 # Needed for setuptools_scm to work correctly
22-
- run: pip install -U --user pip mypy pyperclip rich rich-argparse wcwidth
23-
- run: mypy .
19+
- name: Install uv and set the python version
20+
uses: astral-sh/setup-uv@v5
21+
with:
22+
python-version: 3.13
23+
- name: Install the project
24+
run: uv sync --group validate
25+
- name: Run mypy static type checker
26+
run: uv run mypy .

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ uv.lock
5454
# Node/npm used for installing Prettier locally to override the outdated version that is bundled with the VSCode extension
5555
node_modules/
5656
package-lock.json
57-
package.json
57+
package.json

.pre-commit-config.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: "v5.0.0"
4+
hooks:
5+
- id: check-case-conflict
6+
- id: check-merge-conflict
7+
- id: end-of-file-fixer
8+
- id: trailing-whitespace
9+
10+
- repo: https://github.com/astral-sh/ruff-pre-commit
11+
rev: "v0.9.2"
12+
hooks:
13+
- id: ruff-format
14+
args: [--config=pyproject.toml]
15+
16+
- repo: https://github.com/pre-commit/mirrors-prettier
17+
rev: "v3.1.0"
18+
hooks:
19+
- id: prettier
20+
additional_dependencies:
21+
- prettier@3.4.2
22+
- prettier-plugin-toml@2.0.1

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Markdown documentation files with non-standards syntax for mkdocstrings that Prettier should not auto-format
2-
docs/features/initialization.md
2+
docs/features/initialization.md

.readthedocs.yaml

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,23 @@
44
# Required
55
version: 2
66

7-
# Set the OS, Python version and other tools you might need
8-
build:
9-
os: ubuntu-24.04
10-
tools:
11-
python: "3"
12-
13-
# Build documentation in the "docs/" directory with MkDocs
14-
mkdocs:
15-
configuration: mkdocs.yml
16-
177
# Optionally build your docs in additional formats such as PDF and ePub
188
# formats:
199
# - pdf
2010
# - epub
2111
formats: all
2212

23-
# Optional but recommended, declare the Python requirements required to build your documentation
24-
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
25-
python:
26-
install:
27-
- method: pip
28-
path: .
29-
extra_requirements:
30-
- docs
13+
# Build documentation in the "docs/" directory with MkDocs
14+
mkdocs:
15+
configuration: mkdocs.yml
16+
17+
# Set the OS, Python version and other tools you might need
18+
build:
19+
os: ubuntu-24.04
20+
tools:
21+
python: "3.13"
22+
jobs:
23+
install:
24+
- pip install .
25+
- pip install dependency-groups
26+
- pip-install-dependency-groups docs

Makefile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Simple Makefile for use with a uv-based development environment
2+
.PHONY: install
3+
install: ## Install the virtual environment
4+
@echo "🚀 Creating virtual environment"
5+
@uv sync
6+
7+
.PHONY: check
8+
check: ## Run code quality tools.
9+
@echo "🚀 Checking lock file consistency with 'pyproject.toml'"
10+
@uv lock --locked
11+
@echo "🚀 Linting code: Running pre-commit"
12+
@uv run pre-commit run -a
13+
@echo "🚀 Static type checking: Running mypy"
14+
@uv run mypy
15+
16+
.PHONY: test
17+
test: ## Test the code with pytest.
18+
@echo "🚀 Testing code: Running pytest"
19+
@uv run python -m pytest --cov --cov-config=pyproject.toml --cov-report=xml tests
20+
@uv run python -m pytest --cov --cov-config=pyproject.toml --cov-report=xml tests_isolated
21+
22+
.PHONY: docs-test
23+
docs-test: ## Test if documentation can be built without warnings or errors
24+
@uv run mkdocs build -s
25+
26+
.PHONY: docs
27+
docs: ## Build and serve the documentation
28+
@uv run mkdocs serve
29+
30+
.PHONY: build
31+
build: clean-build ## Build wheel file
32+
@echo "🚀 Creating wheel file"
33+
@uvx --from build pyproject-build --installer uv
34+
35+
.PHONY: clean-build
36+
clean-build: ## Clean build artifacts
37+
@echo "🚀 Removing build artifacts"
38+
@uv run python -c "import shutil; import os; shutil.rmtree('dist') if os.path.exists('dist') else None"
39+
40+
.PHONY: tag
41+
tag: ## Add a Git tag and push it to origin with syntax: make tag TAG=tag_name
42+
@echo "🚀 Creating git tag: ${TAG}"
43+
@git tag -a ${TAG} -m ""
44+
@echo "🚀 Pushing tag to origin: ${TAG}"
45+
@git push origin ${TAG}
46+
47+
.PHONY: validate-tag
48+
validate-tag: ## Check to make sure that a tag exists for the current HEAD and it looks like a valid version number
49+
@echo "🚀 Validating version tag"
50+
@uv run inv validatetag
51+
52+
.PHONY: publish-test
53+
publish-test: validate-tag build ## Test publishing a release to PyPI.
54+
@echo "🚀 Publishing: Dry run."
55+
@uvx twine upload --repository testpypi dist/*
56+
57+
.PHONY: publish
58+
publish: validate-tag build ## Publish a release to PyPI.
59+
@echo "🚀 Publishing."
60+
@uvx twine upload dist/*
61+
62+
.PHONY: help
63+
help:
64+
@uv run python -c "import re; \
65+
[[print(f'\033[36m{m[0]:<20}\033[0m {m[1]}') for m in re.findall(r'^([a-zA-Z_-]+):.*?## (.*)$$', open(makefile).read(), re.M)] for makefile in ('$(MAKEFILE_LIST)').strip().split()]"
66+
67+
.DEFAULT_GOAL := help

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ setuptools-scm = "*"
2929
mkdocs-include-markdown-plugin = "*"
3030
mkdocs-macros-plugin = "*"
3131
mkdocs-material = "*"
32-
mkdocstrings[python] = "*"
32+
mkdocstrings= {version = "*", extras = ["python"]}
3333
twine = ">=1.11"
3434

3535
[pipenv]

examples/scripts/nested.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
!echo "Doing a relative run script"
22
_relative_run_script script.txt
3-

examples/tmux_launch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ if [ $# -eq 1 ]
3333
fi
3434

3535
tmux new-session -s "tmux window demo" -n "$FIRST_COMMAND" "$FIRST_COMMAND ;read" \; \
36-
new-window -n "$SECOND_COMMAND" "$SECOND_COMMAND ; read" \; previous-window
36+
new-window -n "$SECOND_COMMAND" "$SECOND_COMMAND ; read" \; previous-window

examples/tmux_split.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ fi
3131

3232
tmux new-session -s "tmux split pane demo" "$FIRST_COMMAND ; read" \; \
3333
split-window "$SECOND_COMMAND ; read" \; \
34-
select-layout even-vertical
34+
select-layout even-vertical

pyproject.toml

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["build", "setuptools>=64", "setuptools-scm>=8"]
2+
requires = ["build>=1.2.1", "setuptools>=64", "setuptools-scm>=8"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
@@ -34,59 +34,72 @@ classifiers = [
3434
"Topic :: Software Development :: Libraries :: Python Modules",
3535
]
3636
dependencies = [
37-
"gnureadline; platform_system == 'Darwin'",
38-
"pyperclip",
39-
"pyreadline3; platform_system == 'Windows'",
40-
"rich-argparse",
41-
"wcwidth",
37+
"gnureadline>=8; platform_system == 'Darwin'",
38+
"pyperclip>=1.8",
39+
"pyreadline3>=3.4; platform_system == 'Windows'",
40+
"rich-argparse>=1.4",
41+
"wcwidth>=0.2.10",
4242
]
4343

44-
[project.optional-dependencies]
45-
build = ["build", "setuptools", "setuptools-scm"]
44+
[dependency-groups]
45+
build = ["build>=1.2.1", "setuptools>=64", "setuptools-scm>=8"]
4646
dev = [
47-
"black",
48-
"codecov",
49-
"griffe-typingdoc",
50-
"invoke",
51-
"mkdocs-include-markdown-plugin",
52-
"mkdocs-macros-plugin",
53-
"mkdocs-material",
54-
"mkdocstrings[python]",
55-
"mypy",
56-
"pytest",
57-
"pytest-cov",
58-
"pytest-mock",
59-
"ruff",
60-
"twine",
47+
"black>=24",
48+
"codecov>=2",
49+
"griffe-typingdoc>=0.2",
50+
"invoke>=2",
51+
"mkdocs-include-markdown-plugin>=6",
52+
"mkdocs-macros-plugin>=1",
53+
"mkdocs-material>=8",
54+
"mkdocstrings[python]>=0.26",
55+
"mypy>=1.12",
56+
"pre-commit>=2.20.0",
57+
"pytest>=7",
58+
"pytest-cov>=4",
59+
"pytest-mock>=3.14",
60+
"ruff>=0.9",
61+
"twine>=6",
6162
]
6263
docs = [
63-
"black",
64-
"griffe-typingdoc",
65-
"mkdocs-include-markdown-plugin",
66-
"mkdocs-macros-plugin",
67-
"mkdocs-material",
68-
"mkdocstrings[python]",
69-
"setuptools",
70-
"setuptools_scm",
64+
"black>=24",
65+
"griffe-typingdoc>=0.2",
66+
"mkdocs-include-markdown-plugin>=6",
67+
"mkdocs-macros-plugin>=1",
68+
"mkdocs-material>=8",
69+
"mkdocstrings[python]>=0.26",
70+
"setuptools>=64",
71+
"setuptools_scm>=8",
7172
]
72-
test = ["codecov", "coverage", "pytest", "pytest-cov", "pytest-mock"]
73-
validate = ["mypy", "ruff", "types-setuptools"]
73+
plugins = ["cmd2-ext-test"]
74+
test = [
75+
"codecov>=2",
76+
"coverage>=7",
77+
"pytest>=7",
78+
"pytest-cov>=4",
79+
"pytest-mock>=3.14",
80+
]
81+
validate = ["mypy>=1.12", "ruff>=0.9", "types-setuptools>=69"]
7482

7583
[tool.mypy]
7684
disallow_incomplete_defs = true
7785
disallow_untyped_calls = true
7886
disallow_untyped_defs = true
7987
exclude = [
88+
"^.git/",
89+
"^.venv/",
8090
"^build/", # .build directory
8191
"^docs/", # docs directory
92+
"^dist/",
8293
"^examples/", # examples directory
8394
"^plugins/*", # plugins directory
8495
"^noxfile\\.py$", # nox config file
8596
"setup\\.py$", # any files named setup.py
97+
"^site/",
8698
"^tasks\\.py$", # tasks.py invoke config file
8799
"^tests/", # tests directory
88100
"^tests_isolated/", # tests_isolated directory
89101
]
102+
files = ['.']
90103
show_column_numbers = true
91104
show_error_codes = true
92105
show_error_context = true
@@ -274,25 +287,7 @@ packages = ["cmd2"]
274287
[tool.setuptools_scm]
275288

276289
[tool.uv]
277-
dev-dependencies = [
278-
"black",
279-
"build",
280-
"cmd2-ext-test",
281-
"codecov",
282-
"griffe-typingdoc",
283-
"invoke",
284-
"mkdocs-include-markdown-plugin",
285-
"mkdocs-macros-plugin",
286-
"mkdocs-material",
287-
"mkdocstrings[python]",
288-
"mypy",
289-
"pytest",
290-
"pytest-cov",
291-
"pytest-mock",
292-
"ruff",
293-
"ruff",
294-
"twine",
295-
]
290+
default-groups = ["build", "dev", "plugins"]
296291

297292
[tool.uv.sources]
298293
cmd2-ext-test = { path = "plugins/ext_test", editable = true }

0 commit comments

Comments
 (0)