Skip to content

Commit 4f1bedb

Browse files
authored
Merge pull request #132 from django-commons/develop
Merge v2.3.0
2 parents 6758c33 + e0e213a commit 4f1bedb

Some content is hidden

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

75 files changed

+1409
-376
lines changed

.github/workflows/lint.yml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: lint
1+
name: Lint
22

33
on:
44
push:
@@ -18,26 +18,21 @@ jobs:
1818
strategy:
1919
matrix:
2020
# run static analysis on bleeding and trailing edges
21-
python-version: [ '3.8', '3.10', '3.12' ]
21+
python-version: [ '3.9', '3.10', '3.13' ]
2222
django-version:
2323
- '3.2' # LTS April 2024
2424
- '4.2' # LTS April 2026
25-
- '5.0' # April 2025
2625
- '5.1' # December 2025
2726
exclude:
28-
- python-version: '3.8'
27+
- python-version: '3.9'
2928
django-version: '4.2'
30-
- python-version: '3.12'
29+
- python-version: '3.13'
3130
django-version: '4.2'
32-
- python-version: '3.12'
31+
- python-version: '3.13'
3332
django-version: '3.2'
3433
- python-version: '3.10'
3534
django-version: '3.2'
36-
- python-version: '3.8'
37-
django-version: '5.0'
38-
- python-version: '3.10'
39-
django-version: '5.0'
40-
- python-version: '3.8'
35+
- python-version: '3.9'
4136
django-version: '5.1'
4237
- python-version: '3.10'
4338
django-version: '5.1'

.github/workflows/release.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
##
2+
# Derived from:
3+
# https://github.com/django-commons/django-commons-playground/blob/main/.github/workflows/release.yml
4+
#
5+
6+
name: Publish Release
7+
8+
on:
9+
push:
10+
tags:
11+
- 'v*' # only publish on version tags (e.g. v1.0.0)
12+
workflow_dispatch:
13+
inputs:
14+
pypi:
15+
description: 'Publish to PyPi'
16+
required: true
17+
default: false
18+
type: boolean
19+
github:
20+
description: 'Publish a GitHub Release'
21+
required: true
22+
default: false
23+
type: boolean
24+
testpypi:
25+
description: 'Publish to TestPyPi'
26+
required: true
27+
default: true
28+
type: boolean
29+
30+
env:
31+
PYPI_URL: https://pypi.org/p/django-typer
32+
PYPI_TEST_URL: https://test.pypi.org/project/django-typer
33+
34+
jobs:
35+
36+
build:
37+
name: Build Package
38+
runs-on: ubuntu-latest
39+
40+
steps:
41+
- uses: actions/checkout@v4
42+
- name: Set up Python
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: "3.x"
46+
- name: Install pypa/build
47+
run:
48+
python3 -m pip install build --user
49+
- name: Build a binary wheel and a source tarball
50+
run: python3 -m build
51+
- name: Store the distribution packages
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: python-package-distributions
55+
path: dist/
56+
57+
publish-to-pypi:
58+
name: Publish to PyPI
59+
if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.pypi == 'true') || github.event_name != 'workflow_dispatch' }}
60+
needs:
61+
- build
62+
runs-on: ubuntu-latest
63+
environment:
64+
name: pypi
65+
url: ${{ env.PYPI_URL }}
66+
permissions:
67+
id-token: write # IMPORTANT: mandatory for trusted publishing
68+
steps:
69+
- name: Download all the dists
70+
uses: actions/download-artifact@v4
71+
with:
72+
name: python-package-distributions
73+
path: dist/
74+
- name: Publish distribution 📦 to PyPI
75+
uses: pypa/gh-action-pypi-publish@release/v1.10
76+
77+
github-release:
78+
name: Publish GitHub Release
79+
if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.github == 'true') || github.event_name != 'workflow_dispatch' }}
80+
needs:
81+
- publish-to-pypi
82+
runs-on: ubuntu-latest
83+
84+
permissions:
85+
contents: write # IMPORTANT: mandatory for making GitHub Releases
86+
id-token: write # IMPORTANT: mandatory for sigstore
87+
88+
steps:
89+
- name: Download all the dists
90+
uses: actions/download-artifact@v4
91+
with:
92+
name: python-package-distributions
93+
path: dist/
94+
- name: Sign the dists with Sigstore
95+
uses: sigstore/gh-action-sigstore-python@v3
96+
with:
97+
inputs: >-
98+
./dist/*.tar.gz
99+
./dist/*.whl
100+
- name: Create GitHub Release
101+
env:
102+
GITHUB_TOKEN: ${{ github.token }}
103+
run: >-
104+
gh release create
105+
'${{ github.ref_name }}'
106+
--repo '${{ github.repository }}'
107+
--generate-notes
108+
- name: Upload artifact signatures to GitHub Release
109+
env:
110+
GITHUB_TOKEN: ${{ github.token }}
111+
# Upload to GitHub Release using the `gh` CLI.
112+
# `dist/` contains the built packages, and the
113+
# sigstore-produced signatures and certificates.
114+
run: >-
115+
gh release upload
116+
'${{ github.ref_name }}' dist/**
117+
--repo '${{ github.repository }}'
118+
119+
publish-to-testpypi:
120+
name: Publish to TestPyPI
121+
if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.testpypi == 'true') || github.event_name != 'workflow_dispatch' }}
122+
needs:
123+
- build
124+
runs-on: ubuntu-latest
125+
126+
environment:
127+
name: testpypi
128+
url: ${{ env.PYPI_TEST_URL }}
129+
130+
permissions:
131+
id-token: write # IMPORTANT: mandatory for trusted publishing
132+
133+
steps:
134+
- name: Download all the dists
135+
uses: actions/download-artifact@v4
136+
with:
137+
name: python-package-distributions
138+
path: dist/
139+
- name: Publish distribution 📦 to TestPyPI
140+
uses: pypa/gh-action-pypi-publish@release/v1.10
141+
with:
142+
repository-url: https://test.pypi.org/legacy/
143+
skip-existing: true
144+
145+
notify-django-packages:
146+
name: Notify Django Packages
147+
runs-on: ubuntu-latest
148+
needs:
149+
- publish-to-pypi
150+
steps:
151+
- name: Notify Django Packages
152+
run:
153+
curl -X GET "https://djangopackages.org/packages/django-typer/fetch-data/"

.github/workflows/test.yml

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: test
1+
name: Test
22

33
on:
44
push:
@@ -19,30 +19,26 @@ jobs:
1919
runs-on: ubuntu-latest
2020
strategy:
2121
matrix:
22-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13.0-rc.2']
22+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
2323
django-version:
2424
- '3.2' # LTS April 2024
2525
- '4.2' # LTS April 2026
2626
- '5.0' # April 2025
2727
- '5.1' # December 2025
2828
exclude:
29-
- python-version: '3.8'
30-
django-version: '5.0'
3129
- python-version: '3.9'
3230
django-version: '5.0'
3331
- python-version: '3.11'
3432
django-version: '3.2'
3533
- python-version: '3.12'
3634
django-version: '3.2'
37-
- python-version: '3.8'
38-
django-version: '5.1'
3935
- python-version: '3.9'
4036
django-version: '5.1'
41-
- python-version: '3.13.0-rc.2'
37+
- python-version: '3.13'
4238
django-version: '3.2'
43-
- python-version: '3.13.0-rc.2'
39+
- python-version: '3.13'
4440
django-version: '4.2'
45-
- python-version: '3.13.0-rc.2'
41+
- python-version: '3.13'
4642
django-version: '5.0'
4743

4844
steps:
@@ -57,9 +53,6 @@ jobs:
5753
with:
5854
virtualenvs-create: true
5955
virtualenvs-in-project: true
60-
- name: Install libopenblas-dev
61-
if: matrix.python-version == '3.13.0-rc.2'
62-
run: sudo apt-get install libopenblas-dev
6356
- name: Install Release Dependencies
6457
run: |
6558
poetry config virtualenvs.in-project true
@@ -96,14 +89,14 @@ jobs:
9689
runs-on: ubuntu-latest
9790
strategy:
9891
matrix:
99-
python-version: ['3.8', '3.12']
92+
python-version: ['3.9', '3.13']
10093
django-version:
10194
- '3.2' # LTS April 2024
10295
- '5.1' # December 2025
10396
exclude:
104-
- python-version: '3.8'
97+
- python-version: '3.9'
10598
django-version: '5.1'
106-
- python-version: '3.12'
99+
- python-version: '3.13'
107100
django-version: '3.2'
108101

109102
steps:
@@ -153,14 +146,14 @@ jobs:
153146
runs-on: macos-latest
154147
strategy:
155148
matrix:
156-
python-version: ['3.8', '3.12']
149+
python-version: ['3.9', '3.13']
157150
django-version:
158151
- '3.2' # LTS April 2024
159152
- '5.1' # December 2025
160153
exclude:
161-
- python-version: '3.8'
154+
- python-version: '3.9'
162155
django-version: '5.1'
163-
- python-version: '3.12'
156+
- python-version: '3.13'
164157
django-version: '3.2'
165158

166159
steps:
@@ -237,14 +230,14 @@ jobs:
237230
# runs-on: windows-latest
238231
# strategy:
239232
# matrix:
240-
# python-version: ['3.8', '3.12']
233+
# python-version: ['3.9', '3.13']
241234
# django-version:
242235
# - '3.2' # LTS April 2024
243236
# - '5.0' # April 2025
244237
# exclude:
245-
# - python-version: '3.8'
238+
# - python-version: '3.9'
246239
# django-version: '5.0'
247-
# - python-version: '3.12'
240+
# - python-version: '3.13'
248241
# django-version: '3.2'
249242

250243
# steps:
@@ -297,9 +290,6 @@ jobs:
297290
timeout-minutes: 60
298291
- uses: actions/checkout@v4
299292
- uses: actions/setup-python@v5
300-
with:
301-
python-version: '3.12'
302-
303293
- name: Install Poetry
304294
uses: snok/install-poetry@v1
305295
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,4 @@ poetry.lock
163163
.vscode
164164
django_typer/tests/dj_params.json
165165
**/.DS_Store
166+
.ruff_cache

ARCHITECTURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Architecture
22

3-
The principal design challenge of [django-typer](https://pypi.python.org/pypi/django-typer) is to manage the [Typer](https://typer.tiangolo.com/) app trees associated with each Django management command class and to keep these trees separate when classes are inherited and allow them to be edited directly when commands are extended through the plugin pattern. There are also incurred complexities with adding default django options where appropriate and supporting command callbacks as methods or static functions. Supporting dynamic command/group access through attributes on command instances also requires careful usage of advanced Python features.
3+
The principal design challenge of [django-typer](https://pypi.python.org/pypi/django-typer) is to manage the [Typer](https://typer.tiangolo.com/) app trees associated with each Django management command class and to keep these trees separate when classes are inherited and allow them to be edited directly when commands are extended through the plugin pattern. There are also incurred complexities with adding default django options where appropriate and supporting command callbacks as methods or static functions. Supporting dynamic command/group access through attributes on command instances also requires careful usage of esoteric Python features.
44

55
The [Typer](https://typer.tiangolo.com/) app tree defines the layers of groups and commands that define the CLI. Each [TyperCommand](https://django-typer.readthedocs.io/en/latest/reference.html#django_typer.TyperCommand) maintains its own app tree defined by a root [Typer](https://django-typer.readthedocs.io/en/latest/reference.html#django_typer.management.Typer) node. When other classes inherit from a base command class, that app tree is copied and the new class can modify it without affecting the base class's tree. We extend [Typer](https://typer.tiangolo.com/)'s Typer type with our own [Typer](https://django-typer.readthedocs.io/en/latest/reference.html#django_typer.management.Typer) class that adds additional bookkeeping and attribute resolution features we need.
66

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
[![PyPI djversions](https://img.shields.io/pypi/djversions/django-typer.svg)](https://pypi.org/project/django-typer/)
99
[![PyPI status](https://img.shields.io/pypi/status/django-typer.svg)](https://pypi.python.org/pypi/django-typer)
1010
[![Documentation Status](https://readthedocs.org/projects/django-typer/badge/?version=latest)](http://django-typer.readthedocs.io/?badge=latest/)
11-
[![Code Cov](https://codecov.io/gh/bckohan/django-typer/branch/main/graph/badge.svg?token=0IZOKN2DYL)](https://codecov.io/gh/bckohan/django-typer)
12-
[![Test Status](https://github.com/bckohan/django-typer/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/bckohan/django-typer/actions/workflows/test.yml?query=branch:main)
13-
[![Lint Status](https://github.com/bckohan/django-typer/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/bckohan/django-typer/actions/workflows/lint.yml?query=branch:main)
11+
[![Code Cov](https://codecov.io/gh/django-commons/django-typer/branch/main/graph/badge.svg?token=0IZOKN2DYL)](https://codecov.io/gh/django-commons/django-typer)
12+
[![Test Status](https://github.com/django-commons/django-typer/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/django-commons/django-typer/actions/workflows/test.yml?query=branch:main)
13+
[![Lint Status](https://github.com/django-commons/django-typer/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/django-commons/django-typer/actions/workflows/lint.yml?query=branch:main)
14+
[![Published on Django Packages](https://img.shields.io/badge/Published%20on-Django%20Packages-0c3c26)](https://djangopackages.org/packages/p/django-typer/)
1415

1516
Use static typing to define the CLI for your [Django](https://www.djangoproject.com/) management commands with [Typer](https://typer.tiangolo.com/). Optionally use the provided [TyperCommand](https://django-typer.readthedocs.io/en/latest/reference.html#django_typer.TyperCommand) class that inherits from [BaseCommand](https://docs.djangoproject.com/en/stable/howto/custom-management-commands/#django.core.management.BaseCommand). This class maps the [Typer](https://typer.tiangolo.com/) interface onto a class based interface that Django developers will be familiar with. All of the [BaseCommand](https://docs.djangoproject.com/en/stable/howto/custom-management-commands/#django.core.management.BaseCommand) functionality is preserved, so that [TyperCommand](https://django-typer.readthedocs.io/en/latest/reference.html#django_typer.TyperCommand) can be a drop in replacement.
1617

@@ -29,7 +30,7 @@ Use static typing to define the CLI for your [Django](https://www.djangoproject.
2930

3031
Please refer to the [full documentation](https://django-typer.readthedocs.io/) for more information.
3132

32-
![django-typer example](https://raw.githubusercontent.com/bckohan/django-typer/main/doc/source/_static/img/closepoll_example.gif)
33+
![django-typer example](https://raw.githubusercontent.com/django-commons/django-typer/main/doc/source/_static/img/closepoll_example.gif)
3334

3435
## 🚨 Deprecation Notice
3536

@@ -70,7 +71,7 @@ Please refer to the [full documentation](https://django-typer.readthedocs.io/) f
7071

7172
## Basic Example
7273

73-
[TyperCommand](https://django-typer.readthedocs.io/en/latest/reference.html#django_typer.TyperCommand) is a very simple drop in replacement for [BaseCommand](https://docs.djangoproject.com/en/stable/howto/custom-management-commands/#django.core.management.BaseCommand). All of the documented features of [BaseCommand](https://docs.djangoproject.com/en/stable/howto/custom-management-commands/#django.core.management.BaseCommand) work the same way!
74+
[TyperCommand](https://django-typer.readthedocs.io/en/latest/reference.html#django_typer.TyperCommand) is a drop in extension to [BaseCommand](https://docs.djangoproject.com/en/stable/howto/custom-management-commands/#django.core.management.BaseCommand). All of the documented features of [BaseCommand](https://docs.djangoproject.com/en/stable/howto/custom-management-commands/#django.core.management.BaseCommand) work the same way!
7475

7576
```python
7677
from django_typer.management import TyperCommand
@@ -96,7 +97,7 @@ def main(arg1: str, arg2: str, arg3: float = 0.5, arg4: int = 1):
9697
"""
9798
```
9899

99-
![Basic Example](https://raw.githubusercontent.com/bckohan/django-typer/main/examples/helps/basic.svg)
100+
![Basic Example](https://raw.githubusercontent.com/django-commons/django-typer/main/examples/helps/basic.svg)
100101

101102
## Multiple Subcommands Example
102103

@@ -165,9 +166,9 @@ def delete(
165166
"""
166167
```
167168

168-
![Multiple Subcommands Example](https://raw.githubusercontent.com/bckohan/django-typer/main/examples/helps/multi.svg)
169-
![Multiple Subcommands Example - create](https://raw.githubusercontent.com/bckohan/django-typer/main/examples/helps/multi_create.svg)
170-
![Multiple Subcommands Example - delete](https://raw.githubusercontent.com/bckohan/django-typer/main/examples/helps/multi_delete.svg)
169+
![Multiple Subcommands Example](https://raw.githubusercontent.com/django-commons/django-typer/main/examples/helps/multi.svg)
170+
![Multiple Subcommands Example - create](https://raw.githubusercontent.com/django-commons/django-typer/main/examples/helps/multi_create.svg)
171+
![Multiple Subcommands Example - delete](https://raw.githubusercontent.com/django-commons/django-typer/main/examples/helps/multi_delete.svg)
171172

172173

173174
## Grouping and Hierarchies Example
@@ -288,7 +289,7 @@ def divide(
288289
return f"{numerator / denominator:.{self.precision}f}"
289290
```
290291

291-
![Grouping and Hierarchies Example](https://raw.githubusercontent.com/bckohan/django-typer/main/examples/helps/hierarchy.svg)
292-
![Grouping and Hierarchies Example - math](https://raw.githubusercontent.com/bckohan/django-typer/main/examples/helps/hierarchy_math.svg)
293-
![Grouping and Hierarchies Example - math multiply](https://raw.githubusercontent.com/bckohan/django-typer/main/examples/helps/hierarchy_math_multiply.svg)
294-
![Grouping and Hierarchies Example - math divide](https://raw.githubusercontent.com/bckohan/django-typer/main/examples/helps/hierarchy_math_divide.svg)
292+
![Grouping and Hierarchies Example](https://raw.githubusercontent.com/django-commons/django-typer/main/examples/helps/hierarchy.svg)
293+
![Grouping and Hierarchies Example - math](https://raw.githubusercontent.com/django-commons/django-typer/main/examples/helps/hierarchy_math.svg)
294+
![Grouping and Hierarchies Example - math multiply](https://raw.githubusercontent.com/django-commons/django-typer/main/examples/helps/hierarchy_math_multiply.svg)
295+
![Grouping and Hierarchies Example - math divide](https://raw.githubusercontent.com/django-commons/django-typer/main/examples/helps/hierarchy_math_divide.svg)

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Only the latest version of django-typer [![PyPI version](https://badge.fury.io/p
66

77
## Reporting a Vulnerability
88

9-
If you think you have found a vulnerability, and even if you are not sure, please [report it to us in private](https://github.com/bckohan/django-typer/security/advisories/new). We will review it and get back to you. Please refrain from public discussions of the issue.
9+
If you think you have found a vulnerability, and even if you are not sure, please [report it to us in private](https://github.com/django-commons/django-typer/security/advisories/new). We will review it and get back to you. Please refrain from public discussions of the issue.

0 commit comments

Comments
 (0)