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
1 change: 0 additions & 1 deletion .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
- {name: Random 3.13, python: '3.13', tox: random}
- {name: Random 3.12, python: '3.12', tox: random}
- {name: Random 3.11, python: '3.11', tox: random}
- {name: Random 3.10, python: '3.10', tox: random}
- {name: Random Windows, python: '3.15', tox: random, os: windows-latest}
- {name: Random Mac, python: '3.15', tox: random, os: macos-latest}
- {name: Stress 3.15, python: '3.15', tox: stress-py3.15}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
- {python: '3.13'}
- {python: '3.12'}
- {python: '3.11'}
- {python: '3.10'}
- {name: PyPy, python: 'pypy-3.11', tox: pypy3.11}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Unreleased

- Drop support for Python 3.10. {pr}`3920`
- A parameter name that is not a valid Python identifier, or that is a Python
keyword, is deprecated and raises `TypeError` in Click 9.0. {pr}`3866`
- An {class}`Option` name written as a Python identifier is deprecated when it
Expand Down
2 changes: 1 addition & 1 deletion examples/aliases/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "click-example-aliases"
version = "1.0.0"
description = "Click aliases example"
requires-python = ">=3.10"
requires-python = ">=3.11"
dependencies = [
"click>=8.1",
]
Expand Down
2 changes: 1 addition & 1 deletion examples/colors/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "click-example-colors"
version = "1.0.0"
description = "Click colors example"
requires-python = ">=3.10"
requires-python = ">=3.11"
dependencies = [
"click>=8.1",
]
Expand Down
2 changes: 1 addition & 1 deletion examples/completion/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "click-example-completion"
version = "1.0.0"
description = "Click completion example"
requires-python = ">=3.10"
requires-python = ">=3.11"
dependencies = [
"click>=8.1",
]
Expand Down
2 changes: 1 addition & 1 deletion examples/complex/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "click-example-complex"
version = "1.0.0"
description = "Click complex example"
requires-python = ">=3.10"
requires-python = ">=3.11"
dependencies = [
"click>=8.1",
]
Expand Down
2 changes: 1 addition & 1 deletion examples/imagepipe/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "click-example-imagepipe"
version = "1.0.0"
description = "Click imagepipe example"
requires-python = ">=3.10"
requires-python = ">=3.11"
dependencies = [
"click>=8.1",
"pillow",
Expand Down
2 changes: 1 addition & 1 deletion examples/inout/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "click-example-inout"
version = "1.0.0"
description = "Click inout example"
requires-python = ">=3.10"
requires-python = ">=3.11"
dependencies = [
"click>=8.1",
]
Expand Down
2 changes: 1 addition & 1 deletion examples/naval/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "click-example-naval"
version = "1.0.0"
description = "Click naval example"
requires-python = ">=3.10"
requires-python = ">=3.11"
dependencies = [
"click>=8.1",
]
Expand Down
2 changes: 1 addition & 1 deletion examples/repo/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "click-example-repo"
version = "1.0.0"
description = "Click repo example"
requires-python = ">=3.10"
requires-python = ">=3.11"
dependencies = [
"click>=8.1",
]
Expand Down
2 changes: 1 addition & 1 deletion examples/termui/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "click-example-termui"
version = "1.0.0"
description = "Click termui example"
requires-python = ">=3.10"
requires-python = ">=3.11"
dependencies = [
"click>=8.1",
]
Expand Down
2 changes: 1 addition & 1 deletion examples/validation/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "click-example-validation"
version = "1.0.0"
description = "Click validation example"
requires-python = ">=3.10"
requires-python = ">=3.11"
dependencies = [
"click>=8.1",
]
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ classifiers = [
"Programming Language :: Python",
"Typing :: Typed",
]
requires-python = ">=3.10"
requires-python = ">=3.11"

[project.urls]
Donate = "https://palletsprojects.com/donate"
Expand Down Expand Up @@ -105,14 +105,14 @@ exclude_also = [
]

[tool.mypy]
python_version = "3.10"
python_version = "3.11"
files = ["src", "tests/typing"]
show_error_codes = true
pretty = true
strict = true

[tool.pyright]
pythonVersion = "3.10"
pythonVersion = "3.11"
include = ["src", "tests/typing"]
typeCheckingMode = "basic"

Expand Down Expand Up @@ -144,7 +144,7 @@ order-by-type = false

[tool.tox]
env_list = [
"py3.15", "py3.14", "py3.13", "py3.12", "py3.11", "py3.10",
"py3.15", "py3.14", "py3.13", "py3.12", "py3.11",
"py3.15t",
"pypy3.11",
"stress-py3.15", "stress-py3.15t",
Expand Down
4 changes: 1 addition & 3 deletions src/click/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
from .utils import make_str

if t.TYPE_CHECKING:
from typing_extensions import Self

from .shell_completion import CompletionItem

F = t.TypeVar("F", bound="t.Callable[..., t.Any]")
Expand Down Expand Up @@ -575,7 +573,7 @@ def to_info_dict(self) -> dict[str, t.Any]:
"auto_envvar_prefix": self.auto_envvar_prefix,
}

def __enter__(self) -> Self:
def __enter__(self) -> t.Self:
self._depth += 1
push_context(self)
return self
Expand Down
18 changes: 7 additions & 11 deletions src/click/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@
from .globals import get_current_context
from .utils import echo

if t.TYPE_CHECKING:
import typing_extensions as te

P = te.ParamSpec("P")

P = t.ParamSpec("P")
R = t.TypeVar("R")
T = t.TypeVar("T")
_AnyCallable = t.Callable[..., t.Any]
FC = t.TypeVar("FC", bound="_AnyCallable | Command")


def pass_context(f: t.Callable[te.Concatenate[Context, P], R]) -> t.Callable[P, R]:
def pass_context(f: t.Callable[t.Concatenate[Context, P], R]) -> t.Callable[P, R]:
"""Marks a callback as wanting to receive the current context
object as first argument.
"""
Expand All @@ -36,7 +32,7 @@ def new_func(*args: P.args, **kwargs: P.kwargs) -> R:
return update_wrapper(new_func, f)


def pass_obj(f: t.Callable[te.Concatenate[T, P], R]) -> t.Callable[P, R]:
def pass_obj(f: t.Callable[t.Concatenate[T, P], R]) -> t.Callable[P, R]:
"""Similar to :func:`pass_context`, but only pass the object on the
context onwards (:attr:`Context.obj`). This is useful if that object
represents the state of a nested system.
Expand All @@ -50,7 +46,7 @@ def new_func(*args: P.args, **kwargs: P.kwargs) -> R:

def make_pass_decorator(
object_type: type[T], ensure: bool = False
) -> t.Callable[[t.Callable[te.Concatenate[T, P], R]], t.Callable[P, R]]:
) -> t.Callable[[t.Callable[t.Concatenate[T, P], R]], t.Callable[P, R]]:
"""Given an object type this creates a decorator that will work
similar to :func:`pass_obj` but instead of passing the object of the
current context, it will find the innermost context of type
Expand All @@ -73,7 +69,7 @@ def new_func(ctx, *args, **kwargs):
remembered on the context if it's not there yet.
"""

def decorator(f: t.Callable[te.Concatenate[T, P], R]) -> t.Callable[P, R]:
def decorator(f: t.Callable[t.Concatenate[T, P], R]) -> t.Callable[P, R]:
def new_func(*args: P.args, **kwargs: P.kwargs) -> R:
ctx = get_current_context()

Expand All @@ -99,7 +95,7 @@ def new_func(*args: P.args, **kwargs: P.kwargs) -> R:

def pass_meta_key(
key: str, *, doc_description: str | None = None
) -> t.Callable[[t.Callable[te.Concatenate[T, P], R]], t.Callable[P, R]]:
) -> t.Callable[[t.Callable[t.Concatenate[T, P], R]], t.Callable[P, R]]:
"""Create a decorator that passes a key from
:attr:`click.Context.meta` as the first argument to the decorated
function.
Expand All @@ -112,7 +108,7 @@ def pass_meta_key(
.. versionadded:: 8.0
"""

def decorator(f: t.Callable[te.Concatenate[T, P], R]) -> t.Callable[P, R]:
def decorator(f: t.Callable[t.Concatenate[T, P], R]) -> t.Callable[P, R]:
def new_func(*args: P.args, **kwargs: P.kwargs) -> R:
ctx = get_current_context()
obj = ctx.meta[key]
Expand Down
51 changes: 11 additions & 40 deletions src/click/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,8 @@ class CompositeParamType(ParamType[_ValueT_co]):
def arity(self) -> int: ... # type: ignore[override]


if t.TYPE_CHECKING:
# on Python 3.10 this will raise a TypeError

class FuncParamTypeInfoDict(
ParamTypeInfoDict,
t.Generic[_ValueT_contra, _ValueT_co],
):
func: t.Callable[[_ValueT_contra], _ValueT_co]
else:

class FuncParamTypeInfoDict(ParamTypeInfoDict):
func: t.Callable[[t.Any], t.Any]
class FuncParamTypeInfoDict(ParamTypeInfoDict, t.Generic[_ValueT_contra, _ValueT_co]):
func: t.Callable[[_ValueT_contra], _ValueT_co]


class FuncParamType(ParamType[_ValueT_co], t.Generic[_ValueT_contra, _ValueT_co]):
Expand Down Expand Up @@ -326,17 +316,9 @@ def __repr__(self) -> str:
return "STRING"


if t.TYPE_CHECKING:
# on Python 3.10 this will raise a TypeError

class ChoiceInfoDict(ParamTypeInfoDict, t.Generic[_ValueT_co]):
choices: tuple[_ValueT_co, ...]
case_sensitive: bool
else:

class ChoiceInfoDict(ParamTypeInfoDict):
choices: tuple[t.Any, ...]
case_sensitive: bool
class ChoiceInfoDict(ParamTypeInfoDict, t.Generic[_ValueT_co]):
choices: tuple[_ValueT_co, ...]
case_sensitive: bool


class Choice(ParamType[_ValueT_co], t.Generic[_ValueT_co]):
Expand Down Expand Up @@ -610,23 +592,12 @@ def convert(
)


if t.TYPE_CHECKING:
# on Python 3.10 this will raise a TypeError

class NumberRangeInfoDict(ParamTypeInfoDict, t.Generic[_FloatValueT_co]):
min: _FloatValueT_co | None
max: _FloatValueT_co | None
min_open: bool
max_open: bool
clamp: bool
else:

class NumberRangeInfoDict(ParamTypeInfoDict):
min: t.Any | None
max: t.Any | None
min_open: bool
max_open: bool
clamp: bool
class NumberRangeInfoDict(ParamTypeInfoDict, t.Generic[_FloatValueT_co]):
min: _FloatValueT_co | None
max: _FloatValueT_co | None
min_open: bool
max_open: bool
clamp: bool


class _NumberRangeBase(
Expand Down
6 changes: 1 addition & 5 deletions src/click/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
from ._compat import WIN
from .globals import resolve_color_default

if t.TYPE_CHECKING:
import typing_extensions as te

P = te.ParamSpec("P")

P = t.ParamSpec("P")
R = t.TypeVar("R")


Expand Down
2 changes: 1 addition & 1 deletion tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def cli(method):


def test_choice_argument_enum(runner):
class MyEnum(str, enum.Enum):
class MyEnum(enum.StrEnum):
FOO = "foo-value"
BAR = "bar-value"
BAZ = "baz-value"
Expand Down
3 changes: 0 additions & 3 deletions tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
from contextlib import nullcontext
from typing import Literal

if sys.version_info < (3, 11):
enum.StrEnum = enum.Enum # type: ignore[assignment]

import pytest

import click
Expand Down
2 changes: 1 addition & 1 deletion tests/typing/typing_aliased_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing_extensions import assert_type
from typing import assert_type

import click

Expand Down
2 changes: 1 addition & 1 deletion tests/typing/typing_confirmation_option.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""From https://click.palletsprojects.com/en/stable/options/#yes-parameters"""

from typing_extensions import assert_type
from typing import assert_type

import click

Expand Down
3 changes: 1 addition & 2 deletions tests/typing/typing_edit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from pathlib import Path

from typing_extensions import assert_type
from typing import assert_type

import click

Expand Down
2 changes: 1 addition & 1 deletion tests/typing/typing_group_kw_options.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing_extensions import assert_type
from typing import assert_type

import click

Expand Down
2 changes: 1 addition & 1 deletion tests/typing/typing_help_option.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing_extensions import assert_type
from typing import assert_type

import click

Expand Down
2 changes: 1 addition & 1 deletion tests/typing/typing_options.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""From https://click.palletsprojects.com/en/stable/quickstart/#adding-parameters"""

from typing_extensions import assert_type
from typing import assert_type

import click

Expand Down
3 changes: 1 addition & 2 deletions tests/typing/typing_password_option.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import codecs

from typing_extensions import assert_type
from typing import assert_type

import click

Expand Down
3 changes: 1 addition & 2 deletions tests/typing/typing_path.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import pathlib

from typing_extensions import assert_type
from typing import assert_type

import click

Expand Down
Loading
Loading