From de5ec6a0d14351797a54b12b3910534b67df609e Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 22 Jan 2022 09:37:14 -0800 Subject: [PATCH] fix incorrect tuple[T] (#6996) Found from PyCQA/flake8-pyi#135. --- stdlib/@python2/distutils/cmd.pyi | 2 +- stdlib/@python2/imaplib.pyi | 4 ++-- stdlib/@python2/parser.pyi | 4 ++-- stdlib/distutils/cmd.pyi | 2 +- stdlib/imaplib.pyi | 4 ++-- stdlib/logging/handlers.pyi | 2 +- stdlib/unittest/util.pyi | 2 +- stubs/Pillow/PIL/Image.pyi | 2 +- stubs/Pygments/@tests/stubtest_allowlist.txt | 4 ---- stubs/Pygments/pygments/lexer.pyi | 2 +- stubs/Pygments/pygments/token.pyi | 2 +- stubs/dateparser/dateparser/__init__.pyi | 6 +++--- stubs/dateparser/dateparser/date.pyi | 16 ++++++++-------- 13 files changed, 24 insertions(+), 28 deletions(-) diff --git a/stdlib/@python2/distutils/cmd.pyi b/stdlib/@python2/distutils/cmd.pyi index 3b5b85912..096414713 100644 --- a/stdlib/@python2/distutils/cmd.pyi +++ b/stdlib/@python2/distutils/cmd.pyi @@ -57,7 +57,7 @@ class Command: ) -> str: ... def make_file( self, - infiles: str | list[str] | tuple[str], + infiles: str | list[str] | tuple[str, ...], outfile: str, func: Callable[..., Any], args: list[Any], diff --git a/stdlib/@python2/imaplib.pyi b/stdlib/@python2/imaplib.pyi index b7e455f45..fc17ca0aa 100644 --- a/stdlib/@python2/imaplib.pyi +++ b/stdlib/@python2/imaplib.pyi @@ -28,7 +28,7 @@ class IMAP4: tagpre: str = ... tagre: Pattern[Text] = ... welcome: bytes = ... - capabilities: tuple[str] = ... + capabilities: tuple[str, ...] = ... PROTOCOL_VERSION: str = ... def __init__(self, host: str = ..., port: int = ...) -> None: ... def open(self, host: str = ..., port: int = ...) -> None: ... @@ -127,5 +127,5 @@ class _Authenticator: def Internaldate2tuple(resp: str) -> time.struct_time: ... def Int2AP(num: int) -> str: ... -def ParseFlags(resp: str) -> tuple[str]: ... +def ParseFlags(resp: str) -> tuple[str, ...]: ... def Time2Internaldate(date_time: float | time.struct_time | str) -> str: ... diff --git a/stdlib/@python2/parser.pyi b/stdlib/@python2/parser.pyi index 73ebff4c4..de88bc0ba 100644 --- a/stdlib/@python2/parser.pyi +++ b/stdlib/@python2/parser.pyi @@ -6,7 +6,7 @@ def suite(source: Text) -> STType: ... def sequence2st(sequence: Sequence[Any]) -> STType: ... def tuple2st(sequence: Sequence[Any]) -> STType: ... def st2list(st: STType, line_info: bool = ..., col_info: bool = ...) -> list[Any]: ... -def st2tuple(st: STType, line_info: bool = ..., col_info: bool = ...) -> tuple[Any]: ... +def st2tuple(st: STType, line_info: bool = ..., col_info: bool = ...) -> tuple[Any, ...]: ... def compilest(st: STType, filename: Text = ...) -> CodeType: ... def isexpr(st: STType) -> bool: ... def issuite(st: STType) -> bool: ... @@ -18,4 +18,4 @@ class STType: def isexpr(self) -> bool: ... def issuite(self) -> bool: ... def tolist(self, line_info: bool = ..., col_info: bool = ...) -> list[Any]: ... - def totuple(self, line_info: bool = ..., col_info: bool = ...) -> tuple[Any]: ... + def totuple(self, line_info: bool = ..., col_info: bool = ...) -> tuple[Any, ...]: ... diff --git a/stdlib/distutils/cmd.pyi b/stdlib/distutils/cmd.pyi index 875e851be..96a048c93 100644 --- a/stdlib/distutils/cmd.pyi +++ b/stdlib/distutils/cmd.pyi @@ -57,7 +57,7 @@ class Command: ) -> str: ... def make_file( self, - infiles: str | list[str] | tuple[str], + infiles: str | list[str] | tuple[str, ...], outfile: str, func: Callable[..., Any], args: list[Any], diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index 33b99239e..f0ae1a60f 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -32,7 +32,7 @@ class IMAP4: tagpre: str tagre: Pattern[str] welcome: bytes - capabilities: tuple[str] + capabilities: tuple[str, ...] PROTOCOL_VERSION: str if sys.version_info >= (3, 9): def __init__(self, host: str = ..., port: int = ..., timeout: float | None = ...) -> None: ... @@ -165,5 +165,5 @@ class _Authenticator: def Internaldate2tuple(resp: str) -> time.struct_time: ... def Int2AP(num: int) -> str: ... -def ParseFlags(resp: str) -> tuple[str]: ... +def ParseFlags(resp: str) -> tuple[str, ...]: ... def Time2Internaldate(date_time: float | time.struct_time | str) -> str: ... diff --git a/stdlib/logging/handlers.pyi b/stdlib/logging/handlers.pyi index 50d6d0583..7cd971f61 100644 --- a/stdlib/logging/handlers.pyi +++ b/stdlib/logging/handlers.pyi @@ -254,7 +254,7 @@ class QueueHandler(Handler): def enqueue(self, record: LogRecord) -> None: ... class QueueListener: - handlers: tuple[Handler] # undocumented + handlers: tuple[Handler, ...] # undocumented respect_handler_level: bool # undocumented if sys.version_info >= (3, 7): queue: SimpleQueue[Any] | Queue[Any] # undocumented diff --git a/stdlib/unittest/util.pyi b/stdlib/unittest/util.pyi index 680ca24b7..30ab6061b 100644 --- a/stdlib/unittest/util.pyi +++ b/stdlib/unittest/util.pyi @@ -11,7 +11,7 @@ _MIN_COMMON_LEN: int _MIN_DIFF_LEN: int def _shorten(s: str, prefixlen: int, suffixlen: int) -> str: ... -def _common_shorten_repr(*args: str) -> tuple[str]: ... +def _common_shorten_repr(*args: str) -> tuple[str, ...]: ... def safe_repr(obj: object, short: bool = ...) -> str: ... def strclass(cls: type) -> str: ... def sorted_list_difference(expected: Sequence[_T], actual: Sequence[_T]) -> tuple[list[_T], list[_T]]: ... diff --git a/stubs/Pillow/PIL/Image.pyi b/stubs/Pillow/PIL/Image.pyi index fddbb2385..05d9b767f 100644 --- a/stubs/Pillow/PIL/Image.pyi +++ b/stubs/Pillow/PIL/Image.pyi @@ -227,7 +227,7 @@ def fromarray(obj, mode: _Mode | None = ...) -> Image: ... def fromqimage(im) -> Image: ... def fromqpixmap(im) -> Image: ... def open( - fp: str | bytes | Path | SupportsRead[bytes], mode: Literal["r"] = ..., formats: list[str] | tuple[str] | None = ... + fp: str | bytes | Path | SupportsRead[bytes], mode: Literal["r"] = ..., formats: list[str] | tuple[str, ...] | None = ... ) -> Image: ... def alpha_composite(im1: Image, im2: Image) -> Image: ... def blend(im1: Image, im2: Image, alpha: float) -> Image: ... diff --git a/stubs/Pygments/@tests/stubtest_allowlist.txt b/stubs/Pygments/@tests/stubtest_allowlist.txt index 2d07b5ad5..f72c29ab5 100644 --- a/stubs/Pygments/@tests/stubtest_allowlist.txt +++ b/stubs/Pygments/@tests/stubtest_allowlist.txt @@ -7,7 +7,3 @@ pygments.lexer.LexerMeta.analyse_text # Inheriting from tuple is weird pygments.token._TokenType.__init__ -pygments.token.Number -pygments.token.String -pygments.token.Token -pygments.token.Whitespace diff --git a/stubs/Pygments/pygments/lexer.pyi b/stubs/Pygments/pygments/lexer.pyi index 379ba5308..6267debf3 100644 --- a/stubs/Pygments/pygments/lexer.pyi +++ b/stubs/Pygments/pygments/lexer.pyi @@ -40,7 +40,7 @@ class _inherit: ... inherit: Any -class combined(tuple[Any]): +class combined(tuple[Any, ...]): def __new__(cls, *args): ... def __init__(self, *args) -> None: ... diff --git a/stubs/Pygments/pygments/token.pyi b/stubs/Pygments/pygments/token.pyi index 67c5506f0..94468ba3e 100644 --- a/stubs/Pygments/pygments/token.pyi +++ b/stubs/Pygments/pygments/token.pyi @@ -1,6 +1,6 @@ from collections.abc import Mapping -class _TokenType(tuple[str]): +class _TokenType(tuple[str, ...]): parent: _TokenType | None def split(self) -> list[_TokenType]: ... subtypes: set[_TokenType] diff --git a/stubs/dateparser/dateparser/__init__.pyi b/stubs/dateparser/dateparser/__init__.pyi index fcee04715..aa7bea1cf 100644 --- a/stubs/dateparser/dateparser/__init__.pyi +++ b/stubs/dateparser/dateparser/__init__.pyi @@ -33,9 +33,9 @@ class _Settings(TypedDict, total=False): def parse( date_string: str, - date_formats: list[str] | tuple[str] | set[str] | None = ..., - languages: list[str] | tuple[str] | set[str] | None = ..., - locales: list[str] | tuple[str] | set[str] | None = ..., + date_formats: list[str] | tuple[str, ...] | set[str] | None = ..., + languages: list[str] | tuple[str, ...] | set[str] | None = ..., + locales: list[str] | tuple[str, ...] | set[str] | None = ..., region: str | None = ..., settings: _Settings | None = ..., ) -> datetime.datetime | None: ... diff --git a/stubs/dateparser/dateparser/date.pyi b/stubs/dateparser/dateparser/date.pyi index 468a1fb31..e8d065d89 100644 --- a/stubs/dateparser/dateparser/date.pyi +++ b/stubs/dateparser/dateparser/date.pyi @@ -39,12 +39,12 @@ def parse_with_formats(date_string: str, date_formats: Iterable[str], settings: class _DateLocaleParser: locale: Locale date_string: str - date_formats: list[str] | tuple[str] | set[str] | None + date_formats: list[str] | tuple[str, ...] | set[str] | None def __init__( self, locale: Locale, date_string: str, - date_formats: list[str] | tuple[str] | set[str] | None, + date_formats: list[str] | tuple[str, ...] | set[str] | None, settings: Settings | None = ..., ) -> None: ... @classmethod @@ -52,7 +52,7 @@ class _DateLocaleParser: cls, locale: Locale, date_string: str, - date_formats: list[str] | tuple[str] | set[str] | None = ..., + date_formats: list[str] | tuple[str, ...] | set[str] | None = ..., settings: Settings | None = ..., ) -> DateData: ... def _parse(self) -> DateData | None: ... @@ -90,20 +90,20 @@ class DateDataParser: try_previous_locales: bool use_given_order: bool languages: list[str] | None - locales: list[str] | tuple[str] | set[str] | None + locales: list[str] | tuple[str, ...] | set[str] | None region: str previous_locales: collections.OrderedDict[Locale, None] def __init__( self, - languages: list[str] | tuple[str] | set[str] | None = ..., - locales: list[str] | tuple[str] | set[str] | None = ..., + languages: list[str] | tuple[str, ...] | set[str] | None = ..., + locales: list[str] | tuple[str, ...] | set[str] | None = ..., region: str | None = ..., try_previous_locales: bool = ..., use_given_order: bool = ..., settings: _Settings | None = ..., ) -> None: ... - def get_date_data(self, date_string: str, date_formats: list[str] | tuple[str] | set[str] | None = ...) -> DateData: ... - def get_date_tuple(self, date_string: str, date_formats: list[str] | tuple[str] | set[str] | None = ...): ... + def get_date_data(self, date_string: str, date_formats: list[str] | tuple[str, ...] | set[str] | None = ...) -> DateData: ... + def get_date_tuple(self, date_string: str, date_formats: list[str] | tuple[str, ...] | set[str] | None = ...): ... def _get_applicable_locales(self, date_string: str) -> Iterator[Locale]: ... def _is_applicable_locale(self, locale: Locale, date_string: str) -> bool: ... @classmethod