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.

Odd Behavior for `Function` field

See original GitHub issue
class TestSchema(Schema):
    test = fields.Function(deserialize=lambda x: 1)
    test2 = fields.Constant(11)
    
TestSchema().load({})

yields UnmarshalResult(data={'test2': 11}, errors={}), ie omitting test. The fix seems to be:

class TestSchema2(Schema):
    test = fields.Function(deserialize=lambda x: 1, missing='asdf')
    test2 = fields.Constant(11)

yielding: UnmarshalResult(data={'test': 1, 'test2': 11}, errors={}).

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cancan101commented, Jul 25, 2018
Name: marshmallow
Version: 2.15.3
Summary: A lightweight library for converting complex datatypes to and from native Python datatypes.
Home-page: https://github.com/marshmallow-code/marshmallow
Author: Steven Loria
Author-email: sloria1@gmail.com
License: MIT
0reactions
deckar01commented, Jul 27, 2018

You could use it to invert a boolean value when mapping a field like enabled to disabled. Sometimes a custom field is overkill when the just need to transform the input value a little.

disabled = field.Function(deserialize=lambda x: not x, load_from='enabled')
Read more comments on GitHub >

github_iconTop Results From Across the Web

End behavior of polynomials (article)
If the polynomials degree is odd, then the end behavior will be different on both sides. If the leading coefficient is positive then...
Read more >
Identifying Even & Odd Degree Functions, Zeros & End Behavior
The following video examines how to describe the end behavior of polynomial functions. We examine how to state the type of polynomial, ...
Read more >
limits end behavior and even and odd functions notes - YouTube
limits end behavior and even and odd functions notes. 729 views 6 years ago. jim meyers. jim meyers. 137 subscribers. Subscribe.
Read more >
Oppositional defiant disorder (ODD) - Symptoms and causes
ODD is a childhood mental health disorder that includes frequent and persistent anger, irritability, arguing, defiance or vindictiveness ...
Read more >
Leading Coefficient Test
Use the Leading Coefficient Test to determine the end behavior of the graph of the polynomial function f(x)=−x3+5x . Solution: Because the degree...
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