Skip to content

Commit bb6613f

Browse files
authored
shlex.split: allow TextIO and deprecate None (#11451)
1 parent 84572bb commit bb6613f

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

stdlib/shlex.pyi

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1+
import sys
12
from collections.abc import Iterable
2-
from typing import TextIO
3-
from typing_extensions import Self
3+
from typing import TextIO, overload
4+
from typing_extensions import Self, deprecated
45

56
__all__ = ["shlex", "split", "quote", "join"]
67

7-
def split(s: str, comments: bool = False, posix: bool = True) -> list[str]: ...
8+
if sys.version_info >= (3, 12):
9+
def split(s: str | TextIO, comments: bool = False, posix: bool = True) -> list[str]: ...
10+
11+
else:
12+
@overload
13+
def split(s: str | TextIO, comments: bool = False, posix: bool = True) -> list[str]: ...
14+
@overload
15+
@deprecated("Passing None for 's' to shlex.split() is deprecated and will raise an error in Python 3.12.")
16+
def split(s: None, comments: bool = False, posix: bool = True) -> list[str]: ...
17+
818
def join(split_command: Iterable[str]) -> str: ...
919
def quote(s: str) -> str: ...
1020

0 commit comments

Comments
 (0)