Skip to content

Boolean type should fallback to False instead of True!!! #250

@daveoncode

Description

@daveoncode

If I deserialize a dictionary containing None as value for a boolean node, Colander falls back to True, which is absolutely wrong... a default for a boolean must always be False by definition.
I currently subclassed Boolean in this way to make it work as expected:

class SmartBoolean(Boolean):
    def deserialize(self, node, cstruct):
        if cstruct in (null, None, ''):
            return null
        return super().deserialize(node, cstruct)

But I hope you will consider to replace True with False in the last line of original Boolean deserialize() method. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions