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

Type checker conflict with Config in ModelSchema (and Schema) #29

Open
paolodina opened this issue Feb 7, 2025 · 0 comments
Open

Type checker conflict with Config in ModelSchema (and Schema) #29

paolodina opened this issue Feb 7, 2025 · 0 comments

Comments

@paolodina
Copy link

paolodina commented Feb 7, 2025

Hi eadwinCode!

I've encountered a minor issue when using ModelSchema in the Config inner class. Pylance reports a conflict because ModelSchema already defines Config. Here's a minimal example that triggers the error:

class UserOutSchema(ModelSchema):
    class Config:
        model = User
        include = ["id", "email", "first_name", "last_name", "date_joined", "is_active"]

And the error message from Pylance:

"Config" overrides symbol of same name in class "ModelSchema"
  "project.api_extra.UserOutSchema.Config" is not assignable to "ninja_schema.orm.model_schema.ModelSchema.Config"
  Type "type[project.api_extra.UserOutSchema.Config]" is not assignable to type "type[ninja_schema.orm.model_schema.ModelSchema.Config]"

Would it be possible to adjust ModelSchema so that defining a Config class doesn't trigger the type checking error? The same happens with Schema.

Alternatively, is there a recommended way to achieve the same configuration without overriding Config?

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