Commit 9dc9dd4
authored
Add multiple --input-model support with inheritance preservation (#2881)
* Add multiple --input-model support with inheritance preservation
* Fix lint and coverage issues
* Simplify code to improve branch coverage
* Extract input-model processing to separate module
* Fix PEP8 naming violations and unused parameter
* Fix lint error for multi-line import
* Add expected_output_not_contains parameter to test helper
* Achieve 100% test coverage for input_model feature
* Mark pydantic v1 coercion code with pragma no cover
* Refactor input_model tests to use expected files with assert_output
* Fix expected files for Python version compatibility
* Fix import order
* Fix PR review issues: duplicate imports, duplicate test, and duplicate union types
* Fix union type override for anyOf schemas and remove duplicate test
* Clarify test docstrings: input model type tests all output to default Pydantic BaseModel
* Remove line comments
* Add test for x-python-type with union in anyOf schema
* Remove line comments except ignore comments
* Remove SKIP_PYTHON_314 and fix Union serialization for Python 3.14
* Refactor duplicate tests using pytest.mark.parametrize
* Fix lint and type errors
* Regenerate config-types
* Fix StrictTypes import in config-types with reuse-foreign strategy
- Add _resolve_type_import_from_defs method to resolve imports from
$defs entries with x-python-import metadata
- Handle Annotated types in _serialize_python_type_full to prevent
invalid type serialization with FieldInfo
* Use FQN for type arguments in x-python-type serialization
Add _full_type_name helper function that generates fully qualified names
for type arguments while keeping outer types as short names. This ensures
proper import resolution for custom types like StrictTypes.
- Add _full_type_name function with Union type handling (| syntax)
- Update _serialize_python_type to use _full_type_name for type args
- Update expected test file for config_class output
* Fix pyright type error in _full_type_name
* Add unit tests for 100% patch coverage
- Add tests for _simple_type_name edge cases (NoneType, generic types)
- Add tests for _full_type_name (string annotation, ForwardRef, typing specials)
- Add tests for _serialize_python_type_full with Annotated type
- Add tests for _resolve_type_import_from_defs (found, not found, no x-python-import, exception handling)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
* Fix lint error and improve test for generic type without args
Use list.__class_getitem__(()) to create a GenericAlias with origin
but no args, avoiding the ruff UP035 auto-fix that converted typing.List to list.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
* Fix variable naming: use 'spec' for find_spec result
Renamed misleading variable from 'module' to 'spec' when storing
the result of importlib.util.find_spec(), as it returns a ModuleSpec
not a module object.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
* Add tests for _full_type_name branch coverage
- Test builtin type (module='builtins') returns short name
- Test collections.abc type returns short name
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent 36530b1 commit 9dc9dd4
58 files changed
Lines changed: 2988 additions & 1054 deletions
File tree
- src/datamodel_code_generator
- _types
- parser
- tests
- data
- expected/main
- input_model
- jsonschema
- jsonschema
- python/input_model
- main/jsonschema
- parser
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Large diffs are not rendered by default.
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
145 | 148 | | |
146 | 149 | | |
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
146 | 153 | | |
147 | 154 | | |
148 | 155 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| 162 | + | |
162 | 163 | | |
163 | 164 | | |
| 165 | + | |
164 | 166 | | |
165 | 167 | | |
166 | 168 | | |
| |||
0 commit comments