From 419a3afbe6e774c9182001977874c8ea08a9f49d Mon Sep 17 00:00:00 2001 From: Chandan Singh Date: Sun, 30 Jun 2019 02:43:56 +0100 Subject: Add initial mypy configuration and types As a first step, add type hints to variables whose type `mypy` cannot infer automatically. This is the minimal set of type hints that allow running `mypy` without any arguments, and having it not fail. We currently ignore C extensions that mypy can't process directly. Later, we can look into generating stubs for such modules (potentially automatically). --- src/buildstream/_artifactelement.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/buildstream/_artifactelement.py') diff --git a/src/buildstream/_artifactelement.py b/src/buildstream/_artifactelement.py index cfd3c29c8..e3bffaf72 100644 --- a/src/buildstream/_artifactelement.py +++ b/src/buildstream/_artifactelement.py @@ -16,12 +16,18 @@ # # Authors: # James Ennis + +from typing import TYPE_CHECKING + from . import Element from . import _cachekey from ._exceptions import ArtifactElementError from ._loader.metaelement import MetaElement from .types import Scope +if TYPE_CHECKING: + from typing import Dict + # ArtifactElement() # @@ -33,7 +39,8 @@ from .types import Scope # class ArtifactElement(Element): - __instantiated_artifacts = {} # A hash of ArtifactElement by ref + # A hash of ArtifactElement by ref + __instantiated_artifacts = {} # type: Dict[str, ArtifactElement] def __init__(self, context, ref): _, element, key = verify_artifact_ref(ref) -- cgit v1.2.1