From e3dbfbc313c1ab5411d03d3a91feb8754456e30e Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Wed, 12 May 2021 10:22:22 +0800 Subject: [PATCH] Update stubs --- mypy_stubs/eth2spec/utils/ssz/ssz_impl.pyi | 8 +++++++- mypy_stubs/eth2spec/utils/ssz/ssz_typing.pyi | 7 +++++-- mypy_stubs/remerkleable/complex.pyi | 9 +++++++-- mypy_stubs/remerkleable/core.pyi | 2 +- mypy_stubs/remerkleable/readonly_iters.pyi | 12 ++++++------ mypy_stubs/remerkleable/tree.pyi | 4 ++-- mypy_stubs/remerkleable/virtual.pyi | 3 +-- 7 files changed, 29 insertions(+), 16 deletions(-) diff --git a/mypy_stubs/eth2spec/utils/ssz/ssz_impl.pyi b/mypy_stubs/eth2spec/utils/ssz/ssz_impl.pyi index 430fe735b2..36d441ae3e 100644 --- a/mypy_stubs/eth2spec/utils/ssz/ssz_impl.pyi +++ b/mypy_stubs/eth2spec/utils/ssz/ssz_impl.pyi @@ -1,5 +1,11 @@ +from remerkleable.basic import uint as uint from remerkleable.byte_arrays import Bytes32 -from remerkleable.core import View as View +from remerkleable.core import View +from typing import TypeVar def serialize(obj: View) -> bytes: ... def hash_tree_root(obj: View) -> Bytes32: ... +def uint_to_bytes(n: uint) -> bytes: ... +V = TypeVar('V', bound=View) + +def copy(obj: V) -> V: ... diff --git a/mypy_stubs/eth2spec/utils/ssz/ssz_typing.pyi b/mypy_stubs/eth2spec/utils/ssz/ssz_typing.pyi index 9ed955c03e..dbe22d5728 100644 --- a/mypy_stubs/eth2spec/utils/ssz/ssz_typing.pyi +++ b/mypy_stubs/eth2spec/utils/ssz/ssz_typing.pyi @@ -1,5 +1,8 @@ from remerkleable.basic import bit as bit, boolean as boolean, byte as byte, uint as uint, uint128 as uint128, uint16 as uint16, uint256 as uint256, uint32 as uint32, uint64 as uint64, uint8 as uint8 from remerkleable.bitfields import Bitlist as Bitlist, Bitvector as Bitvector -from remerkleable.byte_arrays import ByteList as ByteList, ByteVector as ByteVector, Bytes1 as Bytes1, Bytes32 as Bytes32, Bytes4 as Bytes4, Bytes48 as Bytes48, Bytes8 as Bytes8, Bytes96 as Bytes96 +from remerkleable.byte_arrays import ByteList as ByteList, Bytes1 as Bytes1, Bytes32 as Bytes32, Bytes4 as Bytes4, Bytes48 as Bytes48, Bytes8 as Bytes8, Bytes96 as Bytes96 from remerkleable.complex import Container as Container, List as List, Vector as Vector -from remerkleable.core import BasicView as BasicView, TypeDef as TypeDef, View as View +from remerkleable.core import BasicView as BasicView, Path as Path, View as View +from typing import Any + +Bytes20: Any diff --git a/mypy_stubs/remerkleable/complex.pyi b/mypy_stubs/remerkleable/complex.pyi index baf030a06d..9fc43b6b5e 100644 --- a/mypy_stubs/remerkleable/complex.pyi +++ b/mypy_stubs/remerkleable/complex.pyi @@ -123,8 +123,13 @@ class _ContainerLike: def fields(cls: Any) -> Fields: ... CV = TypeVar('CV', bound='Container') -class Container(ComplexView): - def __new__(cls: Any, *args: Any, backing: Optional[Node]=..., hook: Optional[ViewHook]=..., **kwargs: Any) -> Any: ... +class _ContainerBase(ComplexView): + def __new__(cls: Any, *args: Any, backing: Optional[Node]=..., hook: Optional[ViewHook]=..., append_nodes: Optional[PyList[Node]]=..., **kwargs: Any) -> Any: ... + @classmethod + def fields(cls: Any) -> Fields: ... + +class Container(_ContainerBase): + def __new__(cls: Any, *args: Any, backing: Optional[Node]=..., hook: Optional[ViewHook]=..., append_nodes: Optional[PyList[Node]]=..., **kwargs: Any) -> Any: ... def __init_subclass__(cls, *args: Any, **kwargs: Any) -> None: ... @classmethod def coerce_view(cls: Type[CV], v: Any) -> CV: ... diff --git a/mypy_stubs/remerkleable/core.pyi b/mypy_stubs/remerkleable/core.pyi index 8619a0759b..eeba1aa39d 100644 --- a/mypy_stubs/remerkleable/core.pyi +++ b/mypy_stubs/remerkleable/core.pyi @@ -13,7 +13,7 @@ class ObjParseException(Exception): ... class Path: anchor: Type[View] path: PyList[Tuple[Any, Type[View]]] - def __init__(self, anchor: Type[View], path: Optional[PyList[Tuple[Any, Type[View]]]]=...) -> Any: ... + def __init__(self, anchor: Type[View], path: Optional[PyList[Tuple[Any, Type[View]]]]=...) -> None: ... @staticmethod def from_raw_path(anchor: Type[View], path: PyList[Any]) -> Path: ... def __truediv__(self, other: Any) -> Path: ... diff --git a/mypy_stubs/remerkleable/readonly_iters.pyi b/mypy_stubs/remerkleable/readonly_iters.pyi index ff4988cbd6..7eb271c1a8 100644 --- a/mypy_stubs/remerkleable/readonly_iters.pyi +++ b/mypy_stubs/remerkleable/readonly_iters.pyi @@ -11,7 +11,7 @@ class BitfieldIter: length: int currentRoot: Root stack: PyList[Optional[Node]] - def __init__(self, anchor: Node, depth: int, length: int) -> Any: ... + def __init__(self, anchor: Node, depth: int, length: int) -> None: ... def __iter__(self) -> Any: ... def __next__(self): ... @@ -26,7 +26,7 @@ class PackedIter: currentRoot: RootNode elem_type: Type[BasicView] stack: PyList[Optional[Node]] - def __init__(self, anchor: Node, depth: int, length: int, elem_type: Type[BasicView]) -> Any: ... + def __init__(self, anchor: Node, depth: int, length: int, elem_type: Type[BasicView]) -> None: ... def __iter__(self) -> Any: ... def __next__(self): ... @@ -38,21 +38,21 @@ class NodeIter: per_node: int stack: PyList[Optional[Node]] currentRoot: Any = ... - def __init__(self, anchor: Node, depth: int, length: int) -> Any: ... + def __init__(self, anchor: Node, depth: int, length: int) -> None: ... def __iter__(self) -> Any: ... def __next__(self): ... class ComplexElemIter(NodeIter): reused_view: View - def __init__(self, anchor: Node, depth: int, length: int, elem_type: Type[View]) -> Any: ... + def __init__(self, anchor: Node, depth: int, length: int, elem_type: Type[View]) -> None: ... def __next__(self): ... class ComplexFreshElemIter(NodeIter): elem_type: Type[View] - def __init__(self, anchor: Node, depth: int, length: int, elem_type: Type[View]) -> Any: ... + def __init__(self, anchor: Node, depth: int, length: int, elem_type: Type[View]) -> None: ... def __next__(self): ... class ContainerElemIter(NodeIter): elem_types: Sequence[Type[View]] - def __init__(self, anchor: Node, depth: int, elem_types: Sequence[Type[View]]) -> Any: ... + def __init__(self, anchor: Node, depth: int, elem_types: Sequence[Type[View]]) -> None: ... def __next__(self): ... diff --git a/mypy_stubs/remerkleable/tree.pyi b/mypy_stubs/remerkleable/tree.pyi index 5b3818db32..c01c335069 100644 --- a/mypy_stubs/remerkleable/tree.pyi +++ b/mypy_stubs/remerkleable/tree.pyi @@ -52,7 +52,7 @@ class RebindableNode(Node): class PairNode(RebindableNode, Node): left: Node right: Node - def __init__(self, left: Node, right: Node) -> Any: ... + def __init__(self, left: Node, right: Node) -> None: ... def get_left(self) -> Node: ... def get_right(self) -> Node: ... def is_leaf(self) -> bool: ... @@ -63,7 +63,7 @@ def subtree_fill_to_length(bottom: Node, depth: int, length: int) -> Node: ... def subtree_fill_to_contents(nodes: List[Node], depth: int) -> Node: ... class RootNode(Node): - def __init__(self, root: Root) -> Any: ... + def __init__(self, root: Root) -> None: ... def getter(self, target: Gindex) -> Node: ... def is_leaf(self) -> bool: ... def setter(self, target: Gindex, expand: bool=...) -> Link: ... diff --git a/mypy_stubs/remerkleable/virtual.pyi b/mypy_stubs/remerkleable/virtual.pyi index 8d983248de..a86d4763bd 100644 --- a/mypy_stubs/remerkleable/virtual.pyi +++ b/mypy_stubs/remerkleable/virtual.pyi @@ -1,5 +1,4 @@ from remerkleable.tree import NavigationError as NavigationError, Node as Node, RebindableNode as RebindableNode, Root as Root -from typing import Any class VirtualSource: def get_left(self, key: Root) -> Node: ... @@ -7,7 +6,7 @@ class VirtualSource: def is_leaf(self, key: Root) -> bool: ... class VirtualNode(RebindableNode, Node): - def __init__(self, root: Root, src: VirtualSource) -> Any: ... + def __init__(self, root: Root, src: VirtualSource) -> None: ... def get_left(self) -> Node: ... def get_right(self) -> Node: ... def is_leaf(self) -> bool: ...