##// END OF EJS Templates
rust-pyo3: change the name of the Python module to pyo3_rustext...
rust-pyo3: change the name of the Python module to pyo3_rustext Two reasons for doing so - `pyo3-rustext` is not a valid Python identifier, hence the module could only be imported with `__import__("mercurial.pyo3-rustext")` and then retrieved by getattr. Normal usage is throught `mercurial.policy`. Hovever manual testing for development and perhaps unit tests can benefit a more natural way of doing. - The module's `__name__` attribute was already `pyo3_rustext`. This can lead to some discrepancies, in particular when we introduce submodules.

File last commit:

r52995:82e2c99c default
r53303:c28ba6fb default
Show More
typelib.py
55 lines | 1.4 KiB | text/x-python | PythonLexer
# typelib.py - type hint aliases and support
#
# Copyright 2022 Matt Harbison <matt_harbison@yahoo.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import annotations
import typing
from typing import (
Callable,
)
# Note: this is slightly different from pycompat.TYPE_CHECKING, as using
# pycompat causes the BinaryIO_Proxy type to be resolved to ``object`` when
# used as the base class during a pytype run.
TYPE_CHECKING = typing.TYPE_CHECKING
# The BinaryIO class provides empty methods, which at runtime means that
# ``__getattr__`` on the proxy classes won't get called for the methods that
# should delegate to the internal object. So to avoid runtime changes because
# of the required typing inheritance, just use BinaryIO when typechecking, and
# ``object`` otherwise.
if TYPE_CHECKING:
from typing import (
BinaryIO,
Union,
)
from . import (
node,
posix,
util,
windows,
)
BinaryIO_Proxy = BinaryIO
CacheStat = Union[
posix.cachestat,
windows.cachestat,
util.uncacheable_cachestat,
]
NodeConstants = node.sha1nodeconstants
else:
from typing import Any
BinaryIO_Proxy = object
CacheStat = Any
NodeConstants = Any
# scmutil.getuipathfn() related callback.
UiPathFn = Callable[[bytes], bytes]