Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tests/test_future_annotations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from __future__ import annotations

import typer
from typer.testing import CliRunner
from typing_extensions import Annotated

runner = CliRunner()


def test_annotated():
app = typer.Typer()

@app.command()
def cmd(force: Annotated[bool, typer.Option("--force")] = False):
if force:
print("Forcing operation")
else:
print("Not forcing")

result = runner.invoke(app)
assert result.exit_code == 0, result.output
assert "Not forcing" in result.output

result = runner.invoke(app, ["--force"])
assert result.exit_code == 0, result.output
assert "Forcing operation" in result.output
4 changes: 2 additions & 2 deletions typer/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import inspect
import sys
from copy import copy
from typing import Any, Callable, Dict, List, Tuple, Type, cast, get_type_hints
from typing import Any, Callable, Dict, List, Tuple, Type, cast

from typing_extensions import Annotated
from typing_extensions import Annotated, get_type_hints

from ._typing import get_args, get_origin
from .models import ArgumentInfo, OptionInfo, ParameterInfo, ParamMeta
Expand Down