Skip to content
Myr

➖ Drop support for Python 3.8 (#1463)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sebastián Ramírez · committed by GitHub · parent 2108ffc · Browse files · 3 files+14 added−42 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Yurii Motov <yurii.motov.monte@gmail.com>

Diff stats

3 files+14 added−42 removed

  • other:+14 added−42 removed

3 files+14 added−42 removed

modified:.github/workflows/test.yml+2 added-4 removed
modified:typer/_typing.py+11 added-31 removed
1# Copied from pydantic 1.9.2 (the latest version to support python 3.6.)2# https://github.com/pydantic/pydantic/blob/v1.9.2/pydantic/typing.py3# Reduced drastically to only include Typer-specific 3.8+ functionality3# Reduced drastically to only include Typer-specific 3.9+ functionality4# mypy: ignore-errors56import sys7from typing import (8 Annotated,9 Any,10 Callable,11 Literal,12 Optional,13 Tuple,14 Type,15 Union,16 get_args,17 get_origin,18 get_type_hints,19)2016if sys.version_info >= (3, 9):17 from typing import Annotated, Literal, get_args, get_origin, get_type_hints18else:19 from typing_extensions import (20 Annotated,21 Literal,22 get_args,23 get_origin,24 get_type_hints,25 )2621if sys.version_info < (3, 10):2223 def is_union(tp: Optional[Type[Any]]) -> bool:24 return tp is Union
25 unmodified lines
5051NONE_TYPES: Tuple[Any, Any, Any] = (None, NoneType, Literal[None])525360if sys.version_info[:2] == (3, 8):61 # We can use the fast implementation for 3.8 but there is a very weird bug62 # where it can fail for `Literal[None]`.63 # We just need to redefine a useless `Literal[None]` inside the function body to fix this54def is_none_type(type_: Any) -> bool:55 for none_type in NONE_TYPES:56 if type_ is none_type:57 return True58 return False5965 def is_none_type(type_: Any) -> bool:66 Literal[None] # fix edge case67 for none_type in NONE_TYPES:68 if type_ is none_type:69 return True70 return False6072else:7374 def is_none_type(type_: Any) -> bool:75 for none_type in NONE_TYPES:76 if type_ is none_type:77 return True78 return False798061def is_callable_type(type_: Type[Any]) -> bool:62 return type_ is Callable or get_origin(type_) is Callable6364
21 unmodified lines
modified:typer/rich_utils.py+1 added-7 removed
1# Extracted and modified from https://github.com/ewels/rich-click23import inspect4import io5import sys5from collections import defaultdict6from gettext import gettext as _7from os import getenv9from typing import Any, DefaultDict, Dict, Iterable, List, Optional, Union8from typing import Any, DefaultDict, Dict, Iterable, List, Literal, Optional, Union910import click11from rich import box12from rich.align import Align
10 unmodified lines
23from rich.theme import Theme24from rich.traceback import Traceback25from typer.models import DeveloperExceptionConfig2628if sys.version_info >= (3, 9):29 from typing import Literal30else:31 from typing_extensions import Literal3227# Default styles28STYLE_OPTION = "bold cyan"29STYLE_SWITCH = "bold green"30STYLE_NEGATIVE_OPTION = "bold magenta"
721 unmodified lines