Skip to content

Commit 9dffae1

Browse files
authored
Merge pull request #52 from bckohan/v1.1.x
Merge V1.1.1 changes.
2 parents 1a1c4a6 + 52de175 commit 9dffae1

File tree

8 files changed

+120
-111
lines changed

8 files changed

+120
-111
lines changed

.github/workflows/lint.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,24 @@ jobs:
4343
run: |
4444
poetry config virtualenvs.in-project true
4545
poetry run pip install --upgrade pip
46-
poetry install
46+
poetry install -E rich
4747
poetry run pip install -U "django~=${{ matrix.django-version }}"
48+
# - name: Setup tmate session
49+
# uses: mxschmitt/action-tmate@v3
50+
# with:
51+
# detached: true
52+
# timeout-minutes: 60
4853
- name: Run Static Analysis
4954
run: |
5055
source .venv/bin/activate
5156
isort django_typer --check
5257
black django_typer --check
5358
pylint django_typer
5459
mypy django_typer
60+
pyright
5561
poetry check
5662
pip check
5763
python -m readme_renderer ./README.md -o /tmp/README.html
5864
cd ./doc
5965
doc8 --ignore-path build --max-line-length 100
6066
echo "$(poetry env info --path)/bin" >> $GITHUB_PATH
61-
62-
# - name: Run pyright
63-
# uses: jakebailey/pyright-action@v2

