From c453d8bae46b5fa3a6c496391b1325280be8dc39 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 18 Feb 2024 23:43:43 -0500 Subject: [PATCH] shlex.plit: allow TextIO and deprecate None --- stdlib/shlex.pyi | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/stdlib/shlex.pyi b/stdlib/shlex.pyi index 3fda03b5694a..6d395971e9c6 100644 --- a/stdlib/shlex.pyi +++ b/stdlib/shlex.pyi @@ -1,10 +1,20 @@ +import sys from collections.abc import Iterable -from typing import TextIO -from typing_extensions import Self +from typing import TextIO, overload +from typing_extensions import Self, deprecated __all__ = ["shlex", "split", "quote", "join"] -def split(s: str, comments: bool = False, posix: bool = True) -> list[str]: ... +if sys.version_info >= (3, 12): + def split(s: str | TextIO, comments: bool = False, posix: bool = True) -> list[str]: ... + +else: + @overload + def split(s: str | TextIO, comments: bool = False, posix: bool = True) -> list[str]: ... + @overload + @deprecated("Passing None for 's' to shlex.split() is deprecated and will raise an error in Python 3.12.") + def split(s: None, comments: bool = False, posix: bool = True) -> list[str]: ... + def join(split_command: Iterable[str]) -> str: ... def quote(s: str) -> str: ...