Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Avoid the unnecessary import of typing_extensions in newer Python versions #1048

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
5 changes: 4 additions & 1 deletion typer/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
Union,
)

from typing_extensions import Literal, get_args, get_origin
if sys.version_info >= (3, 9):
from typing import Literal, get_args, get_origin
else:
from typing_extensions import Literal, get_args, get_origin

if sys.version_info < (3, 10):

Expand Down
6 changes: 5 additions & 1 deletion typer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
from uuid import UUID

import click
from typing_extensions import get_args, get_origin

if sys.version_info >= (3, 9):
from typing import get_args, get_origin
else:
from typing_extensions import get_args, get_origin

from ._typing import is_union
horta marked this conversation as resolved.
Show resolved Hide resolved
from .completion import get_completion_inspect_parameters
Expand Down
5 changes: 4 additions & 1 deletion typer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from copy import copy
from typing import Any, Callable, Dict, List, Tuple, Type, cast

from typing_extensions import Annotated, get_args, get_origin, get_type_hints
if sys.version_info >= (3, 9):
from typing import Annotated, get_args, get_origin, get_type_hints
else:
from typing_extensions import Annotated, get_args, get_origin, get_type_hints

from .models import ArgumentInfo, OptionInfo, ParameterInfo, ParamMeta

Expand Down
Loading