CONTRIBUTING.md

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
[Poetry]: https://python-poetry.org/
2+
[Pylint]: https://www.pylint.org/
3+
[isort]: https://pycqa.github.io/isort/
4+
[mypy]: http://mypy-lang.org/
5+
[django-pytest]: https://pytest-django.readthedocs.io/en/latest/
6+
[pytest]: https://docs.pytest.org/en/stable/
7+
[Sphinx]: https://www.sphinx-doc.org/en/master/
8+
[readthedocs]: https://readthedocs.org/
9+
[me]: https://github.com/bckohan
10+
[black]: https://black.readthedocs.io/en/stable/
11+
[pyright]: https://github.com/microsoft/pyright
12+
13+
# Contributing
14+
15+
Contributions are encouraged! Please use the issue page to submit feature
16+
requests or bug reports. Issues with attached PRs will be given priority and
17+
have a much higher likelihood of acceptance. Please also open an issue and
18+
associate it with any submitted PRs. That said, the aim is to keep this library
19+
as lightweight as possible. Only features with broad-based use cases will be
20+
considered.
21+
22+
We are actively seeking additional maintainers. If you're interested, please
23+
[contact me](https://github.com/bckohan).
24+
25+
## Installation
26+
27+
`django-typer` uses [Poetry](https://python-poetry.org/) for environment, package, and dependency
28+
management:
29+
30+
```shell
31+
poetry install
32+
```
33+
34+
## Documentation
35+
36+
`django-typer` documentation is generated using [Sphinx](https://www.sphinx-doc.org/en/master/) with the
37+
[readthedocs](https://readthedocs.org/) theme. Any new feature PRs must provide updated documentation for
38+
the features added. To build the docs run doc8 to check for formatting issues
39+
then run Sphinx:
40+
41+
```bash
42+
cd ./doc
43+
poetry run doc8 --ignore-path build --max-line-length 100
44+
poetry run make html
45+
```
46+
47+
## Static Analysis
48+
49+
`django-typer` uses [Pylint](https://www.pylint.org/) for Python linting and [mypy](http://mypy-lang.org/) and [pyright](https://github.com/microsoft/pyright) for static type
50+
checking. Header imports are also standardized using [isort](https://pycqa.github.io/isort/) and formatting is
51+
done with [black](https://black.readthedocs.io/en/stable/). Before any PR is accepted the following must be run, and
52+
static analysis tools should not produce any errors or warnings. Disabling
53+
certain errors or warnings where justified is acceptable:
54+
55+
```bash
56+
poetry run isort django_typer
57+
poetry run black django_typer
58+
poetry run pylint django_typer
59+
poetry run mypy django_typer
60+
pyright
61+
poetry check
62+
poetry run pip check
63+
poetry run python -m readme_renderer ./README.md
64+
```
65+
66+
## Running Tests
67+
68+
`django-typer` is set up to use [pytest](https://docs.pytest.org/en/stable/) to run unit tests. All the tests are
69+
housed in `django_typer/tests/tests.py`. Before a PR is accepted, all tests
70+
must be passing and the code coverage must be at 100%. A small number of
71+
exempted error handling branches are acceptable.
72+
73+
To run the full suite:
74+
75+
```shell
76+
poetry run pytest
77+
```
78+
79+
To run a single test, or group of tests in a class:
80+
81+
```shell
82+
poetry run pytest <path_to_tests_file>::ClassName::FunctionName
83+
```
84+
85+
For instance, to run all tests in BasicTests, and then just the
86+
test_call_command test you would do:
87+
88+
```shell
89+
poetry run pytest django_typer/tests/tests.py::BasicTests
90+
poetry run pytest django_typer/tests/tests.py::BasicTests::test_call_command
91+
```

CONTRIBUTING.rst

-99
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# django-typer
22

33

4-
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
55
[![PyPI version](https://badge.fury.io/py/django-typer.svg)](https://pypi.python.org/pypi/django-typer/)
66
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/django-typer.svg)](https://pypi.python.org/pypi/django-typer/)
77
[![PyPI djversions](https://img.shields.io/pypi/djversions/django-typer.svg)](https://pypi.org/project/django-typer/)

django_typer/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
from typing import ParamSpec
115115

116116

117-
VERSION = (1, 1, 0)
117+
VERSION = (1, 1, 1)
118118

119119
__title__ = "Django Typer"
120120
__version__ = ".".join(str(i) for i in VERSION)
@@ -1210,8 +1210,8 @@ class TyperCommandMeta(type):
12101210
"""
12111211

12121212
style: ColorStyle
1213-
stdout: t.IO[str]
1214-
stderr: t.IO[str]
1213+
stdout: BaseOutputWrapper
1214+
stderr: BaseOutputWrapper
12151215
requires_system_checks: t.Union[t.Sequence[str], str]
12161216
suppressed_base_arguments: t.Optional[t.Iterable[str]]
12171217
typer_app: Typer

django_typer/apps.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
patch.apply()
2222

23-
rich: t.Union[ModuleType, None] = None
23+
rich: t.Optional[ModuleType]
24+
traceback: t.Optional[ModuleType]
2425

2526
try:
2627
import sys
@@ -30,7 +31,12 @@
3031
from typer import main as typer_main
3132

3233
tb_config = traceback_config()
33-
if rich and isinstance(tb_config, dict) and not tb_config.get("no_install", False):
34+
if (
35+
rich
36+
and traceback
37+
and isinstance(tb_config, dict)
38+
and not tb_config.get("no_install", False)
39+
):
3440
# install rich tracebacks if we've been configured to do so (default)
3541
no_color = "NO_COLOR" in os.environ
3642
force_color = "FORCE_COLOR" in os.environ
@@ -60,7 +66,8 @@
6066
# installed rich one - we patch it here to make sure!
6167
typer_main._original_except_hook = sys.excepthook
6268
except ImportError:
63-
pass
69+
rich = None
70+
traceback = None
6471

6572

6673
@register("settings")

doc/source/changelog.rst

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Change Log
33
==========
44

5+
v1.1.1
6+
======
7+
8+
* Implemented `Fix pyright type checking and add to CI <https://github.com/bckohan/django-typer/issues/51>`_
9+
* Implemented `Convert CONTRIBUTING.rst to markdown <https://github.com/bckohan/django-typer/issues/50>`_
10+
511
v1.1.0
612
======
713

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "django-typer"
3-
version = "1.1.0"
3+
version = "1.1.1"
44
description = "Use Typer to define the CLI for your Django management commands."
55
authors = ["Brian Kohan <[email protected]>"]
66
license = "MIT"
@@ -88,6 +88,7 @@ scipy = [
8888
]
8989
django-stubs = "^4.2.7"
9090
pexpect = "^4.9.0"
91+
pyright = "^1.1.357"
9192

9293
[tool.poetry.extras]
9394
rich = ["rich"]

0 commit comments

Comments
 (0)