From 4eb865591fc8b08ac7118d891fb457cceac84b35 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Wed, 9 Nov 2022 19:46:11 -0800 Subject: [PATCH] fix mypy errors (#187) --- sphinx_immaterial/apidoc/python/parameter_objects.py | 8 +++++--- sphinx_immaterial/graphviz.py | 2 +- tests/python_apigen_test_modules/_alpha.py | 4 ++-- tests/python_apigen_test_modules/_bravo.py | 4 ++-- tests/python_apigen_test_modules/classmethod.py | 6 +++--- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/sphinx_immaterial/apidoc/python/parameter_objects.py b/sphinx_immaterial/apidoc/python/parameter_objects.py index f148181bf..e25780bc5 100644 --- a/sphinx_immaterial/apidoc/python/parameter_objects.py +++ b/sphinx_immaterial/apidoc/python/parameter_objects.py @@ -49,9 +49,11 @@ def handle_item(fieldarg: str, content: Any) -> docutils.nodes.Node: domain, typename, docutils.nodes.Text, - env=env, - inliner=inliner, - location=location, + env=cast(sphinx.environment.BuildEnvironment, env), + inliner=cast( + docutils.parsers.rst.states.Inliner, inliner + ), + location=cast(docutils.nodes.Node, location), ) ) ) diff --git a/sphinx_immaterial/graphviz.py b/sphinx_immaterial/graphviz.py index dde2fca2e..a1c29aaf8 100644 --- a/sphinx_immaterial/graphviz.py +++ b/sphinx_immaterial/graphviz.py @@ -228,7 +228,7 @@ def render_dot_html( code: str, options: dict, prefix: str = "graphviz", - imgcls: str = None, + imgcls: Optional[str] = None, alt: Optional[str] = None, filename: Optional[str] = None, ) -> Tuple[str, str]: diff --git a/tests/python_apigen_test_modules/_alpha.py b/tests/python_apigen_test_modules/_alpha.py index 03ba0abed..92ec5fcf7 100644 --- a/tests/python_apigen_test_modules/_alpha.py +++ b/tests/python_apigen_test_modules/_alpha.py @@ -12,7 +12,7 @@ def my_method_Alpha(self) -> int: This is paragraph two. """ - pass + return 1 @property def my_property_Alpha(self) -> str: @@ -21,4 +21,4 @@ def my_property_Alpha(self) -> str: This is paragraph two. """ - pass + return "alpha" diff --git a/tests/python_apigen_test_modules/_bravo.py b/tests/python_apigen_test_modules/_bravo.py index 48672429d..4385552e7 100644 --- a/tests/python_apigen_test_modules/_bravo.py +++ b/tests/python_apigen_test_modules/_bravo.py @@ -9,7 +9,7 @@ def my_method_Bravo(self) -> int: This is paragraph two. """ - pass + return 1 @property def my_property_Bravo(self) -> str: @@ -18,4 +18,4 @@ def my_property_Bravo(self) -> str: This is paragraph two. """ - pass + return "bravo" diff --git a/tests/python_apigen_test_modules/classmethod.py b/tests/python_apigen_test_modules/classmethod.py index 59058480a..770f501eb 100644 --- a/tests/python_apigen_test_modules/classmethod.py +++ b/tests/python_apigen_test_modules/classmethod.py @@ -1,11 +1,11 @@ class Foo: @classmethod def my_classmethod(cls, arg: str) -> int: - pass + return 1 @staticmethod def my_staticmethod(arg: str) -> int: - pass + return 1 def my_method(self, arg: str) -> int: - pass + return 1