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

Default values of overloaded functions are wrongly rendered as string literal #8693

Closed
tk0miya opened this issue Jan 16, 2021 · 0 comments
Closed

Comments

@tk0miya
Copy link
Member

tk0miya commented Jan 16, 2021

Describe the bug
Default values of overloaded functions are wrongly rendered as string literal

To Reproduce

    @overload
    async def get_shared_api_tokens(self, service_name: str = ...) -> Dict[str, str]:
        ...

    @overload
    async def get_shared_api_tokens(self, service_name: None = ...) -> Dict[str, Dict[str, str]]:
        ...

    async def get_shared_api_tokens(
        self, service_name: Optional[str] = None
    ) -> Union[Dict[str, Dict[str, str]], Dict[str, str]]:
        """Some doc"""
        # actual implementation here

The ellipsis is rendered as '...' (see #8514).

Expected behavior
The default values are rendered as is.

Your project
No

Screenshots
No

Environment info

  • OS: Mac
  • Python version: 3.9.1
  • Sphinx version: HEAD of 3.x
  • Sphinx extensions: sphinx.ext.autodoc
  • Extra tools: No

Additional context
No

@tk0miya tk0miya added this to the 3.5.0 milestone Jan 16, 2021
tk0miya added a commit to tk0miya/sphinx that referenced this issue Jan 16, 2021
…ed as string

The default values for overloaded functions are rendered as string
literal unexpectedly because autodoc extracts code snippets from
the source code, not actual value (ex. int, ellipsis, and so on).

This introduces a simple wrapper class; `DefaultValue` to render these
code snippets like actual values, not string literals.
tk0miya added a commit that referenced this issue Jan 17, 2021
…nctions

Fix #8693: autodoc: Default values for overloads are rendered as string
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant