Skip to content

Commit

Permalink
Add support for paramspec
Browse files Browse the repository at this point in the history
  • Loading branch information
Numerlor committed Sep 18, 2022
1 parent ccc75d2 commit 44a6f8e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sphinx_autodoc_typehints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_annotation_module(annotation: Any) -> str:
if annotation is None:
return "builtins"
is_new_type = sys.version_info >= (3, 10) and isinstance(annotation, NewType)
if is_new_type or isinstance(annotation, TypeVar):
if is_new_type or isinstance(annotation, TypeVar) or annotation.__class__.__name__ == "ParamSpec":
return "typing"
if hasattr(annotation, "__module__"):
return annotation.__module__ # type: ignore # deduced Any
Expand Down Expand Up @@ -153,7 +153,7 @@ def format_annotation(annotation: Any, config: Config) -> str: # noqa: C901 # t
if full_name == "typing.NewType":
args_format = f"\\(``{annotation.__name__}``, {{}})"
role = "class" if sys.version_info >= (3, 10) else "func"
elif full_name == "typing.TypeVar":
elif full_name in {"typing.TypeVar", "typing.ParamSpec"}:
params = {k: getattr(annotation, f"__{k}__") for k in ("bound", "covariant", "contravariant")}
params = {k: v for k, v in params.items() if v}
if "bound" in params:
Expand Down

0 comments on commit 44a6f8e

Please sign in to comment.