Skip to content

Commit

Permalink
update typer to v0.9.0 and use Annotated type hint
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianPugh committed Aug 27, 2023
1 parent 8118ead commit 8269109
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 58 deletions.
94 changes: 47 additions & 47 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ pythontemplate = "pythontemplate.cli.main:run_app"
[tool.poetry.dependencies]
# Be as loose as possible if writing a library.
python = "^3.8"
typer = ">=0.7.0"
typer = ">=0.9.0"
typing-extensions = "^4.7.1"

[tool.poetry.group.docs.dependencies]
sphinx = "~6.2.1"
Expand Down
2 changes: 1 addition & 1 deletion pythontemplate/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .cli.main import run_app

run_app(prog_name="pythontemplate")
run_app()
21 changes: 12 additions & 9 deletions pythontemplate/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import typer
from typer import Option
from typing_extensions import Annotated

import pythontemplate

Expand All @@ -18,16 +19,18 @@ def version_callback(value: bool):
@app.callback()
def common(
ctx: typer.Context,
version: bool = Option(
None,
"--version",
"-v",
callback=version_callback,
help="Print pythontemplate version.",
),
version: Annotated[
bool,
Option(
"--version",
"-v",
callback=version_callback,
help="Print gnwmanager version.",
),
] = False,
):
pass


def run_app(*args, **kwargs):
app(*args, **kwargs)
def run_app():
app(prog_name="pythontemplate")

0 comments on commit 8269109

Please sign in to comment.