Skip to content

Breaks with newest sphinx-autodoc-typehints again #42

Closed
@flying-sheep

Description

@flying-sheep

This code is just too hacky

curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe, 2)
if calframe[1][3] == "process_docstring":
annot_fmt = format_both(annotation, fully_qualified, simplify_optional_unions)
if elegant_typehints.annotate_defaults:
variables = calframe[1].frame.f_locals
sig = inspect.signature(variables["obj"])
arg_name = variables["argname"].replace(r"\_", "_")
if arg_name != "return":
default = sig.parameters[arg_name].default
if default is not inspect.Parameter.empty:
annot_fmt += f" (default: ``{_escape(repr(default))}``)"
return annot_fmt

I hope this time the defaults rendering will be merged upstream, then we won’t need it anymore

tox-dev/sphinx-autodoc-typehints#191

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions