File: shlex.pyi

package info (click to toggle)
typeshed 0.0~git20241223.ea91db2-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 28,756 kB
  • sloc: python: 7,741; makefile: 20; sh: 18
file content (63 lines) | stat: -rw-r--r-- 2,191 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import sys
from collections import deque
from collections.abc import Iterable
from io import TextIOWrapper
from typing import Literal, Protocol, overload, type_check_only
from typing_extensions import Self, deprecated

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

@type_check_only
class _ShlexInstream(Protocol):
    def read(self, size: Literal[1], /) -> str: ...
    def readline(self) -> object: ...
    def close(self) -> object: ...

if sys.version_info >= (3, 12):
    def split(s: str | _ShlexInstream, comments: bool = False, posix: bool = True) -> list[str]: ...

else:
    @overload
    def split(s: str | _ShlexInstream, 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: ...

# TODO: Make generic over infile once PEP 696 is implemented.
class shlex:
    commenters: str
    wordchars: str
    whitespace: str
    escape: str
    quotes: str
    escapedquotes: str
    whitespace_split: bool
    infile: str | None
    instream: _ShlexInstream
    source: str
    debug: int
    lineno: int
    token: str
    filestack: deque[tuple[str | None, _ShlexInstream, int]]
    eof: str | None
    @property
    def punctuation_chars(self) -> str: ...
    def __init__(
        self,
        instream: str | _ShlexInstream | None = None,
        infile: str | None = None,
        posix: bool = False,
        punctuation_chars: bool | str = False,
    ) -> None: ...
    def get_token(self) -> str | None: ...
    def push_token(self, tok: str) -> None: ...
    def read_token(self) -> str | None: ...
    def sourcehook(self, newfile: str) -> tuple[str, TextIOWrapper] | None: ...
    def push_source(self, newstream: str | _ShlexInstream, newfile: str | None = None) -> None: ...
    def pop_source(self) -> None: ...
    def error_leader(self, infile: str | None = None, lineno: int | None = None) -> str: ...
    def __iter__(self) -> Self: ...
    def __next__(self) -> str: ...