mongo-types icon indicating copy to clipboard operation
mongo-types copied to clipboard

remove `required=False` as a keyword arg

Open chdsbd opened this issue 4 years ago • 0 comments

required=False is the default behavior. We should remove this option to prevent mistakes where callers mistakenly think required=True is the default behavior.

The following definitions are equivalent

class Post:
    author = fields.StringField()

class Post:
    author = fields.StringField(required=False)

This is different.

class Post:
    author = fields.StringField(required=True)

With this change, it would only be possible to write:

class Post:
    author = fields.StringField()

class Post:
    author = fields.StringField(required=True)

The following would error:

class Post:
    author = fields.StringField(required=False)

chdsbd avatar Apr 15 '21 02:04 chdsbd