-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
Fix missing constr import issue #1609
Conversation
Add duplicate field constraints test case
@indrat |
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1609 +/- ##
===========================================
Coverage 100.00% 100.00%
===========================================
Files 11 34 +23
Lines 1020 3745 +2725
Branches 201 877 +676
===========================================
+ Hits 1020 3745 +2725
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
@@ -4,7 +4,7 @@ | |||
|
|||
from __future__ import annotations | |||
|
|||
from msgspec import Struct | |||
from msgspec import Meta, Struct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for checking the pattern.
OK, I will fix the issue in another PR.
Testing this with the msgspec output and from __future__ import annotations
from typing import Any
from typing_extensions import
Model = Any and thus the isort call fails with: › datamodel-codegen --input root_test --input-file-type jsonschema --output output_test --disable-timestamp --enable-version-header --collapse-root-models --output-model-type msgspec.Struct --target-python 3.8
Traceback (most recent call last):
File "/Users/indra/projects/data-model-code-gen/datamodel-code-generator/datamodel_code_generator/__main__.py", line 388, in main
generate(
File "/Users/indra/projects/data-model-code-gen/datamodel-code-generator/datamodel_code_generator/__init__.py", line 435, in generate
results = parser.parse()
^^^^^^^^^^^^^^
File "/Users/indra/projects/data-model-code-gen/datamodel-code-generator/datamodel_code_generator/parser/base.py", line 1183, in parse
body = code_formatter.format_code(body)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/indra/projects/data-model-code-gen/datamodel-code-generator/datamodel_code_generator/format.py", line 164, in format_code
code = self.apply_isort(code)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/indra/projects/data-model-code-gen/datamodel-code-generator/datamodel_code_generator/format.py", line 193, in apply_isort
return isort.code(code, config=self.isort_config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/indra/projects/data-model-code-gen/datamodel-code-generator/venv/lib/python3.11/site-packages/isort/api.py", line 92, in sort_code_string
sort_stream(
File "/Users/indra/projects/data-model-code-gen/datamodel-code-generator/venv/lib/python3.11/site-packages/isort/api.py", line 210, in sort_stream
changed = core.process(
^^^^^^^^^^^^^
File "/Users/indra/projects/data-model-code-gen/datamodel-code-generator/venv/lib/python3.11/site-packages/isort/core.py", line 422, in process
parsed_content = parse.file_contents(import_section, config=config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/indra/projects/data-model-code-gen/datamodel-code-generator/venv/lib/python3.11/site-packages/isort/parse.py", line 522, in file_contents
if "," in import_string.split(just_imports[-1])[-1]:
~~~~~~~~~~~~^^^^
IndexError: list index out of range |
'--output-model-type', | ||
'msgspec.Struct', | ||
'--target-python-version', | ||
'3.8', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@indrat
I have added the test case.
lgtm 👍 |
Thank you very much!! |
Closes: #1495