Skip to content

Commit

Permalink
Merge pull request #89 from bckohan/v2.0.x
Browse files Browse the repository at this point in the history
V2.1.0
  • Loading branch information
bckohan committed Jun 6, 2024
2 parents da65a56 + 943f311 commit 599e7c0
Show file tree
Hide file tree
Showing 335 changed files with 4,123 additions and 4,055 deletions.
1 change: 1 addition & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
coverage:
fixes:
- "__init__.py::django_typer/__init__.py"
- "management/__init__.py::django_typer/management/__init__.py"
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
timeout-minutes: 60
- name: Run Unit Tests
run: |
poetry run pytest django_typer/tests/shellcompletion/*
poetry run pytest tests/shellcompletion/*
mv .coverage linux-complete-py${{ matrix.python-version }}-dj${{ matrix.django-version }}.coverage
- name: Store coverage files
Expand Down Expand Up @@ -209,7 +209,7 @@ jobs:
- name: Run Unit Tests
shell: zsh {0}
run: |
poetry run pytest django_typer/tests/shellcompletion/test_zsh.py || exit 1
poetry run pytest tests/shellcompletion/test_zsh.py || exit 1
mv .coverage macos-complete-py${{ matrix.python-version }}-dj${{ matrix.django-version }}.coverage
- name: Store coverage files
Expand Down Expand Up @@ -256,7 +256,7 @@ jobs:
# shell: powershell
# - name: Run Unit Tests
# run: |
# poetry run pytest django_typer/tests/completion_tests.py::PowerShellTests
# poetry run pytest tests/completion_tests.py::PowerShellTests
# mv .coverage windows-complete-py${{ matrix.python-version }}-dj${{ matrix.django-version }}.coverage
# shell: powershell
# - name: Store coverage files
Expand Down
36 changes: 9 additions & 27 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,21 @@

# Contributing

Contributions are encouraged! Please use the issue page to submit feature
requests or bug reports. Issues with attached PRs will be given priority and
have a much higher likelihood of acceptance. Please also open an issue and
associate it with any submitted PRs. That said, the aim is to keep this library
as lightweight as possible. Only features with broad-based use cases will be
considered.
Contributions are encouraged! Please use the issue page to submit feature requests or bug reports. Issues with attached PRs will be given priority and have a much higher likelihood of acceptance. Please also open an issue and associate it with any submitted PRs. That said, the aim is to keep this library as lightweight as possible. Only features with broad-based use cases will be considered.

We are actively seeking additional maintainers. If you're interested, please
[contact me](https://github.com/bckohan).
We are actively seeking additional maintainers. If you're interested, please [contact me](https://github.com/bckohan).

## Installation

`django-typer` uses [Poetry](https://python-poetry.org/) for environment, package, and dependency
management:
`django-typer` uses [Poetry](https://python-poetry.org/) for environment, package, and dependency management:

```shell
poetry install
```

## Documentation

`django-typer` documentation is generated using [Sphinx](https://www.sphinx-doc.org/en/master/) with the
[readthedocs](https://readthedocs.org/) theme. Any new feature PRs must provide updated documentation for
the features added. To build the docs run doc8 to check for formatting issues
then run Sphinx:
`django-typer` documentation is generated using [Sphinx](https://www.sphinx-doc.org/en/master/) with the [readthedocs](https://readthedocs.org/) theme. Any new feature PRs must provide updated documentation for the features added. To build the docs run doc8 to check for formatting issues then run Sphinx:

```bash
cd ./doc
Expand All @@ -46,11 +36,7 @@ poetry run make html

## Static Analysis

`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:
`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:

```bash
./check.sh
Expand All @@ -64,10 +50,7 @@ To run static analysis without automated fixing you can run:

## Running Tests

`django-typer` is set up to use [pytest](https://docs.pytest.org/en/stable/) to run unit tests. All the tests are
housed in `django_typer/tests/tests.py`. Before a PR is accepted, all tests
must be passing and the code coverage must be at 100%. A small number of
exempted error handling branches are acceptable.
`django-typer` is set up to use [pytest](https://docs.pytest.org/en/stable/) to run unit tests. All the tests are housed in `tests/tests.py`. Before a PR is accepted, all tests must be passing and the code coverage must be at 100%. A small number of exempted error handling branches are acceptable.

To run the full suite:

Expand All @@ -81,10 +64,9 @@ To run a single test, or group of tests in a class:
poetry run pytest <path_to_tests_file>::ClassName::FunctionName
```

For instance, to run all tests in BasicTests, and then just the
test_call_command test you would do:
For instance, to run all tests in BasicTests, and then just the test_call_command test you would do:

```shell
poetry run pytest django_typer/tests/tests.py::BasicTests
poetry run pytest django_typer/tests/tests.py::BasicTests::test_call_command
poetry run pytest tests/tests.py::BasicTests
poetry run pytest tests/tests.py::BasicTests::test_call_command
```
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ Please refer to the [full documentation](https://django-typer.readthedocs.io/) f

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

## 🚨 Deprecation Notice

**Imports from ``django_typer`` have been deprecated and will be removed in 3.0! Imports have moved to ``django_typer.management``:**

```python
# old way
from django_typer import TyperCommand, command, group, initialize, Typer

# new way!
from django_typer.management import TyperCommand, command, group, initialize, Typer
```

## Installation

1. Clone django-typer from GitHub or install a release off [PyPI](https://pypi.org/project/django-typer/):
Expand Down Expand Up @@ -61,7 +73,7 @@ Please refer to the [full documentation](https://django-typer.readthedocs.io/) f
[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!

```python
from django_typer import TyperCommand
from django_typer.management import TyperCommand
class Command(TyperCommand):
def handle(self, arg1: str, arg2: str, arg3: float = 0.5, arg4: int = 1):
Expand All @@ -73,7 +85,7 @@ class Command(TyperCommand):
Or, you may also use an interface identical to [Typer](https://typer.tiangolo.com/)'s. Simply import [Typer](https://typer.tiangolo.com/) from django_typer instead of typer.
```python
from django_typer import Typer
from django_typer.management import Typer
app = Typer()
Expand All @@ -98,7 +110,7 @@ Commands with multiple subcommands can be defined:
from django.utils.translation import gettext_lazy as _
from typer import Argument
from django_typer import TyperCommand, command
from django_typer.management import TyperCommand, command
class Command(TyperCommand):
Expand Down Expand Up @@ -128,7 +140,7 @@ Commands with multiple subcommands can be defined:
Or using the typer-style interface this could be written:
```python
from django_typer import Typer
from django_typer.management import Typer
import typing as t
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -176,7 +188,7 @@ Using the class-based interface we could define the command like this:
from django.utils.translation import gettext_lazy as _
from typer import Argument, Option
from django_typer import TyperCommand, group
from django_typer.management import TyperCommand, group
class Command(TyperCommand):
Expand Down Expand Up @@ -232,7 +244,7 @@ from functools import reduce
from django.utils.translation import gettext_lazy as _
from typer import Argument, Option
from django_typer import Typer
from django_typer.management import Typer
app = Typer(help=_("A more complex command that defines a hierarchy of subcommands."))
Expand Down
Loading

0 comments on commit 599e7c0

Please sign in to comment.