FireO icon indicating copy to clipboard operation
FireO copied to clipboard

Allow models to be specified more pythonically - with type hints, perhaps use pydantic for type checking

Open gresnick opened this issue 3 years ago • 0 comments

Currently it doesn't seem possible/useful to assign type hints to fields, for example

class User(mdl.Model):
    name: str = mdl.TextField()

Ideally, using a validation library such as pydantic

class User(mdl.Model):
   name: str

Reasons for the suggestion:

  • more pythonic (concise, using built-in type hints)
  • potentially support more types out of the box
  • allow pydantic models instead of NestedModel -> cannot accidentally .save() !
  • robust validation provided by third party validation library

gresnick avatar Feb 15 '22 15:02 gresnick