Allow Python 2 unicode for some click interfaces (#4825)

Helps Python 2 code using:

    form __future__ import unicode_literals

On Python 2, these interfaces are compatible with both str and unicode.
This commit is contained in:
Jon Dufresne
2020-12-15 11:51:43 -08:00
committed by GitHub
parent 35d73ef277
commit 3ae99d153b
3 changed files with 7 additions and 7 deletions

View File

@@ -57,7 +57,7 @@ def group(
**kwargs: Any,
) -> Callable[[Callable[..., Any]], Group]: ...
def argument(
*param_decls: str,
*param_decls: Text,
cls: Type[Argument] = ...,
# Argument
required: Optional[bool] = ...,
@@ -74,7 +74,7 @@ def argument(
) -> _IdentityFunction: ...
@overload
def option(
*param_decls: str,
*param_decls: Text,
cls: Type[Option] = ...,
# Option
show_default: Union[bool, Text] = ...,
@@ -87,7 +87,7 @@ def option(
count: bool = ...,
allow_from_autoenv: bool = ...,
type: Optional[_ConvertibleType] = ...,
help: Optional[str] = ...,
help: Optional[Text] = ...,
show_choices: bool = ...,
# Parameter
default: Optional[Any] = ...,

View File

@@ -63,8 +63,8 @@ def progressbar(
def clear() -> None: ...
def style(
text: Text,
fg: Optional[str] = ...,
bg: Optional[str] = ...,
fg: Optional[Text] = ...,
bg: Optional[Text] = ...,
bold: Optional[bool] = ...,
dim: Optional[bool] = ...,
underline: Optional[bool] = ...,

View File

@@ -1,6 +1,6 @@
import datetime
import uuid
from typing import IO, Any, Callable, Generic, Iterable, List, Optional, Tuple as _PyTuple, Type, TypeVar, Union
from typing import IO, Any, Callable, Generic, Iterable, List, Optional, Text, Tuple as _PyTuple, Type, TypeVar, Union
from click.core import Context, Parameter, _ConvertibleType, _ParamType
@@ -31,7 +31,7 @@ class FloatRange(FloatParamType):
class File(ParamType):
def __init__(
self,
mode: str = ...,
mode: Text = ...,
encoding: Optional[str] = ...,
errors: Optional[str] = ...,
lazy: Optional[bool] = ...,