Typing for phyloviz baseparser.

This commit is contained in:
John Chilton
2021-10-26 10:27:58 -04:00
parent 1d8a2bd22f
commit 203421dc7f
2 changed files with 6 additions and 5 deletions
@@ -1,4 +1,5 @@
import json
from typing import Any, Dict
class Node:
@@ -14,6 +15,8 @@ class Node:
self.length, self.bootstrap = kwargs.get("length", 0), kwargs.get("bootstrap", None)
self.events = kwargs.get("events", "")
self.parent = None
# clean up boot strap values
if self.bootstrap == -1:
self.bootstrap = None
@@ -28,7 +31,7 @@ class Node:
def __str__(self):
return f"{self.name} id:{str(self.id)}, depth: {str(self.depth)}"
def toJson(self):
def toJson(self) -> Dict[str, Any]:
"""Converts the data in the node to a dict representation of json"""
thisJson = {
"name": self.name,
@@ -79,7 +82,7 @@ class PhyloTree:
self.id += 1
return Node(nodeName, **kwargs)
def addRoot(self, root):
def addRoot(self, root: Node):
"""Creates a root for phyloTree"""
assert isinstance(root, Node)
root.parent = None
@@ -88,7 +91,7 @@ class PhyloTree:
def generateJsonableDict(self):
"""Changes itself into a dictonary by recurssively calling the tojson on all its nodes. Think of it
as a dict in an array of dict in an array of dict and so on..."""
jsonTree = ""
jsonTree: Dict[str, Any]
if self.root:
assert isinstance(self.root, Node)
jsonTree = self.root.toJson()
-2
View File
@@ -80,8 +80,6 @@ check_untyped_defs = False
check_untyped_defs = False
[mypy-galaxy.web.framework.middleware.error]
check_untyped_defs = False
[mypy-galaxy.visualization.data_providers.phyloviz.baseparser]
check_untyped_defs = False
[mypy-galaxy.util.topsort]
check_untyped_defs = False
[mypy-galaxy.util.submodules]