Skip to content

Commit 30b4bf3

Browse files
authored
Merge pull request #321 from BCG-Gamma/dev/2.0.dev8
BUILD: release pytools 2.0.dev8
2 parents 361b6ca + 375f8c2 commit 30b4bf3

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/pytools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"""
22
A collection of Python extensions and tools used in BCG GAMMA's open-source libraries.
33
"""
4-
__version__ = "2.0.dev7"
4+
__version__ = "2.0.dev8"

src/pytools/sphinx/util/_util_py37.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Implementation of sphinx module.
33
"""
4+
import collections.abc
45
import importlib
56
import logging
67
from inspect import getattr_static
@@ -17,6 +18,7 @@
1718
get_type_hints,
1819
)
1920

21+
# todo: switch from typing_inspect over to typing once typing implements it completely
2022
import typing_inspect
2123

2224
from ...api import AllTracker, get_generic_bases, inheritdoc
@@ -250,7 +252,7 @@ def _resolve_attribute_signatures(self, cls: Type) -> None:
250252

251253
def _substitute_type_vars_in_type_expression(
252254
type_expression: Union[Type, TypeVar]
253-
) -> Union[type, TypeVar]:
255+
) -> Union[Type, TypeVar]:
254256
# recursively substitute type vars with their resolutions
255257
if isinstance(type_expression, TypeVar):
256258
# resolve type variables defined by Generic[] in the
@@ -260,6 +262,14 @@ def _substitute_type_vars_in_type_expression(
260262
# dynamically resolve type variables inside nested type expressions
261263
args = typing_inspect.get_args(type_expression)
262264
if args:
265+
# unpack callable args, since copy_with() expects a flat tuple
266+
# (arg_1, arg_2, ..., arg_n, return)
267+
# instead of ([arg_1, arg_2, ..., arg_n], return)
268+
if typing_inspect.get_origin(
269+
type_expression
270+
) is collections.abc.Callable and isinstance(args[0], list):
271+
args = (*args[0], *args[1:])
272+
263273
# noinspection PyUnresolvedReferences
264274
return type_expression.copy_with(
265275
tuple(map(_substitute_type_vars_in_type_expression, args))
@@ -295,7 +305,7 @@ def _get_defining_class(method: FunctionType) -> Optional[type]:
295305
except NameError:
296306
# we could not find the container of the given method in the method's global
297307
# namespace - this is likely an inherited method where the parent class
298-
#
308+
# sits in a different module
299309
log.warning(
300310
f"failed to find container {method.__module__}.{method_container!r} "
301311
f"of method {method.__name__!r}"

0 commit comments

Comments
 (0)