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

Close #2755: autodoc: Support type_comment style annotation #6982

Closed
wants to merge 1 commit into from

Conversation

tk0miya
Copy link
Member

@tk0miya tk0miya commented Jan 1, 2020

Feature or Bugfix

  • Feature

Purpose

@tk0miya tk0miya added type:enhancement enhance or introduce a new feature extensions:autodoc labels Jan 1, 2020
@tk0miya tk0miya added this to the 2.4.0 milestone Jan 1, 2020
@tk0miya tk0miya force-pushed the 2755_type_comment_support branch 2 times, most recently from 010342a to a49b484 Compare January 1, 2020 15:37
sphinx/util/inspect.py Outdated Show resolved Hide resolved
sphinx/util/inspect.py Outdated Show resolved Hide resolved
sphinx/util/inspect.py Outdated Show resolved Hide resolved
@@ -983,8 +983,10 @@ def format_args(self, **kwargs: Any) -> str:
not inspect.isbuiltin(self.object) and
not inspect.isclass(self.object) and
hasattr(self.object, '__call__')):
self.env.app.emit('autodoc-before-format-args', self.object.__call__, False)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is good way to do this. But we have to let handlers know the target object is bound method or not...

@tk0miya tk0miya force-pushed the 2755_type_comment_support branch 2 times, most recently from 2af277d to 4fb1362 Compare January 2, 2020 13:45
sphinx/ext/autodoc/typehints.py Outdated Show resolved Hide resolved
sphinx/ext/autodoc/typehints.py Show resolved Hide resolved
sphinx/ext/autodoc/typehints.py Outdated Show resolved Hide resolved
sphinx/ext/autodoc/typehints.py Outdated Show resolved Hide resolved
@tk0miya
Copy link
Member Author

tk0miya commented Jan 2, 2020

@eric-wieser Thank you for quick and wise comment! Updated.

@tk0miya
Copy link
Member Author

tk0miya commented Jan 2, 2020

OMG. Literal causes test failures on py37 and older environment...

@tk0miya tk0miya closed this Jan 2, 2020
@tk0miya
Copy link
Member Author

tk0miya commented Jan 2, 2020

oh, I closed this PR wrongly. I'll post another one again

@eric-wieser
Copy link
Contributor

Error message seems truncated:

WARNING: error while formatting arguments for target.typehints.complex_func:

Is there a way to get more info?

@eric-wieser
Copy link
Contributor

eric-wieser commented Jan 2, 2020

I'll post another one again

Why not just reopen the PR?

elif isinstance(typ, (ast.Constant, ast.NameConstant)): # type: ignore
return repr(typ.value)
else:
raise NotImplementedError
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise NotImplementedError
raise NotImplementedError('Unable to render {} instances'.format(type(type).__name__))

@tk0miya
Copy link
Member Author

tk0miya commented Jan 2, 2020

Reposted as #6984

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extensions:autodoc type:enhancement enhance or introduce a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants