Skip to content

Anonymous return values have their types populated in the name slot of the tuple.  #72

Closed
@Erotemic

Description

@Erotemic

I noticed an inconsistency, when using numpydoc version 0.6.0 in python2.7 on Ubuntu. The parsed return section information returns different styles of tuple depending on if the return value is anoymous or not.

Here is a minimal working example:

def mwe():
        from numpydoc.docscrape import NumpyDocString
        docstr = (
            'Returns\n'
            '----------\n'
            'int\n'
            '    can return an anoymous integer\n'
            'out : ndarray\n'
            '    can return a named value\n'
        )
        doc = NumpyDocString(docstr)
        returns = doc._parsed_data['Returns']
        print(returns)

This results in

[(u'int', '', [u'can return an anoymous integer']),
 (u'out', u'ndarray', [u'can return a named value'])]

However judging by tests (due to lack of docs), I believe it was indented that each value in the returns list should be a tuple of (arg, arg_type, arg_desc). Therefore we should see this instead:

[('', u'int', [u'can return an anoymous integer']),
 (u'out', u'ndarray', [u'can return a named value'])]

My current workaround is this:

        for p_name, p_type, p_descr in returns:
            if not p_type:
                p_name = ''
                p_type = p_name

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions