Skip to content

Commit

Permalink
pass 5
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener committed Mar 14, 2023
1 parent c59cbd0 commit 5494abf
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
15 changes: 15 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from urllib.request import urlopen


_conf_url = \
"https://raw.githubusercontent.com/inducer/sphinxconfig/main/sphinxconfig.py"
with urlopen(_conf_url) as _inf:
Expand Down Expand Up @@ -41,3 +42,17 @@
autodoc_type_aliases = {"GraphT": "pytools.graph.GraphT",
"NodeT": "pytools.graph.NodeT",
}

# Some modules need to import things just so that sphinx can resolve symbols in
# type annotations. Often, we do not want these imports (e.g. of PyOpenCL) when
# in normal use (because they would introduce unintended side effects or hard
# dependencies). This flag exists so that these imports only occur during doc
# build. Since sphinx appears to resolve type hints lexically (as it should),
# this needs to be cross-module (since, e.g. an inherited pytools
# docstring can be read by sphinx when building meshmode, a dependent package),
# this needs a setting of the same name across all packages involved, that's
# why this name is as global-sounding as it is.
import sys


sys._BUILDING_SPHINX_DOCS = True
13 changes: 8 additions & 5 deletions pytools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@
from functools import reduce, wraps
from sys import intern
from typing import (
Any, Callable, cast, ClassVar, Dict, Generic, Hashable, Iterable, List, Mapping,
Optional, Set, Tuple, Type, TypeVar, Union, ValuesView, KeysView,
ItemsView, Sequence, Generator, TYPE_CHECKING)
TYPE_CHECKING, Any, Callable, ClassVar, Dict, Generator, Generic, Hashable,
ItemsView, Iterable, KeysView, List, Mapping, Optional, Sequence, Set, Tuple,
Type, TypeVar, Union, ValuesView, cast)


if TYPE_CHECKING:
import numpy as np

if getattr(sys, "_BUILDING_SPHINX_DOCS", False):
import numpy as np # noqa: F811


try:
from typing import Concatenate
Expand Down Expand Up @@ -2475,11 +2478,11 @@ def find_git_revision(tree_root: str) \
return git_rev


def find_module_git_revision(module_file, n_levels_up):
def find_module_git_revision(module_file: str, n_levels_up: int) -> Optional[bytes]:
from os.path import dirname, join
tree_root = join(*([dirname(module_file)] + [".." * n_levels_up]))

return find_git_revision(tree_root) # type: ignore[no-untyped-call]
return find_git_revision(tree_root)

# }}}

Expand Down
2 changes: 1 addition & 1 deletion run-mypy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -ex

mypy --show-error-codes pytools

mypy --strict pytools/datatable.py pytools/graph.py pytools/mpi.py
mypy --strict pytools/datatable.py pytools/graph.py pytools/mpi.py pytools/__init__.py
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from setuptools import setup


ver_dic = {}
version_file = open("pytools/version.py")
try:
Expand Down

0 comments on commit 5494abf

Please sign in to comment.