Skip to content

Commit be6ced4

Browse files
committed
Set types.Union as an alias for types.UnionType.
This is required because some Sphinx versions used the old name from a prerelease Python version.
1 parent 7e66e38 commit be6ced4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sphinx_jinja2_compat/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#
2828

2929
# stdlib
30+
import sys
3031
from typing import Any, Callable, List, TypeVar
3132

3233
__all__: List[str] = []
@@ -67,5 +68,8 @@ def environmentfilter(f: F) -> F:
6768
def contextfunction(f: F) -> F:
6869
return jinja2.utils.pass_context(f)
6970

70-
jinja2.utils.contextfunction = contextfunction # type: ignore[attr-defined]
71-
jinja2.contextfunction = contextfunction # type: ignore[attr-defined]
71+
# This all has to be up here so it's triggered first.
72+
if sys.version_info >= (3, 10):
73+
# stdlib
74+
import types
75+
types.Union = types.UnionType

0 commit comments

Comments
 (0)