From 2ec2309daca511117018bf14eb0d6b50938f50ca Mon Sep 17 00:00:00 2001 From: Josiah Oberholtzer Date: Tue, 13 Dec 2022 13:36:14 -0500 Subject: [PATCH] Address mypy complaints --- uqbar/apis/graphs.py | 4 ++-- uqbar/graphs/core.py | 2 +- uqbar/sphinx/api.py | 14 +++++++------- uqbar/sphinx/style.py | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/uqbar/apis/graphs.py b/uqbar/apis/graphs.py index 2ad3441f..5a6d1450 100644 --- a/uqbar/apis/graphs.py +++ b/uqbar/apis/graphs.py @@ -257,7 +257,7 @@ def __str__(self) -> str: ### PUBLIC METHODS ### - def build_graph(self, urls=None): + def build_graph(self, urls=None) -> uqbar.graphs.Graph: urls = urls or {} graph = uqbar.graphs.Graph( name="InheritanceGraph", @@ -286,7 +286,7 @@ def build_graph(self, urls=None): "style": ["filled", "rounded"], }, ) - class_paths_to_nodes: Dict[type, uqbar.graphs.Node] = {} + class_paths_to_nodes: Dict[str, uqbar.graphs.Node] = {} for class_path in self._all_class_paths: node = self._get_or_create_node(class_path, graph, urls) class_paths_to_nodes[class_path] = node diff --git a/uqbar/graphs/core.py b/uqbar/graphs/core.py index aed93ef3..eb90df4c 100644 --- a/uqbar/graphs/core.py +++ b/uqbar/graphs/core.py @@ -14,7 +14,7 @@ class Attachable(UniqueTreeNode): ### INITIALIZER ### - def __init__(self): + def __init__(self) -> None: self._edges: Set["Edge"] = set() ### PRIVATE METHODS ### diff --git a/uqbar/sphinx/api.py b/uqbar/sphinx/api.py index ffc3982a..4b7cc523 100644 --- a/uqbar/sphinx/api.py +++ b/uqbar/sphinx/api.py @@ -46,7 +46,7 @@ def logger_func(string): logger.info("{} {}".format(bold("[uqbar-api]"), string)) -def on_builder_inited(app): +def on_builder_inited(app) -> None: """ Hooks into Sphinx's ``builder-inited`` event. @@ -60,16 +60,16 @@ def on_builder_inited(app): source_paths = config.uqbar_api_source_paths for source_path in source_paths: if isinstance(source_path, types.ModuleType): - if hasattr(source_path, "__path__"): - initial_source_paths.extend(getattr(source_path, "__path__")) - else: + if hasattr(source_path, "__path__") and source_path.__path__ is not None: + initial_source_paths.extend(source_path.__path__) + elif hasattr(source_path, "__file__") and source_path.__file__ is not None: initial_source_paths.extend(source_path.__file__) continue try: module = importlib.import_module(source_path) - if hasattr(module, "__path__"): - initial_source_paths.extend(getattr(module, "__path__")) - else: + if hasattr(module, "__path__") and module.__path__ is not None: + initial_source_paths.extend(module.__path__) + elif hasattr(module, "__file__") and module.__file__ is not None: initial_source_paths.append(module.__file__) except ImportError: initial_source_paths.append(source_path) diff --git a/uqbar/sphinx/style.py b/uqbar/sphinx/style.py index 0bd4bcda..82461619 100644 --- a/uqbar/sphinx/style.py +++ b/uqbar/sphinx/style.py @@ -86,7 +86,7 @@ def handle_method(signature_node, module, object_name, cache): signature_node.insert(0, emphasis) -def on_doctree_read(app, document): +def on_doctree_read(app, document) -> None: """ Hooks into Sphinx's ``doctree-read`` event. """