question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'coerce' still ignores 'nullable': True

See original GitHub issue

#269 was fixed, but only for integer:

>>> v = cerberus.Validator({'foo': {'coerce': int, 'nullable': True, 'type': 'integer'}})
>>> v.normalized({'foo': None})
{'foo': None}

Just replace integer to string:

>>> v = cerberus.Validator({'foo': {'coerce': str, 'nullable': True, 'type': 'string'}})
>>> v.normalized({'foo': None})

Expected behavior: {'foo': None}

Actual behavior: {'foo': 'None'}

So I still have to use a workaround 'coerce': lambda x: str(x) if x is not None else None

But now I’m not sure if it’s a bug or a feature (duplicate of #142?). If this is a feature, please describe this behavior in the documentation

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
dkellnercommented, Aug 13, 2018

@funkyfuture You’re delegating to Vietnam here, so much for the heat 😉. I will take a look at it and get back to you until wednesday.

0reactions
funkyfuturecommented, Aug 14, 2018

not sure which of the previously behaviours you mean. 😉 anyway, no, for now we shouldn’t change any of that. just fix your tests (and possibly code to comply w/ them).

Read more comments on GitHub >

github_iconTop Results From Across the Web

'coerce' ignores 'nullable': True #269 - pyeve/cerberus - GitHub
I think, nullable should be checked first, and if value is None, then coerce callable should not be called. If it's a bug...
Read more >
Swashbuckle SwaggerGen ignores nullable annotations on ...
Nullable = true , the generator still ignores it and doesn't insert the nullable annotation when there is a $ref in the schema...
Read more >
Using nullability in GraphQL
A field can either be nullable or non-null, and this tells you whether or not you could receive a null value when you...
Read more >
Dealing with null in Spark - MungingData
The isEvenBetter function is still directly referring to null. Let's do a final refactoring to fully remove null from the user defined function....
Read more >
Working with missing data — pandas 1.5.2 documentation
In [11]: None == None # noqa: E711 Out[11]: True In [12]: np.nan == np.nan ... Support for integer NA for more). pandas...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found