summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan van Berkom <tristan@codethink.co.uk>2020-12-01 17:12:37 +0900
committerTristan van Berkom <tristan@codethink.co.uk>2020-12-07 17:51:13 +0900
commitf10feb3d024cb1b8becda17b6d25919d5042ad55 (patch)
tree4dcc9b9d36cbd0ccce84c0f1825d1e8923bbbecc /src
parent4828aa399f621e3cdafdc57c8c8030f955c11b18 (diff)
downloadbuildstream-f10feb3d024cb1b8becda17b6d25919d5042ad55.tar.gz
node.pyi: Adding missing forward declarations
In order to use types from the Node family with mypy, we need to have the methods we use on those types defined.
Diffstat (limited to 'src')
-rw-r--r--src/buildstream/node.pyi33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/buildstream/node.pyi b/src/buildstream/node.pyi
index 854f4bde6..059bec2b8 100644
--- a/src/buildstream/node.pyi
+++ b/src/buildstream/node.pyi
@@ -1,4 +1,4 @@
-from typing import Generic, List, Mapping, Optional, Sequence, TypeVar
+from typing import overload, Generic, List, Mapping, Optional, Sequence, TypeVar, Dict, Any
from ._project import Project
@@ -10,11 +10,36 @@ class ProvenanceInformation: ...
class Node:
def clone(self) -> "Node": ...
def get_provenance(self) -> ProvenanceInformation: ...
+ def strip_node_info(self) -> Dict[str, Any]: ...
class MappingNode(Node, Generic[TNode]):
def __init__(self, file_index: int, line: int, column: int, value: Mapping[str, TValidNodeValue]) -> None: ...
def clone(self) -> MappingNode[TNode]: ...
- def get_str_list(self, key: str, default: List[str] = None) -> List[str]: ...
+ def validate_keys(self, valid_keys: List[str]): ...
+ @overload
+ def get_str_list(self, key: str) -> List[str]: ...
+ @overload
+ def get_str_list(self, key: str, default: List[str]) -> List[str]: ...
+ @overload
+ def get_str_list(self, key: str, default: Optional[List[str]]) -> Optional[List[str]]: ...
+ @overload
+ def get_str(self, key: str) -> str: ...
+ @overload
+ def get_str(self, key: str, default: str) -> str: ...
+ @overload
+ def get_str(self, key: str, default: Optional[str]) -> Optional[str]: ...
+ @overload
+ def get_int(self, key: str) -> int: ...
+ @overload
+ def get_int(self, key: str, default: int) -> int: ...
+ @overload
+ def get_int(self, key: str, default: Optional[int]) -> Optional[int]: ...
+ @overload
+ def get_mapping(self, key: str) -> "MappingNode": ...
+ @overload
+ def get_mapping(self, key: str, default: "MappingNode") -> "MappingNode": ...
+ @overload
+ def get_mapping(self, key: str, default: Optional["MappingNode"]) -> Optional["MappingNode"]: ...
class ScalarNode(Node):
def as_str(self) -> str: ...
@@ -25,6 +50,6 @@ class SequenceNode(Node, Generic[TNode]):
def clone(self) -> "SequenceNode[TNode]": ...
def _assert_symbol_name(
- symbol_name: str, purpose: str, *, ref_node: Optional[Node] = None, allow_dashes: bool = True
+ symbol_name: str, purpose: str, *, ref_node: Optional[Node], allow_dashes: bool = True
) -> None: ...
-def _new_synthetic_file(filename: str, project: Optional[Project] = None) -> MappingNode[TNode]: ...
+def _new_synthetic_file(filename: str, project: Optional[Project]) -> MappingNode[TNode]: ...