Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

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

@msabramo

Description

@msabramo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions