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

tolerate square brackets in return type annotations #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eanopolsky
Copy link

Currently, sphinx-doc does not create docstrings when return type annotations contain square brackets.

Example:

from typing import Optional


def test(a, b) -> Optional[str]:
    if a == b:
        return "foo"
    else:
        return None

Steps to reproduce:

  1. Create the example file as specified above.
  2. Move the point into the body of the function.
  3. Run M-x sphinx-doc RET.

Expected results:
A docstring should appear.

Actual results:
The buffer is unchanged and the following message is logged: Failed to parse function definition ’def test(a, b) -> Optional[str]:’.

This PR modifies the return type regex to tolerate square brackets in return type annotations and adds a corresponding test.

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

Successfully merging this pull request may close these issues.

1 participant