mercurial/cext/parsers.pyi
author Matt Harbison <matt_harbison@yahoo.com>
Sat, 05 Oct 2024 17:32:26 -0400
changeset 51941 e58f02e2f6a9
parent 51406 f8bf1a8e9181
child 51968 8060257fd918
permissions -rw-r--r--
typing: add stub functions for `cext/charencoding` I'm not sure if it's better to have a separate file, and currently pytype doesn't really know how to handle these, so it's no help in figuring that out. Technically, these methods are part of the `mercurial.cext.parsers` module, so put them into the existing stub until there's a reason to split it out.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46038
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     1
from typing import (
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     2
    Callable,
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     3
    Dict,
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     4
    Iterator,
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     5
    List,
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     6
    Optional,
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     7
    Set,
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     8
    Tuple,
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     9
    Union,
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    10
)
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    11
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    12
version: int
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    13
versionerrortext: str
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    14
51941
e58f02e2f6a9 typing: add stub functions for `cext/charencoding`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51406
diff changeset
    15
# From charencode.c
e58f02e2f6a9 typing: add stub functions for `cext/charencoding`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51406
diff changeset
    16
e58f02e2f6a9 typing: add stub functions for `cext/charencoding`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51406
diff changeset
    17
# Note: the first 'bytes' arg of isasciistr() can be typed as 'Buffer' from the
e58f02e2f6a9 typing: add stub functions for `cext/charencoding`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51406
diff changeset
    18
# typing_extensions backport, once the related bug is fixed in pytype, or pytype
e58f02e2f6a9 typing: add stub functions for `cext/charencoding`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51406
diff changeset
    19
# is run under py3.12.  The arg for asciilower(), asciiupper() and
e58f02e2f6a9 typing: add stub functions for `cext/charencoding`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51406
diff changeset
    20
# jsonescapeu8fast() is checked specifically for the 'bytes' type.  The 'bytes'
e58f02e2f6a9 typing: add stub functions for `cext/charencoding`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51406
diff changeset
    21
# return is an instance of 'bytes', not an alias for 'Buffer'.
e58f02e2f6a9 typing: add stub functions for `cext/charencoding`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51406
diff changeset
    22
#
e58f02e2f6a9 typing: add stub functions for `cext/charencoding`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51406
diff changeset
    23
# https://github.com/google/pytype/issues/1772
e58f02e2f6a9 typing: add stub functions for `cext/charencoding`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51406
diff changeset
    24
def isasciistr(s: bytes) -> bool: ...
e58f02e2f6a9 typing: add stub functions for `cext/charencoding`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51406
diff changeset
    25
def asciilower(s: bytes) -> bytes: ...
e58f02e2f6a9 typing: add stub functions for `cext/charencoding`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51406
diff changeset
    26
def asciiupper(s: bytes) -> bytes: ...
e58f02e2f6a9 typing: add stub functions for `cext/charencoding`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51406
diff changeset
    27
def jsonescapeu8fast(u8chars: bytes, paranoid: bool) -> bytes: ...
e58f02e2f6a9 typing: add stub functions for `cext/charencoding`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51406
diff changeset
    28
e58f02e2f6a9 typing: add stub functions for `cext/charencoding`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51406
diff changeset
    29
47539
84391ddf4c78 dirstate-item: rename the class to DirstateItem
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47043
diff changeset
    30
class DirstateItem:
46038
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    31
    __doc__: str
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    32
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    33
    def __len__(self) -> int: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    34
    def __getitem__(self, key: int) -> Union[bytes, int]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    35
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    36
# From dirs.c
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    37
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    38
class dirs:
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    39
    __doc__: str
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    40
    def __init__(self, source, skipchar: bytes): ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    41
    def __iter__(self) -> Iterator[bytes]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    42
    def addpath(self, path: bytes) -> None: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    43
    def delpath(self, path: bytes) -> None: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    44
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    45
# From manifest.c
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    46
class lazymanifest:
47043
12450fbea288 manifests: push down expected node length into the parser
Joerg Sonnenberger <joerg@bec.de>
parents: 46038
diff changeset
    47
    def __init__(self, nodelen: int, data: bytes): ...
46038
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    48
    def __iter__(self) -> Iterator[bytes]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    49
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    50
    def __len__(self) -> int: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    51
    def __getitem__(self, item: bytes) -> Optional[Tuple[bytes, bytes]]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    52
    def __setitem__(self, key: bytes, value: Tuple[bytes, bytes]) -> None: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    53
    def __delitem__(self, key: bytes) -> None: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    54
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    55
    def iterkeys(self) -> Iterator[bytes]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    56
    def iterentries(self) -> Iterator[Tuple[bytes, bytes, bytes]]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    57
    def copy(self) -> lazymanifest: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    58
    def filtercopy(self, matchfn: Callable[[bytes], bool]) -> lazymanifest: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    59
    def diff(self, other: lazymanifest, clean: Optional[bool]) -> Dict[bytes, Tuple[bytes, Tuple]]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    60
    def text(self) -> bytes: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    61
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    62
# From revlog.c
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    63
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    64
class index:
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    65
    __doc__: str
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    66
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    67
    nodemap: Dict[bytes, int]
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    68
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    69
    def ancestors(self, *args: int) -> Iterator[int]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    70
    def commonancestorsheads(self, *args: int) -> List[int]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    71
    def clearcaches(self) -> None: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    72
    def get(self, value: bytes) -> Optional[int]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    73
    def get_rev(self, value: bytes) -> Optional[int]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    74
    def has_node(self, value: Union[int, bytes]) -> bool: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    75
    def rev(self, node: bytes) -> int: ...
51406
f8bf1a8e9181 phases: keep internal state as rev-num instead of node-id
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49649
diff changeset
    76
    def computephasesmapsets(self, root: Dict[int, Set[int]]) -> Tuple[int, Dict[int, Set[bytes]]]: ...
46038
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    77
    def reachableroots2(self, minroot: int, heads: List[int], roots: List[int], includepath: bool) -> List[int]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    78
    def headrevs(self, filteredrevs: Optional[List[int]]) -> List[int]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    79
    def headrevsfiltered(self, filteredrevs: Optional[List[int]]) -> List[int]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    80
    def issnapshot(self, value: int) -> bool: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    81
    def findsnapshots(self, cache: Dict[int, List[int]], start_rev: int) -> None: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    82
    def deltachain(self, rev: int, stop: int, generaldelta: bool) -> Tuple[List[int], bool]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    83
    def slicechunktodensity(self, revs: List[int], targetdensity: float, mingapsize: int) -> List[List[int]]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    84
    def append(self, value: Tuple[int, int, int, int, int, int, int, bytes]) -> None: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    85
    def partialmatch(self, node: bytes) -> bytes: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    86
    def shortest(self, value: bytes) -> int: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    87
    def stats(self) -> Dict[bytes, int]: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    88
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    89
class nodetree:
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    90
    __doc__: str
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    91
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    92
    def insert(self, rev: int) -> None: ...
8dca9051a859 cext: add .pyi files for C extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    93
    def shortest(self, node: bytes) -> int: ...
49649
df5d3b0d6472 typing: add missing signature for mercurial.cext.parsers.parse_index2()
Matt Harbison <matt_harbison@yahoo.com>
parents: 47539
diff changeset
    94
df5d3b0d6472 typing: add missing signature for mercurial.cext.parsers.parse_index2()
Matt Harbison <matt_harbison@yahoo.com>
parents: 47539
diff changeset
    95
# The IndexObject type here is defined in C, and there's no type for a buffer
df5d3b0d6472 typing: add missing signature for mercurial.cext.parsers.parse_index2()
Matt Harbison <matt_harbison@yahoo.com>
parents: 47539
diff changeset
    96
# return, as of py3.11.  https://github.com/python/typing/issues/593
df5d3b0d6472 typing: add missing signature for mercurial.cext.parsers.parse_index2()
Matt Harbison <matt_harbison@yahoo.com>
parents: 47539
diff changeset
    97
def parse_index2(data: object, inline: object, format: int = ...) -> Tuple[object, Optional[Tuple[int, object]]]: ...