[PATCH py3 resend] py3: initial type hinting stubs

Martijn Pieters mj at zopatista.com
Wed Mar 15 14:11:23 EDT 2017


I had to resend this as I had overdialled the DMARC settings on my domain.
Standards, Y U no support mailinglist forwarding properly.

On 15 March 2017 at 11:09, Martijn Pieters <mj at zopatista.com> wrote:

> # HG changeset patch
> # User Martijn Pieters <mjpieters at fb.com>
> # Date 1489356745 25200
> #      Sun Mar 12 15:12:25 2017 -0700
> # Node ID c363e933a66bb85ddbfe8301bbfd246ecaad95d6
> # Parent  719e64bf9ec2d7b8e86b6550a5d193b3c67944d1
> py3: initial type hinting stubs
>
> These are stub files to be used by mypy and future tooling to check type
> hints
> in Python 3. These files are complete for the current state of the covered
> modules. Future tooling should ensure that these are kept in sync.
>
> diff --git a/types/.flake8 b/types/.flake8
> new file mode 100644
> --- /dev/null
> +++ b/types/.flake8
> @@ -0,0 +1,13 @@
> +# Some PEP8 deviations are considered irrelevant to stub files:
> +# E704 multiple statements on one line (def)
> +# E301 expected 1 blank line
> +# E302 expected 2 blank lines
> +# E501 line too long
> +# F401 imported but unused
> +# E701 multiple statements on one line (colon)
> +# F811 redefinition
> +# E305 expected 2 blank lines
> +
> +[flake8]
> +ignore = F401, F811, E301, E302, E305, E501, E701, E704, B303
> +
> diff --git a/types/mercurial/__init__.pyi b/types/mercurial/__init__.pyi
> new file mode 100644
> --- /dev/null
> +++ b/types/mercurial/__init__.pyi
> @@ -0,0 +1,22 @@
> +# Stubs for mercurial (Python 3.5)
> +#
> +# NOTE: This dynamically typed stub was automatically generated by
> stubgen.
> +
> +from tokenize import TokenInfo
> +from types import ModuleType
> +from typing import Any, Generator, Optional, Sequence, Union
> +import importlib.abc
> +import importlib.machinery
> +
> +modulepolicy = ...  # type: str
> +
> +# hgimporter is only used in Python 2
> +# class hgimporter: ...
> +
> +class hgpathentryfinder(importlib.abc.MetaPathFinder): ...
> +
> +def replacetokens(tokens: Sequence[TokenInfo], fullname: str) ->
> Generator[TokenInfo, None, None]: ...
> +
> +BYTECODEHEADER = ...  # type: bytes
> +
> +class hgloader(importlib.machinery.SourceFileLoader): ...
> diff --git a/types/mercurial/config.pyi b/types/mercurial/config.pyi
> new file mode 100644
> --- /dev/null
> +++ b/types/mercurial/config.pyi
> @@ -0,0 +1,27 @@
> +# Stubs for mercurial.config (Python 3.6)
> +#
> +# NOTE: This dynamically typed stub was automatically generated by
> stubgen.
> +
> +from typing import Any, BinaryIO, Callable, Container, Generator,
> ItemsView, List, Mapping, Optional, Sequence, Tuple, Union
> +from .i18n import _ as _
> +
> +# Config is backed up as a (section, item, value, source) tuple; a
> two-item tuple models a missing entry
> +_CfgBackup = Union[Tuple[bytes, bytes, Any, bytes], Tuple[bytes, bytes]]
> +
> +class config:
> +    def __init__(self, data: Optional[config] = ..., includepaths:
> Optional[Sequence[bytes]] = ...) -> None: ...
> +    def copy(self) -> config: ...
> +    def __contains__(self, section: bytes): ...
> +    def hasitem(self, section: bytes, item: bytes): ...
> +    def __getitem__(self, section: bytes): ...
> +    def __iter__(self) -> Generator[bytes, None, None]: ...
> +    def update(self, src: config) -> None: ...
> +    def get(self, section: bytes, item: bytes, default: Optional[Any] =
> ...) -> Optional[Any]: ...
> +    def backup(self, section: bytes, item: bytes) -> _CfgBackup: ...
> +    def source(self, section: bytes, item: bytes) -> bytes: ...
> +    def sections(self) -> List[bytes]: ...
> +    def items(self, section: bytes) -> ItemsView[bytes, Any]: ...
> +    def set(self, section: bytes, item: bytes, value: Any, source: bytes
> = ...) -> None: ...
> +    def restore(self, data: _CfgBackup) -> None: ...
> +    def parse(self, src: bytes, data: bytes, sections:
> Optional[Container[bytes]] = ..., remap: Optional[Mapping[bytes, bytes]] =
> ..., include: Optional[Callable[..., None]] = ...): ...
> +    def read(self, path: bytes, fp: Optional[BinaryIO] = ..., sections:
> Optional[Container[bytes]] = ..., remap: Optional[Mapping[bytes, bytes]] =
> ...) -> None: ...
> diff --git a/types/mercurial/policy.pyi b/types/mercurial/policy.pyi
> new file mode 100644
> --- /dev/null
> +++ b/types/mercurial/policy.pyi
> @@ -0,0 +1,9 @@
> +# Stubs for mercurial.policy (Python 3.5)
> +#
> +# NOTE: This dynamically typed stub was automatically generated by
> stubgen.
> +
> +from typing import Any, Tuple
> +
> +policy = ...  # type: bytes
> +policynoc = ...  # type: Tuple[bytes, ...]
> +policynocffi = ...  # type: Tuple[bytes, ...]
> diff --git a/types/mercurial/ui.pyi b/types/mercurial/ui.pyi
> new file mode 100644
> --- /dev/null
> +++ b/types/mercurial/ui.pyi
> @@ -0,0 +1,119 @@
> +# Stubs for mercurial.ui (Python 3.5)
> +#
> +# NOTE: This dynamically typed stub was automatically generated by
> stubgen.
> +
> +from types import TracebackType
> +from typing import Any, BinaryIO, Callable, Container, ContextManager,
> Generator, ItemsView, List, Mapping, MutableMapping, Optional, Sequence,
> SupportsInt, Tuple, Type, Union
> +from .config import _CfgBackup
> +from .formatter import baseformatter
> +from .i18n import _ as _
> +from .node import hex as hex
> +from .progress import progbar
> +from .url import url
> +
> +import urllib.request as urlreq
> +
> +_OneNameOrMultiple = Union[bytes, Sequence[bytes]]
> +
> +samplehgrcs = ...  # type: MutableMapping[bytes, bytes]
> +
> +class httppasswordmgrdbproxy:
> +    def __init__(self) -> None: ...
> +    def add_password(self, realm: str, uri: Union[str, Sequence[str]],
> user: str, passwd: str) -> None: ...
> +    def find_user_password(self, realm: str, authuri: str) ->
> Tuple[Optional[str], Optional[str]]: ...
> +
> +class ui:
> +    quiet = ...  # type: bool
> +    callhooks = ...  # type: bool
> +    insecureconnections = ...  # type: bool
> +    logblockedtimes = ...  # type: bool
> +    fout = ...  # type: BinaryIO
> +    ferr = ...  # type: BinaryIO
> +    fin = ...  # type: BinaryIO
> +    pageractive = ...  # type: bool
> +    environ = ...  # type: MutableMapping[bytes, bytes]
> +    httppasswordmgrdb = ...  # type: httppasswordmgrdbproxy
> +    def __init__(self, src: Optional[ui] = ...) -> None: ...
> +    @classmethod
> +    def load(cls) -> ui: ...
> +    def copy(self) -> ui: ...
> +    def resetstate(self) -> None: ...
> +    def timeblockedsection(self, key: bytes) -> ContextManager: ...
> +    def formatter(self, topic: bytes, opts: Mapping[bytes, Any]) ->
> baseformatter: ...
> +    def readconfig(self, filename: bytes, root: Optional[bytes] = ...,
> trust: bool = ..., sections: Optional[Container[bytes]] = ..., remap:
> Optional[Mapping[bytes, bytes]] = ...) -> None: ...
> +    debugflag = ...  # type: bool
> +    verbose = ...  # type: bool
> +    tracebackflag = ...  # type: bool
> +    def fixconfig(self, root: Optional[bytes] = ..., section:
> Optional[bytes] = ...) -> None: ...
> +    def backupconfig(self, section: bytes, item: bytes) ->
> Tuple[_CfgBackup, _CfgBackup, _CfgBackup]: ...
> +    def restoreconfig(self, data: Tuple[_CfgBackup, _CfgBackup,
> _CfgBackup]) -> None: ...
> +    def setconfig(self, section: bytes, name: bytes, value: bytes,
> source: bytes = ...) -> None: ...
> +    def configsource(self, section: bytes, name: bytes, untrusted: bool =
> ...) -> bytes: ...
> +    def config(self, section: bytes, name: Union[bytes, Sequence[bytes]],
> default: Optional[Any] = ..., untrusted: bool = ...) -> Optional[Any]: ...
> +    def configsuboptions(self, section: bytes, name: bytes, default:
> Optional[Any] = ..., untrusted: bool = ...) -> Tuple[Optional[bytes],
> Mapping[bytes, Any]]: ...
> +    def configpath(self, section: bytes, name: _OneNameOrMultiple,
> default: Optional[bytes] = ..., untrusted: bool = ...) -> Optional[bytes]:
> ...
> +    def configbool(self, section: bytes, name: _OneNameOrMultiple,
> default: bool = ..., untrusted: bool = ...) -> bool: ...
> +    def configwith(self, convert: Callable[[Any], Any], section: bytes,
> name: _OneNameOrMultiple, default: Optional[Any] = ..., desc: Optional[Any]
> = ..., untrusted: bool = ...): ...
> +    def configint(self, section: bytes, name: _OneNameOrMultiple,
> default: Union[None, SupportsInt, str, bytes] = ..., untrusted: bool =
> ...)-> Optional[int]: ...
> +    def configbytes(self, section: bytes, name: _OneNameOrMultiple,
> default: Union[bytes, int] = ..., untrusted: bool = ...) -> Optional[int]:
> ...
> +    def configlist(self, section: bytes, name: _OneNameOrMultiple,
> default: Union[None, bytes, List[bytes]] = ..., untrusted: bool = ...) ->
> List[bytes]: ...
> +    def hasconfig(self, section: bytes, name: bytes, untrusted: bool =
> ...) -> bool: ...
> +    def has_section(self, section: bytes, untrusted: bool = ...) -> bool:
> ...
> +    def configitems(self, section: bytes, untrusted: bool = ...,
> ignoresub: bool = ...) -> ItemsView[bytes, Any]: ...
> +    def walkconfig(self, untrusted: bool = ...) -> Generator[Tuple[bytes,
> bytes, bytes], None, None]: ...
> +    def plain(self, feature: Optional[bytes] = ...) -> bool: ...
> +    def username(self) -> bytes: ...
> +    def shortuser(self, user: bytes) -> bytes: ...
> +    def expandpath(self, loc, default: Union[None, bytes, Tuple[bytes],
> List[bytes]] = ...) -> bytes: ...
> +    def paths(self) -> paths: ...
> +    def pushbuffer(self, error: bool = ..., subproc: bool = ..., labeled:
> bool = ...) -> None: ...
> +    def popbuffer(self) -> bytes: ...
> +    def write(self, *args: Any, **opts: Any) -> None: ...
> +    def write_err(self, *args: Any, **opts: Any) -> None: ...
> +    def flush(self) -> None: ...
> +    def disablepager(self) -> None: ...
> +    def pager(self, command: bytes) -> None: ...
> +    def interface(self, feature: bytes) -> bytes: ...
> +    def interactive(self) -> bool: ...
> +    def termwidth(self) -> int: ...
> +    def formatted(self) -> bool: ...
> +    def prompt(self, msg: bytes, default: bytes = ...) -> bytes: ...
> +    @staticmethod
> +    def extractchoices(prompt: bytes) -> Tuple[bytes, List[Tuple[bytes,
> bytes]]]: ...
> +    def promptchoice(self, prompt: bytes, default: int = ...) -> int: ...
> +    def getpass(self, prompt: Optional[bytes] = ..., default:
> Optional[bytes] = ...) -> Optional[bytes]: ...
> +    def status(self, *msg: Any, **opts: Any) -> None: ...
> +    def warn(self, *msg: Any, **opts: Any) -> None: ...
> +    def note(self, *msg: Any, **opts: Any) -> None: ...
> +    def debug(self, *msg: Any, **opts: Any) -> None: ...
> +    def edit(self, text: bytes, user: bytes, extra:
> Optional[Mapping[bytes, bytes]] = ..., editform: Optional[bytes] = ...,
> pending: Optional[bytes] = ..., repopath: Optional[bytes] = ...) -> bytes:
> ...
> +    def system(self, cmd: bytes, environ: Optional[Mapping[bytes, bytes]]
> = ..., cwd: Optional[bytes] = ..., onerr: Optional[Type[BaseException]] =
> ..., errprefix: Optional[bytes] = ...) -> int: ...
> +    def traceback(self, exc: Optional[Tuple[Type[BaseException],
> BaseException, TracebackType]] = ..., force: bool = ...) -> bool: ...
> +    def geteditor(self) -> bytes: ...
> +    def progress(self, topic: bytes, pos: float, item: bytes = ..., unit:
> bytes = ..., total: Optional[float] = ...) -> None: ...
> +    def log(self, service: bytes, *msg: Any, **opts: Any) -> None: ...
> +    def label(self, msg: bytes, label: bytes) -> bytes: ...
> +    def develwarn(self, msg: bytes, stacklevel: int = ..., config:
> Optional[bytes] = ...) -> None: ...
> +    def deprecwarn(self, msg: bytes, version: bytes) -> None: ...
> +    def exportableenviron(self) -> Mapping[bytes, bytes]: ...
> +    def configoverride(self, overrides: Mapping, source: bytes = ...) ->
> ContextManager: ...
> +
> +class paths(dict):
> +    def __init__(self, ui: ui) -> None: ...
> +    def getpath(self, name: bytes, default: Union[None, bytes,
> Tuple[bytes], List[bytes]] = ...) -> path: ...
> +
> +def pathsuboption(option: bytes, attr: str) -> Callable[[Callable],
> Callable]: ...
> +def pushurlpathoption(ui: ui, path: path, value: bytes) ->
> Optional[bytes]: ...
> +def pushrevpathoption(ui: ui, path: path, value: bytes) ->
> Optional[bytes]: ...
> +
> +class path:
> +    url = ...  # type: url
> +    branch = ...  # type: Optional[bytes]
> +    name = ...  # type: bytes
> +    rawloc = ...  # type: bytes
> +    loc = ...  # type: bytes
> +    def __init__(self, ui: ui, name: bytes, rawloc: Optional[bytes] =
> ..., suboptions: Optional[Mapping[bytes, bytes]] = ...) -> None: ...
> +    @property
> +    def suboptions(self) -> Mapping[bytes, bytes]: ...
> +
> +def getprogbar(ui: ui) -> progbar: ...
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>



-- 
Martijn Pieters
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170315/12a4f4f3/attachment.html>


More information about the Mercurial-devel mailing list