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

TypeError: _cast_by_example #109

Closed
delirious-lettuce opened this issue Mar 18, 2018 · 3 comments
Closed

TypeError: _cast_by_example #109

delirious-lettuce opened this issue Mar 18, 2018 · 3 comments
Assignees

Comments

@delirious-lettuce
Copy link

Expected Behavior

Not raise a TypeError

Actual Behavior

Raises a TypeError

Steps to Reproduce the Problem

  1. Call _cast_by_example with a value which isn't None and example as a tuple with a minimum length of 1.
>>> _cast_by_example('value', ('example',))
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "<input>", line 14, in _cast_by_example
TypeError: 'NoneType' object is not iterable

The problem is in this line:

if value is None or value == tuple(None):

The issue is calling tuple(None):

>>> tuple(None)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: 'NoneType' object is not iterable

Potential Fix

The problem line is almost exactly the same as this line (four lines below the problem line):

if value is None or value == [None]:

After looking at that, it seems like a potential fix would be either:

if value is None or value == (None,):
# or
if value is None or value == tuple([None]):

Both of these produce a tuple with one element which is None.

>>> (None,)
(None,)
>>> tuple([None])
(None,)

I didn't send a PR since I wasn't exactly sure if this would be correct and if so, which one of these would be preferred.

@danielguardicore
Copy link
Contributor

Hey,
Well, that's a bug. I think you're right on the solution. Want to open a one liner PR? 🥇

Also, what did you change in the configuration to run into this bug?

@danielguardicore
Copy link
Contributor

Will be solved in a bugfix soon :)

@danielguardicore
Copy link
Contributor

danielguardicore commented Apr 1, 2018

fixed in #111

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