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

Supporting type from docstring #1669

Closed
vallsv opened this issue Jun 7, 2016 · 3 comments
Closed

Supporting type from docstring #1669

vallsv opened this issue Jun 7, 2016 · 3 comments

Comments

@vallsv
Copy link

vallsv commented Jun 7, 2016

Hi,

After we tests with the master of python/mypy repo, it seems that definition of types from the docstring are not supported.

I try this (https://www.jetbrains.com/help/pycharm/2016.1/using-docstrings-to-specify-types.html):

def gcd(a, b):
    """
    :type a: int
    :type b: int
    :rtype: int
    """
    while b:
        a, b = b, a % b
    return a

And that:

def gcd(a, b):
    """
    @type a: int
    @type b: int
    @rtype: int
    """
    while b:
        a, b = b, a % b
    return a

Is there any way to support it?
Thanks a lot

@gvanrossum
Copy link
Member

Sorry, we have considered this and we're not going to support it. Types in docstrings are too often incorrect and unmaintained.

@vallsv
Copy link
Author

vallsv commented Jun 8, 2016

Then is there a way to write something targeting

  • Python >= 2.7
  • Python >= 3.4
  • Sphinx documentation
  • Without duplication of type definition

I try, but i dont find any intersection

If it is possible, it is great. I think there will be no problem to update the codebase i manage.
Thanks.

@JukkaL
Copy link
Collaborator

JukkaL commented Jun 8, 2016

Hopefully Sphinx will start supporting type comments now that they are included in PEP 484 -- then type comments would work everywhere.

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

3 participants