mercurial/typelib.py
author Matt Harbison <matt_harbison@yahoo.com>
Fri, 04 Oct 2024 01:40:35 -0400
changeset 51952 f4c038081561
parent 51864 1c5810ce737e
child 52102 82e2c99c84f3
permissions -rw-r--r--
run-tests: bump the default timeout on Windows to 4x the normal value There are a ridiculous number of tests that timeout on Windows with the 360 sec default (~60). And because of the bug where timed out tests still run to completion before the results are thrown away[1], the timeout does nothing but waste time, so there's no reason to try to find a lower value that still works. For reference on my system: # Ran 909 tests, 116 skipped, 119 failed. python hash seed: 2052473208 real 151m44.322s user 0m0.077s sys 0m0.046s [1] I thought that I wrote a bug for this, but search isn't finding it.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49793
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     1
# typelib.py - type hint aliases and support
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     2
#
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     3
# Copyright 2022 Matt Harbison <matt_harbison@yahoo.com>
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     4
#
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     5
# This software may be used and distributed according to the terms of the
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     6
# GNU General Public License version 2 or any later version.
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     7
51864
1c5810ce737e typing: add `from __future__ import annotations` to remaining source files
Matt Harbison <matt_harbison@yahoo.com>
parents: 51732
diff changeset
     8
from __future__ import annotations
1c5810ce737e typing: add `from __future__ import annotations` to remaining source files
Matt Harbison <matt_harbison@yahoo.com>
parents: 51732
diff changeset
     9
49793
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    10
import typing
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    11
51732
43460c311c0c typing: add trivial type hints to `mercurial.scmutil`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51716
diff changeset
    12
from typing import (
43460c311c0c typing: add trivial type hints to `mercurial.scmutil`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51716
diff changeset
    13
    Callable,
43460c311c0c typing: add trivial type hints to `mercurial.scmutil`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51716
diff changeset
    14
)
43460c311c0c typing: add trivial type hints to `mercurial.scmutil`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51716
diff changeset
    15
49793
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    16
# Note: this is slightly different from pycompat.TYPE_CHECKING, as using
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    17
# pycompat causes the BinaryIO_Proxy type to be resolved to ``object`` when
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    18
# used as the base class during a pytype run.
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    19
TYPE_CHECKING = typing.TYPE_CHECKING
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    20
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    21
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    22
# The BinaryIO class provides empty methods, which at runtime means that
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    23
# ``__getattr__`` on the proxy classes won't get called for the methods that
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    24
# should delegate to the internal object.  So to avoid runtime changes because
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    25
# of the required typing inheritance, just use BinaryIO when typechecking, and
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    26
# ``object`` otherwise.
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    27
if TYPE_CHECKING:
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    28
    from typing import (
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    29
        BinaryIO,
51716
f3b34386d3e0 typing: add type hints to `mercurial.dirstatemap`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49793
diff changeset
    30
        Union,
f3b34386d3e0 typing: add type hints to `mercurial.dirstatemap`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49793
diff changeset
    31
    )
f3b34386d3e0 typing: add type hints to `mercurial.dirstatemap`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49793
diff changeset
    32
f3b34386d3e0 typing: add type hints to `mercurial.dirstatemap`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49793
diff changeset
    33
    from . import (
f3b34386d3e0 typing: add type hints to `mercurial.dirstatemap`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49793
diff changeset
    34
        node,
f3b34386d3e0 typing: add type hints to `mercurial.dirstatemap`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49793
diff changeset
    35
        posix,
f3b34386d3e0 typing: add type hints to `mercurial.dirstatemap`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49793
diff changeset
    36
        windows,
49793
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    37
    )
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    38
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    39
    BinaryIO_Proxy = BinaryIO
51716
f3b34386d3e0 typing: add type hints to `mercurial.dirstatemap`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49793
diff changeset
    40
    CacheStat = Union[posix.cachestat, windows.cachestat]
f3b34386d3e0 typing: add type hints to `mercurial.dirstatemap`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49793
diff changeset
    41
    NodeConstants = node.sha1nodeconstants
49793
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    42
else:
51716
f3b34386d3e0 typing: add type hints to `mercurial.dirstatemap`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49793
diff changeset
    43
    from typing import Any
f3b34386d3e0 typing: add type hints to `mercurial.dirstatemap`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49793
diff changeset
    44
49793
8147abc05794 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    45
    BinaryIO_Proxy = object
51716
f3b34386d3e0 typing: add type hints to `mercurial.dirstatemap`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49793
diff changeset
    46
    CacheStat = Any
f3b34386d3e0 typing: add type hints to `mercurial.dirstatemap`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49793
diff changeset
    47
    NodeConstants = Any
51732
43460c311c0c typing: add trivial type hints to `mercurial.scmutil`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51716
diff changeset
    48
43460c311c0c typing: add trivial type hints to `mercurial.scmutil`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51716
diff changeset
    49
# scmutil.getuipathfn() related callback.
43460c311c0c typing: add trivial type hints to `mercurial.scmutil`
Matt Harbison <matt_harbison@yahoo.com>
parents: 51716
diff changeset
    50
UiPathFn = Callable[[bytes], bytes]