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

Support adding code to generated classes - e.g.: model_config = ConfigDict(protected_namespaces=()) #982

Open
msabramo opened this issue Jul 24, 2024 · 0 comments · May be fixed by #983
Open

Comments

@msabramo
Copy link

msabramo commented Jul 24, 2024

Problem

https://github.com/BerriAI/litellm uses prisma-client-py and it happens to define some fields that start with model_ and this causes Pydantic to complain with a bunch of warnings like this:

UserWarning: Field "model_max_budget" in LiteLLM_BudgetTable 
has conflict with protected namespace "model_".

Suggested solution

It would be nice to be able to get rid of these warnings. To do this the generated code would have to have:

model_config['protected_namespaces'] = ()

or something similar.

Ideally, this would be configurable so that most projects don't have to turn off this checking.

One possible way to solve this is if prisma-client-py had a config option like pyantic_disable_protected_namespaces that would cause it to add the necessary code. PR: #983

Alternatives

Another option is a more general feature that allows adding any arbitrary Python code to the generated class. This would be more powerful but probably much harder to implement.

Additional context

msabramo added a commit to msabramo/prisma-client-py that referenced this issue Jul 24, 2024
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

Successfully merging a pull request may close this issue.

1 participant