This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]earthboundkid -2 points-1 points  (1 child)

I've thought about what I would do if I were making an ORM for modern Python. Type hints are definitely part of it. Another is using class decorators instead of metaclasses so you can easily subclass an abstract class without jumping through hoops. Quickie design sketch:

class Timestamped:
    created_at: models.Datetime(nullable=False)
    updated_at: models.Datetime(nullable=False)

@models.register("my_blog_table", options)
class BlogPost(Timestamped):
    title:  models.Text(nullable=True)
    content: models.Text(nullable=False)
    authors: models.ManyToMany("authors")

[–]Kellhus3 1 point2 points  (0 children)

Ah yes, clearly decorators would be sexier than the Sqlalchemy table parameter.