Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLAlchemyModelFactory is not a generic class #69

Open
bartektrybala opened this issue Dec 15, 2024 · 0 comments
Open

SQLAlchemyModelFactory is not a generic class #69

bartektrybala opened this issue Dec 15, 2024 · 0 comments

Comments

@bartektrybala
Copy link

bartektrybala commented Dec 15, 2024

When you define a factory like this:

class UserFactory(factory.alchemy.SQLAlchemyModelFactory):
    class Meta:
        model = UserModel

    email = factory.Faker("email")

mypy throws error:
Missing type parameters for generic type "SQLAlchemyModelFactory" [type-arg]

but when add the parameter like this: factory.alchemy.SQLAlchemyModelFactory[UserModel] then when you execute the code it throws an error: E TypeError: <SQLAlchemyModelFactory (abstract)> is not a generic class

It's because stubs define SQLAlchemyModelFactory as a generic class but in fact it's not generic. In the source code of factory-boy you've got

class SQLAlchemyModelFactory(base.Factory)

and

class Factory(BaseFactory[T], metaclass=FactoryMetaClass)

but SQLAlchemyModelFactory itself is not generic. Could you fix that? For now I have to ignore the line for mypy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant