summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbst-marge-bot <marge-bot@buildstream.build>2020-08-30 17:24:16 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2020-08-30 17:24:16 +0000
commitfd80d4903eb28845ca9a67d5730254d93dbd0c24 (patch)
tree27517c73ba8554e4e986c77b81c08a0251531dcf
parent9c3d147a0267ebbe39e91ed7f638e2ed76494b51 (diff)
parentdf15640262026c0f2e6fa54b05915d6a9912620e (diff)
downloadbuildstream-fd80d4903eb28845ca9a67d5730254d93dbd0c24.tar.gz
Merge branch 'bschubert/typing' into 'master'
Add some type informations to remove non-typechecked parts of the code See merge request BuildStream/buildstream!2048
-rw-r--r--setup.cfg7
-rw-r--r--src/buildstream/_loader/_loader.pyi1
-rw-r--r--src/buildstream/_loader/loadelement.pyi13
-rw-r--r--src/buildstream/_types.pyi1
-rw-r--r--src/buildstream/_utils.pyi1
-rw-r--r--src/buildstream/_variables.pyi9
-rw-r--r--src/buildstream/element.py4
-rw-r--r--src/buildstream/node.pyi29
-rw-r--r--tox.ini2
9 files changed, 59 insertions, 8 deletions
diff --git a/setup.cfg b/setup.cfg
index e8ba5ac35..19ffbcbc2 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -28,12 +28,7 @@ warn_no_return = True
# Ignore missing stubs for third-party packages.
# In future, these should be re-enabled if/when stubs for them become available.
-[mypy-copyreg,grpc,pluginbase,psutil,py,pyroaring,pytest,_pytest.*,ruamel]
-ignore_missing_imports=True
-
-# Ignore missing stubs for Cythonized modules.
-# In future, these should be re-enabled by writing stubs for them.
-[mypy-buildstream.node,buildstream._loader.*,buildstream._types,buildstream._utils,buildstream._variables]
+[mypy-copyreg,grpc,pluginbase,psutil,pyroaring,ruamel]
ignore_missing_imports=True
# Ignore issues with generated files and vendored code
diff --git a/src/buildstream/_loader/_loader.pyi b/src/buildstream/_loader/_loader.pyi
new file mode 100644
index 000000000..c4281b4b9
--- /dev/null
+++ b/src/buildstream/_loader/_loader.pyi
@@ -0,0 +1 @@
+def valid_chars_name(name: str) -> bool: ...
diff --git a/src/buildstream/_loader/loadelement.pyi b/src/buildstream/_loader/loadelement.pyi
new file mode 100644
index 000000000..67b14df8f
--- /dev/null
+++ b/src/buildstream/_loader/loadelement.pyi
@@ -0,0 +1,13 @@
+from typing import List
+
+from ..node import Node, ProvenanceInformation
+
+def extract_depends_from_node(node: Node) -> List[Dependency]: ...
+
+class Dependency: ...
+
+class LoadElement:
+ first_pass: bool
+ kind: str
+ name: str
+ provenance: ProvenanceInformation
diff --git a/src/buildstream/_types.pyi b/src/buildstream/_types.pyi
new file mode 100644
index 000000000..d1986fc4a
--- /dev/null
+++ b/src/buildstream/_types.pyi
@@ -0,0 +1 @@
+class MetaFastEnum(type): ...
diff --git a/src/buildstream/_utils.pyi b/src/buildstream/_utils.pyi
new file mode 100644
index 000000000..458437281
--- /dev/null
+++ b/src/buildstream/_utils.pyi
@@ -0,0 +1 @@
+def url_directory_name(url: str) -> str: ...
diff --git a/src/buildstream/_variables.pyi b/src/buildstream/_variables.pyi
new file mode 100644
index 000000000..1e2f47325
--- /dev/null
+++ b/src/buildstream/_variables.pyi
@@ -0,0 +1,9 @@
+from typing import Optional
+
+from .node import MappingNode, Node
+
+class Variables:
+ def __init__(self, node: MappingNode) -> None: ...
+ def check(self) -> None: ...
+ def expand(self, node: Node) -> None: ...
+ def get(self, name: str) -> Optional[str]: ...
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 4a29fd8f2..4995f1f37 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -780,7 +780,7 @@ class Element(Plugin):
"""
self._stage_sources_in_sandbox(sandbox, directory)
- def get_public_data(self, domain: str) -> "MappingNode[Any, Any]":
+ def get_public_data(self, domain: str) -> "MappingNode[Node]":
"""Fetch public data on this element
Args:
@@ -805,7 +805,7 @@ class Element(Plugin):
return data
- def set_public_data(self, domain: str, data: "MappingNode[Any, Any]") -> None:
+ def set_public_data(self, domain: str, data: "MappingNode[Node]") -> None:
"""Set public data on this element
Args:
diff --git a/src/buildstream/node.pyi b/src/buildstream/node.pyi
new file mode 100644
index 000000000..57083602c
--- /dev/null
+++ b/src/buildstream/node.pyi
@@ -0,0 +1,29 @@
+from typing import Generic, List, Mapping, Optional, Sequence, TypeVar
+
+from ._project import Project
+
+TNode = TypeVar("TNode", bound="Node")
+TValidNodeValue = TypeVar("TValidNodeValue", int, str, bool, Mapping, Sequence)
+
+class ProvenanceInformation: ...
+
+class Node:
+ def clone(self) -> "Node": ...
+
+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]: ...
+
+class ScalarNode(Node):
+ def as_str(self) -> str: ...
+ def clone(self) -> "ScalarNode": ...
+
+class SequenceNode(Node, Generic[TNode]):
+ def as_str_list(self) -> List[str]: ...
+ def clone(self) -> "SequenceNode[TNode]": ...
+
+def _assert_symbol_name(
+ symbol_name: str, purpose: str, *, ref_node: Optional[Node] = None, allow_dashes: bool = True
+) -> None: ...
+def _new_synthetic_file(filename: str, project: Optional[Project] = None) -> MappingNode[TNode]: ...
diff --git a/tox.ini b/tox.ini
index f347e06e3..0c798f284 100644
--- a/tox.ini
+++ b/tox.ini
@@ -160,6 +160,8 @@ commands =
mypy {posargs}
deps =
mypy==0.730
+ -rrequirements/requirements.txt
+ -rrequirements/dev-requirements.txt
#