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

NoneType' object is not iterable in resolve_fw_decl #36

Closed
mitar opened this issue Apr 11, 2018 · 8 comments
Closed

NoneType' object is not iterable in resolve_fw_decl #36

mitar opened this issue Apr 11, 2018 · 8 comments

Comments

@mitar
Copy link
Collaborator

mitar commented Apr 11, 2018

>>> import typing
>>> from pytypes import type_util
>>> T = typing.TypeVar('T')
>>> class Foo(typing.Generic[T]):
...   pass
... 
>>> type_util.resolve_fw_decl(Foo)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not iterable
@Stewori
Copy link
Owner

Stewori commented Apr 11, 2018

When posting issue-related stacktraces would be helpful to set pytypes.clean_traceback = False (right after pytypes import) to make the pytypes-internal part of the stacktrace visible.

@mitar
Copy link
Collaborator Author

mitar commented Apr 11, 2018

Oh, didn't know about that.

@mitar
Copy link
Collaborator Author

mitar commented Apr 11, 2018

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../pytypes/type_util.py", line 905, in resolve_fw_decl
    for in_tp in in_type.__args__])
TypeError: 'NoneType' object is not iterable

@mitar
Copy link
Collaborator Author

mitar commented Apr 11, 2018

So __args__ is None in this case.

@Stewori
Copy link
Owner

Stewori commented Apr 11, 2018

Alright.
Changing line 903 from
elif hasattr(in_type, '__args__'):
to
elif hasattr(in_type, '__args__') and in_type.__args is not None:
would solve this issue I suppose.
I don't have time to work on pytyes right now, so it would be great if you could test this solution (and ideally push)...

@mitar
Copy link
Collaborator Author

mitar commented Apr 12, 2018

I will look into this. The #35 is in fact more problematic to me, it seems I have found also other examples where it does not work. :-(

mitar added a commit to mitar/pytypes that referenced this issue Apr 12, 2018
@mitar
Copy link
Collaborator Author

mitar commented Apr 12, 2018

Done: #37.

@Stewori
Copy link
Owner

Stewori commented Apr 12, 2018

Thanks!

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

2 participants