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

🔥 Drop support for Python 3.7 #830

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
os: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: [ "3.12" ]
include:
- os: ubuntu-22.04
python-version: "3.7"
- os: macos-latest
python-version: "3.8"
- os: windows-latest
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "Typer, build great CLIs. Easy to code. Based on Python type hints
authors = [
{name = "Sebastián Ramírez", email = "[email protected]"},
]
requires-python = ">=3.7"
requires-python = ">=3.8"
classifiers = [
"Intended Audience :: Information Technology",
"Intended Audience :: System Administrators",
Expand All @@ -24,7 +24,6 @@ classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down
14 changes: 2 additions & 12 deletions typer/_typing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copied from pydantic 1.9.2 (the latest version to support python 3.6.)
# https://github.com/pydantic/pydantic/blob/v1.9.2/pydantic/typing.py
# Reduced drastically to only include Typer-specific 3.7+ functionality
# Reduced drastically to only include Typer-specific 3.8+ functionality
# mypy: ignore-errors

import sys
Expand Down Expand Up @@ -43,17 +43,7 @@ def is_union(tp: Optional[Type[Any]]) -> bool:
NONE_TYPES: Tuple[Any, Any, Any] = (None, NoneType, Literal[None])


if sys.version_info < (3, 8):
# Even though this implementation is slower, we need it for python 3.7:
# In python 3.7 "Literal" is not a builtin type and uses a different
# mechanism.
# for this reason `Literal[None] is Literal[None]` evaluates to `False`,
# breaking the faster implementation used for the other python versions.

def is_none_type(type_: Any) -> bool:
return type_ in NONE_TYPES

elif sys.version_info[:2] == (3, 8):
if sys.version_info[:2] == (3, 8):
# We can use the fast implementation for 3.8 but there is a very weird bug
# where it can fail for `Literal[None]`.
# We just need to redefine a useless `Literal[None]` inside the function body to fix this
Expand Down
6 changes: 1 addition & 5 deletions typer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Callable,
Dict,
List,
Literal,
MutableMapping,
Optional,
Sequence,
Expand All @@ -26,11 +27,6 @@
import click.types
import click.utils

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

MarkupMode = Literal["markdown", "rich", None]

try:
Expand Down
8 changes: 1 addition & 7 deletions typer/rich_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import inspect
import io
import sys
from collections import defaultdict
from gettext import gettext as _
from os import getenv
from typing import Any, DefaultDict, Dict, Iterable, List, Optional, Union
from typing import Any, DefaultDict, Dict, Iterable, List, Literal, Optional, Union

import click
from rich import box
Expand All @@ -22,11 +21,6 @@
from rich.text import Text
from rich.theme import Theme

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

# Default styles
STYLE_OPTION = "bold cyan"
STYLE_SWITCH = "bold green"
Expand Down
Loading