We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
SyntaxError: from __future__ imports must occur at the beginning of the file
Describe the bug When a model is generated with a custom header, importing the resulting model module causes the following error:
This error occurs because the from __future__ statement must appear near the top of the module (see documentation)
from __future__
To Reproduce Generate model via the provided command below using any schema:
Used commandline:
$ datamodel-codegen --input "./openapi.yml" --input-file-type openapi --output ./model.py --output-model-type pydantic_v2.BaseModel --snake-case-field --target-python-version 3.10 --use-schema-description --use-field-description --base-class CustomBaseModel --custom-file-header-path ./custom_pydantic_file_header.py
Expected behavior Generated module could be imported without any issues.
Version:
Additional context Consider hoisting the future statement if any custom header option is passed.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
When a model is generated with a custom header, importing the resulting model module causes the following error:
This error occurs because the
from __future__
statement must appear near the top of the module (see documentation)To Reproduce
Generate model via the provided command below using any schema:
Used commandline:
Expected behavior
Generated module could be imported without any issues.
Version:
Additional context
Consider hoisting the future statement if any custom header option is passed.
The text was updated successfully, but these errors were encountered: