-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Stubgen generates "<ERROR>" if namedtuple's fields are declared in a tuple #4406
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
Comments
Looks like a bug. Can you submit a PR?
…On Dec 24, 2017 5:25 AM, "hoefling" ***@***.***> wrote:
Contents of spam.py:
from collections import namedtuple
FieldsStr = namedtuple('FieldsStr', 'spam, eggs')
FieldsList = namedtuple('FieldsList', ['spam', 'eggs'])
FieldsTuple = namedtuple('FieldsTuple', ('spam', 'eggs'))
$ stubgen -o . spam yields spam.pyi:
# Stubs for spam (Python 3.6)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from collections import namedtuple
FieldsStr = namedtuple('FieldsStr', 'spam, eggs')
FieldsList = namedtuple('FieldsList', ['spam', 'eggs'])
FieldsTuple = namedtuple('FieldsTuple', <ERROR>)
Is this deliberate?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#4406>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACwrMvx7Zr4MyNmkbEwBzX-WFL39Z4RUks5tDkKfgaJpZM4RL6YC>
.
|
Looks like it's just a case that was forgotten to be handled. In def process_namedtuple(self, lvalue: NameExpr, rvalue: CallExpr) -> None:
...
if isinstance(rvalue.args[1], StrExpr):
items = repr(rvalue.args[1].value)
elif isinstance(rvalue.args[1], ListExpr):
list_items = cast(List[StrExpr], rvalue.args[1].items)
items = '[%s]' % ', '.join(repr(item.value) for item in list_items)
else:
items = '<ERROR>' Seems to be an easy fix even I could implement. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Contents of
spam.py
:$ stubgen -o . spam
yieldsspam.pyi
:Is this deliberate?
The text was updated successfully, but these errors were encountered: