Skip to content

Commit 19105a1

Browse files
committed
document just recipes, update contributing file and fix lint CI
1 parent 2243773 commit 19105a1

File tree

3 files changed

+113
-9
lines changed

3 files changed

+113
-9
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
uses: extractions/setup-just@v2
5353
- name: Install Dependencies
5454
run: |
55-
just init ${{ steps.sp.outputs.python-path }}
55+
just init ${{ steps.sp.outputs.python-path }} install
5656
just pin-dependency Django~=${{ matrix.django-version }}.0
5757
- name: Install Emacs
5858
if: ${{ github.event.inputs.debug == 'true' }}

CONTRIBUTING.md

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ We are actively seeking additional maintainers. If you're interested, please ope
88

99
### Install Just
1010

11-
We provide a justfile with recipes for all the development tasks. You should [install just](https://just.systems/man/en/installation.html) if it is not on your system already.
11+
We provide a platform independent justfile with recipes for all the development tasks. You should [install just](https://just.systems/man/en/installation.html) if it is not on your system already.
1212

13-
### Install Poetry
14-
15-
`django-typer` uses [Poetry](https://python-poetry.org/) for environment, package, and dependency management:
13+
`django-typer` uses [Poetry](https://python-poetry.org/) for environment, package, and dependency management. ``just init`` will install the necessary build tooling if you do not already have it:
1614

1715
```shell
18-
poetry install
16+
just init
17+
just install
1918
```
2019

2120
### Windows
@@ -36,20 +35,26 @@ just check-docs # lint the docs
3635
just check-docs-links # check for broken links in the docs
3736
```
3837

38+
Run the docs with auto rebuild using:
39+
40+
```bash
41+
just docs-live
42+
```
43+
3944
## Static Analysis
4045

4146
`django-typer` uses [ruff](https://docs.astral.sh/ruff/) for Python linting, header import standardization and code formatting. [mypy](http://mypy-lang.org/) and [pyright](https://github.com/microsoft/pyright) are used for static type checking. Before any PR is accepted the following must be run, and static analysis tools should not produce any errors or warnings. Disabling certain errors or warnings where justified is acceptable:
4247

4348
To fix formatting and linting problems that are fixable run:
4449

4550
```bash
46-
just fix-all
51+
just fix
4752
```
4853

4954
To run all static analysis without automated fixing you can run:
5055

5156
```bash
52-
just check-all
57+
just check
5358
```
5459

5560
## Running Tests
@@ -59,7 +64,7 @@ just check-all
5964
To run the full suite:
6065

6166
```shell
62-
just test
67+
just test-all
6368
```
6469

6570
To run a single test, or group of tests in a class:
@@ -78,3 +83,56 @@ poetry run pytest tests/test_basics.py::BasicTests::test_call_command
7883
## Versioning
7984

8085
django-typer strictly adheres to [semantic versioning](https://semver.org).
86+
87+
88+
## Just Recipes
89+
90+
```
91+
build # build docs and package
92+
build-docs # build the docs
93+
build-docs-html # build html documentation
94+
build-docs-pdf # build pdf documentation
95+
build-sdist # build the source distribution
96+
build-wheel # build the wheel distribution
97+
check # run all static checks
98+
check-docs # lint the documentation
99+
check-docs-links # check the documentation links for broken links
100+
check-format # check if the code needs formatting
101+
check-lint # lint the code
102+
check-package # run package checks
103+
check-readme # check that the readme renders
104+
check-types # run static type checking
105+
clean # remove all non repository artifacts
106+
clean-docs # remove doc build artifacts
107+
clean-env # remove the virtual environment
108+
clean-git-ignored # remove all git ignored files
109+
coverage # generate the test coverage report
110+
default # list all available commands
111+
docs # build and open the documentation
112+
docs-live # serve the documentation, with auto-reload
113+
fix # fix formatting, linting issues and import sorting
114+
format # format the code and sort imports
115+
init python="python" # install build tooling
116+
install *OPTS # update and install development dependencies
117+
install-docs # install documentation dependencies
118+
install-precommit # install git pre-commit hooks
119+
install-translate # install translation dependencies
120+
lint # sort the imports and fix linting issues
121+
list-missed-tests # run the tests and report if any were not run - sanity check
122+
log-tests # run all tests and log them
123+
open-docs # open the html documentation
124+
pin-dependency +PACKAGES # install a dependency to a specific version e.g. just pin-dependency Django~=5.1.0
125+
precommit # run the pre-commit checks
126+
run +ARGS # run the command in the virtual environment
127+
sort-imports # sort the python imports
128+
test *TESTS # run tests
129+
test-all # run all tests
130+
test-bash # test bash shell completions
131+
test-fish # test fish shell completions
132+
test-no-rich # run the tests that require rich not to be installed
133+
test-powershell # test powershell shell completions
134+
test-pwsh # test pwsh shell completions
135+
test-rich # run the tests that require rich to be installed
136+
test-zsh # test zsh shell completions
137+
translate # generate translations using google translate
138+
```

justfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,165 +1,211 @@
11
set windows-shell := ["powershell.exe", "-NoLogo", "-Command"]
22
set unstable := true
33

4+
# list all available commands
45
default:
56
@just --list
67

8+
# install build tooling
79
init python="python":
810
pip install pipx
911
pipx ensurepath
1012
pipx install poetry
1113
poetry env use {{ python }}
1214
poetry run pip install --upgrade pip setuptools wheel
1315

16+
# install git pre-commit hooks
1417
install-precommit:
1518
poetry run pre-commit install
1619

20+
# update and install development dependencies
1721
install *OPTS:
1822
poetry lock
1923
poetry install -E rich {{ OPTS }}
2024
poetry run pre-commit install
2125

26+
# install documentation dependencies
2227
install-docs:
2328
poetry lock
2429
poetry install --with docs
2530

31+
# install translation dependencies
2632
install-translate:
2733
poetry lock
2834
poetry install --with translate
2935

36+
# install a dependency to a specific version e.g. just pin-dependency Django~=5.1.0
3037
pin-dependency +PACKAGES:
3138
poetry run pip install -U {{ PACKAGES }}
3239

40+
# run static type checking
3341
check-types:
3442
poetry run mypy django_typer
3543
poetry run pyright
3644

45+
# run package checks
3746
check-package:
3847
poetry check
3948
poetry run pip check
4049

50+
# remove doc build artifacts
4151
clean-docs:
4252
python -c "import shutil; shutil.rmtree('./doc/build', ignore_errors=True)"
4353

54+
# remove the virtual environment
4455
clean-env:
4556
python -c "import shutil, sys; shutil.rmtree(sys.argv[1], ignore_errors=True)" $(poetry env info --path)
4657

58+
# remove all git ignored files
4759
clean-git-ignored:
4860
git clean -fdX
4961

5062
# remove all non repository artifacts
5163
clean: clean-docs clean-env clean-git-ignored
5264

65+
# build html documentation
5366
build-docs-html: install-docs
5467
poetry run sphinx-build --fresh-env --builder html --doctree-dir ./doc/build/doctrees ./doc/source ./doc/build/html
5568

69+
# build pdf documentation
5670
build-docs-pdf: install-docs
5771
poetry run sphinx-build --fresh-env --builder latexpdf --doctree-dir ./doc/build/doctrees ./doc/source ./doc/build/pdf
5872

73+
# build the docs
5974
build-docs: build-docs-html
6075

76+
# build the wheel distribution
6177
build-wheel:
6278
poetry build -f wheel
6379

80+
# build the source distribution
6481
build-sdist:
6582
poetry build -f sdist
6683

84+
# build docs and package
6785
build: build-docs-html
6886
poetry build
6987

88+
# open the html documentation
7089
open-docs:
7190
poetry run python -c "import webbrowser; webbrowser.open('file://$(pwd)/doc/build/html/index.html')"
7291

92+
# build and open the documentation
7393
docs: build-docs-html open-docs
7494

95+
# serve the documentation, with auto-reload
7596
docs-live:
7697
poetry run sphinx-autobuild doc/source doc/build --open-browser --watch django_typer --port 8000 --delay 1
7798

99+
# check the documentation links for broken links
78100
check-docs-links:
79101
-poetry run sphinx-build -b linkcheck -Q -D linkcheck_timeout=10 ./doc/source ./doc/build
80102
poetry run python ./doc/broken_links.py
81103

104+
# lint the documentation
82105
check-docs:
83106
poetry run doc8 --ignore-path ./doc/build --max-line-length 100 -q ./doc
84107

108+
# lint the code
85109
check-lint:
86110
poetry run ruff check --select I
87111
poetry run ruff check
88112

113+
# check if the code needs formatting
89114
check-format:
90115
poetry run ruff format --check
91116
poetry run ruff format --line-length 80 --check examples
92117

118+
# check that the readme renders
93119
check-readme:
94120
poetry run python -m readme_renderer ./README.md -o /tmp/README.html
95121

122+
# sort the python imports
96123
sort-imports:
97124
poetry run ruff check --fix --select I
98125

126+
# format the code and sort imports
99127
format: sort-imports
100128
just --fmt --unstable
101129
poetry run ruff format
102130
poetry run ruff format --line-length 80 examples
103131

132+
# sort the imports and fix linting issues
104133
lint: sort-imports
105134
poetry run ruff check --fix
106135

136+
# fix formatting, linting issues and import sorting
107137
fix: lint format
108138

139+
# run all static checks
109140
check: check-lint check-format check-types check-package check-docs check-docs-links check-readme
110141

142+
# run the tests that require rich not to be installed
111143
test-no-rich:
112144
poetry run pip uninstall -y rich
113145
poetry run pytest --cov-append -m no_rich
114146

147+
# run the tests that require rich to be installed
115148
test-rich:
116149
poetry run pytest --cov-append -m rich
117150

151+
# run all tests and log them
118152
log-tests:
119153
poetry run python -m pytest --collect-only --disable-warnings -q --no-cov | poetry run python -c "from pathlib import Path; import sys; Path('./tests/tests.log').unlink(missing_ok=True); open('./tests/tests.log', 'a').close(); open('./tests/all_tests.log', 'w').writelines(sys.stdin)"
120154

155+
# run all tests
121156
test-all: test-rich test-no-rich
122157
poetry run pip install colorama
123158
poetry run pytest --cov-append -m "not rich and not no_rich"
124159
poetry run pip uninstall -y colorama
125160
poetry run pytest --cov-append -k test_ctor_params
126161

162+
# run the tests and report if any were not run - sanity check
127163
list-missed-tests: install log-tests test-all
128164
poetry run python ./tests/missed_tests.py
129165

166+
# test bash shell completions
130167
[script("bash")]
131168
test-bash:
132169
poetry run pytest --cov-append tests/shellcompletion/test_shell_resolution.py::TestShellResolution::test_bash tests/test_parser_completers.py tests/shellcompletion/test_bash.py
133170

171+
# test zsh shell completions
134172
[script("zsh")]
135173
test-zsh:
136174
poetry run pytest --cov-append tests/shellcompletion/test_shell_resolution.py::TestShellResolution::test_zsh tests/test_parser_completers.py tests/shellcompletion/test_zsh.py
137175

176+
# test powershell shell completions
138177
[script("powershell")]
139178
test-powershell:
140179
poetry run pytest --cov-append tests/shellcompletion/test_shell_resolution.py::TestShellResolution::test_powershell tests/test_parser_completers.py tests/test_parser_completers.py tests/shellcompletion/test_powershell.py::PowerShellTests tests/shellcompletion/test_powershell.py::PowerShellExeTests
141180

181+
# test pwsh shell completions
142182
[script("pwsh")]
143183
test-pwsh:
144184
poetry run pytest --cov-append tests/shellcompletion/test_shell_resolution.py::TestShellResolution::test_pwsh tests/test_parser_completers.py tests/shellcompletion/test_powershell.py::PWSHTests tests/shellcompletion/test_powershell.py::PWSHExeTests
145185

186+
# test fish shell completions
146187
[script("fish")]
147188
test-fish:
148189
poetry run pytest --cov-append tests/shellcompletion/test_shell_resolution.py::TestShellResolution::test_fish tests/test_parser_completers.py tests/shellcompletion/test_fish.py
149190

191+
# run tests
150192
test *TESTS:
151193
poetry run pytest --cov-append {{ TESTS }}
152194

195+
# run the pre-commit checks
153196
precommit:
154197
poetry run pre-commit
155198

199+
# generate the test coverage report
156200
coverage:
157201
poetry run coverage combine --keep *.coverage
158202
poetry run coverage report
159203
poetry run coverage xml
160204

205+
# run the command in the virtual environment
161206
run +ARGS:
162207
poetry run {{ ARGS }}
163208

209+
# generate translations using google translate
164210
translate: install-translate
165211
poetry run ./manage.py translate --settings tests.settings.translate

0 commit comments

Comments
 (0)