Skip to content

Passing __dict__ into dict #1453

Answered by Daverball
pamelafox asked this question in Q&A
Aug 25, 2023 · 1 comments · 5 replies
Discussion options

You must be logged in to vote

Since you're always using type[_FSA_MC] you should probably change it to:

_FSA_MCT = t.TypeVar(
    "_FSA_MCT",
    bound=t.Union[
        t.Type[Model],
        t.Type[sa_orm.DeclarativeBase],
        t.Type[sa_orm.DeclarativeBaseNoMeta],
        sa_orm.DeclarativeMeta,
    ],
)

And change all the annotations to use _FSA_MCT, rather than type[_FSA_MC]. If there are any functions that accept any instance that's derived from a class that uses DeclarativeMeta, you probably won't get around changing _FSA_MC to an unbounded TypeVar, or to one that's bound to a Protocol which contains properties that all models should have, if you want to support any custom base class that uses the metaclass.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@pamelafox
Comment options

@Daverball
Comment options

@Daverball
Comment options

@Daverball
Comment options

Answer selected by pamelafox
@pamelafox
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants