sbdchd / mongo-types

:fallen_leaf: Type stubs for mongoengine, pymongo, and bson
Apache License 2.0
19 stars 8 forks source link

remove `required=False` as a keyword arg #20

Open chdsbd opened 3 years ago

chdsbd commented 3 years ago

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)