Skip to content

Commit

Permalink
Merge branch 'master' into feat/autocompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
bckohan authored Nov 7, 2024
2 parents 340c459 + af49fda commit 26581c0
Show file tree
Hide file tree
Showing 22 changed files with 376 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
run: python -m build
- name: Publish
uses: pypa/[email protected].1
uses: pypa/[email protected].3
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-toml
Expand All @@ -14,7 +14,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.5
rev: v0.7.2
hooks:
- id: ruff
args:
Expand Down
21 changes: 21 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,34 @@

* ✨ Show help items in order of definition. PR [#944](https://github.com/fastapi/typer/pull/944) by [@svlandeg](https://github.com/svlandeg).

### Fixes

* 🐛 Fix equality check for custom classes. PR [#979](https://github.com/fastapi/typer/pull/979) by [@AryazE](https://github.com/AryazE).
* 🐛 Allow colon in zsh autocomplete values and descriptions. PR [#988](https://github.com/fastapi/typer/pull/988) by [@snapbug](https://github.com/snapbug).

### Refactors

* 🗑️ Deprecate support for `is_flag` and `flag_value` parameters. PR [#987](https://github.com/fastapi/typer/pull/987) by [@svlandeg](https://github.com/svlandeg).
* 🔥 Remove unused functionality from `_typing.py` file. PR [#805](https://github.com/fastapi/typer/pull/805) by [@ivantodorovich](https://github.com/ivantodorovich).
* ✏️ Fix typo in function name `_make_rich_text`. PR [#959](https://github.com/fastapi/typer/pull/959) by [@svlandeg](https://github.com/svlandeg).

### Internal

* ✅ Only run completion installation tests when the env var `_TYPER_RUN_INSTALL_COMPLETION_TESTS` is set. PR [#995](https://github.com/fastapi/typer/pull/995) by [@svlandeg](https://github.com/svlandeg).
* 📝 Update the docstring of the `_make_rich_text` method. PR [#972](https://github.com/fastapi/typer/pull/972) by [@svlandeg](https://github.com/svlandeg).
*[pre-commit.ci] pre-commit autoupdate. PR [#1040](https://github.com/fastapi/typer/pull/1040) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci).
* ⬆ Bump mkdocs-material from 9.5.42 to 9.5.44. PR [#1042](https://github.com/fastapi/typer/pull/1042) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump ruff from 0.7.1 to 0.7.2. PR [#1038](https://github.com/fastapi/typer/pull/1038) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump mkdocs-macros-plugin from 1.3.6 to 1.3.7. PR [#1031](https://github.com/fastapi/typer/pull/1031) by [@dependabot[bot]](https://github.com/apps/dependabot).
*[pre-commit.ci] pre-commit autoupdate. PR [#1032](https://github.com/fastapi/typer/pull/1032) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci).
* ⬆ Bump ruff from 0.7.0 to 0.7.1. PR [#1029](https://github.com/fastapi/typer/pull/1029) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump pillow from 10.4.0 to 11.0.0. PR [#1023](https://github.com/fastapi/typer/pull/1023) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump mkdocs-material from 9.5.35 to 9.5.42. PR [#1027](https://github.com/fastapi/typer/pull/1027) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump ruff from 0.6.5 to 0.7.0. PR [#1026](https://github.com/fastapi/typer/pull/1026) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump mkdocs-macros-plugin from 1.2.0 to 1.3.6. PR [#1025](https://github.com/fastapi/typer/pull/1025) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Update pre-commit requirement from <4.0.0,>=2.17.0 to >=2.17.0,<5.0.0. PR [#1012](https://github.com/fastapi/typer/pull/1012) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump pypa/gh-action-pypi-publish from 1.10.1 to 1.10.3. PR [#1009](https://github.com/fastapi/typer/pull/1009) by [@dependabot[bot]](https://github.com/apps/dependabot).
*[pre-commit.ci] pre-commit autoupdate. PR [#1001](https://github.com/fastapi/typer/pull/1001) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci).
* 👷 Update Deploy docs CI to use uv. PR [#1021](https://github.com/fastapi/typer/pull/1021) by [@tiangolo](https://github.com/tiangolo).
* 👷 Fix smokeshow, checkout files on CI. PR [#1020](https://github.com/fastapi/typer/pull/1020) by [@tiangolo](https://github.com/tiangolo).
* 👷 Use uv in CI. PR [#1019](https://github.com/fastapi/typer/pull/1019) by [@tiangolo](https://github.com/tiangolo).
Expand Down
6 changes: 3 additions & 3 deletions requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
-e .

mkdocs-material==9.5.35
mkdocs-material==9.5.44
mdx-include >=1.4.1,<2.0.0
mkdocs-redirects>=1.2.1,<1.3.0
pyyaml >=5.3.1,<7.0.0
# For Material for MkDocs, Chinese search
# jieba==0.42.1
# For image processing by Material for MkDocs
pillow==10.4.0
pillow==11.0.0
# For image processing by Material for MkDocs
cairosvg==2.7.1
# mkdocstrings[python]==0.25.1
# Enable griffe-typingdoc once dropping Python 3.7 and upgrading typing-extensions
# griffe-typingdoc==0.2.5
# For griffe, it formats with black
# black==24.3.0
mkdocs-macros-plugin==1.2.0
mkdocs-macros-plugin==1.3.7
2 changes: 1 addition & 1 deletion requirements-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ coverage[toml] >=6.2,<8.0
pytest-xdist >=1.32.0,<4.0.0
pytest-sugar >=0.9.4,<1.1.0
mypy ==1.4.1
ruff ==0.6.5
ruff ==0.7.2
# Needed explicitly by typer-slim
rich >=10.11.0
shellingham >=1.3.0
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
-r requirements-tests.txt
-r requirements-docs.txt

pre-commit >=2.17.0,<4.0.0
pre-commit >=2.17.0,<5.0.0
2 changes: 2 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ set -x
export TERMINAL_WIDTH=3000
# Force disable terminal for tests inside of pytest, takes precedence over GITHUB_ACTIONS env var
export _TYPER_FORCE_DISABLE_TERMINAL=1
# Run autocompletion install tests in the CI
export _TYPER_RUN_INSTALL_COMPLETION_TESTS=1
# It seems xdist-pytest ensures modified sys.path to import relative modules in examples keeps working
pytest --cov --cov-report=term-missing -o console_output_style=progress --numprocesses=auto ${@}
25 changes: 25 additions & 0 deletions tests/test_completion/colon_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import typer

image_desc = [
("alpine:latest", "latest alpine image"),
("alpine:hello", "fake image: for testing"),
("nvidia/cuda:10.0-devel-ubuntu18.04", ""),
]


def _complete(incomplete: str) -> str:
for image, desc in image_desc:
if image.startswith(incomplete):
yield image, desc


app = typer.Typer()


@app.command()
def image(name: str = typer.Option(autocompletion=_complete)):
typer.echo(name)


if __name__ == "__main__":
app()
3 changes: 2 additions & 1 deletion tests/test_completion/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from docs_src.commands.index import tutorial001 as mod

from ..utils import needs_bash, needs_linux
from ..utils import needs_bash, needs_linux, requires_completion_permission


@needs_bash
Expand All @@ -26,6 +26,7 @@ def test_show_completion():

@needs_bash
@needs_linux
@requires_completion_permission
def test_install_completion():
bash_completion_path: Path = Path.home() / ".bashrc"
text = ""
Expand Down
7 changes: 7 additions & 0 deletions tests/test_completion/test_completion_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@

from docs_src.commands.index import tutorial001 as mod

from ..utils import requires_completion_permission

runner = CliRunner()
app = typer.Typer()
app.command()(mod.main)


@requires_completion_permission
def test_completion_install_no_shell():
result = subprocess.run(
[sys.executable, "-m", "coverage", "run", mod.__file__, "--install-completion"],
Expand All @@ -28,6 +31,7 @@ def test_completion_install_no_shell():
assert "Option '--install-completion' requires an argument" in result.stderr


@requires_completion_permission
def test_completion_install_bash():
bash_completion_path: Path = Path.home() / ".bashrc"
text = ""
Expand Down Expand Up @@ -67,6 +71,7 @@ def test_completion_install_bash():
)


@requires_completion_permission
def test_completion_install_zsh():
completion_path: Path = Path.home() / ".zshrc"
text = ""
Expand Down Expand Up @@ -104,6 +109,7 @@ def test_completion_install_zsh():
assert "compdef _tutorial001py_completion tutorial001.py" in install_content


@requires_completion_permission
def test_completion_install_fish():
script_path = Path(mod.__file__)
completion_path: Path = (
Expand Down Expand Up @@ -133,6 +139,7 @@ def test_completion_install_fish():
assert "Completion will take effect once you restart the terminal" in result.stdout


@requires_completion_permission
def test_completion_install_powershell():
completion_path: Path = (
Path.home() / ".config/powershell/Microsoft.PowerShell_profile.ps1"
Expand Down
Loading

0 comments on commit 26581c0

Please sign in to comment.