Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaks with newest sphinx-autodoc-typehints again #42

Closed
flying-sheep opened this issue Jan 4, 2022 · 0 comments
Closed

Breaks with newest sphinx-autodoc-typehints again #42

flying-sheep opened this issue Jan 4, 2022 · 0 comments

Comments

@flying-sheep
Copy link
Collaborator

flying-sheep commented Jan 4, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant