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

TypeError: FileStorage.__get_pydantic_core_schema__() takes 2 positional arguments but 3 were given #178

Closed
3raser95 opened this issue Sep 19, 2024 · 0 comments · Fixed by #179

Comments

@3raser95
Copy link

3raser95 commented Sep 19, 2024

When using pydantic version newer than 2.8.2 I get the same error as the following user in the mentioned other issue:

I tried to run the unit tests following the CONTRIBUTING.md but they fail with errors like

E   TypeError: __get_pydantic_core_schema__() takes 2 positional arguments but 3 were given

when loading test classes like this one:

class BookForm(BaseModel):
    file: FileStorage
    files: List[FileStorage]
    string: str
    string_list: List[str]

Originally posted by @guillaume-alvarez in #174 (comment)

I also get this error with my own code and it is easily fixed by adding another argument to the function like the handler in the following FileStorage class:

@classmethod
    def __get_pydantic_core_schema__(cls, _source: Any, handler: GetCoreSchemaHandler) -> core_schema.CoreSchema:
        return core_schema.with_info_plain_validator_function(cls.validate)
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