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

How to specify different base classes for different models? #2137

Open
nbro10 opened this issue Oct 25, 2024 · 1 comment
Open

How to specify different base classes for different models? #2137

nbro10 opened this issue Oct 25, 2024 · 1 comment

Comments

@nbro10
Copy link
Contributor

nbro10 commented Oct 25, 2024

Is your feature request related to a problem? Please describe.

Yes, I want to be able to specify different base classes for my generated models.

Describe the solution you'd like

We can specify the base class for all models using --base-class. For example, if my package is like this

my_package/base_classes.py
pyproject.toml

Then I can specify them as --base-class=my_package.base_classes.MyBaseClass, but this applies to all models, which is clearly undesirable. Ideally, we should be able to specify the base class for each model that is generated.

For example, we could have the flag --base-classes=base_classes.json, then base_classes.json would look like

{
"MyModel": "MyBaseClass",
"MyModel2": "MyBaseClass2",
}

Or something like that

Describe alternatives you've considered

The alternative could be to override the template and specify the base model depending on the name of the class, but the problem is that we can't import the base class in that way. The template only applies to a single model not the full module or Python file.

We could define the base class in the template, but this is really not ideal, because we want to reuse.

@nbro10
Copy link
Contributor Author

nbro10 commented Jan 1, 2025

Similar #2154

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

2 participants
@nbro10 and others