Commit 69eda18
Skip default_factory wrapping for non-callable type aliases (#3012)
* fix: skip default_factory wrapping for non-callable type aliases (#3009)
When --use-type-alias + --use-annotated + --enum-field-as-literal all are
combined, the generator produced `default_factory=lambda: Mode('default')`
where Mode is a PEP 695 type alias (not callable). Add a TypeAliasBase
guard in __wrap_root_model_default_values to skip wrapping for type aliases.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: add black 22 skipif and ruff format for type alias test
Skip the enum_literal_type_alias_default test on black < 23 since
PEP 695 `type` statement syntax is unsupported. Reformat long
conditional in parser/base.py to satisfy ruff line-length.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: simplify docstring for type alias default test
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Koudai Aono <koxudaxi@gmail.com>1 parent 5a9cdec commit 69eda18
4 files changed
Lines changed: 61 additions & 1 deletion
File tree
- src/datamodel_code_generator/parser
- tests
- data
- expected/main/jsonschema
- jsonschema
- main/jsonschema
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2158 | 2158 | | |
2159 | 2159 | | |
2160 | 2160 | | |
2161 | | - | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
2162 | 2166 | | |
2163 | 2167 | | |
2164 | 2168 | | |
| |||
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5741 | 5741 | | |
5742 | 5742 | | |
5743 | 5743 | | |
| 5744 | + | |
| 5745 | + | |
| 5746 | + | |
| 5747 | + | |
| 5748 | + | |
| 5749 | + | |
| 5750 | + | |
| 5751 | + | |
| 5752 | + | |
| 5753 | + | |
| 5754 | + | |
| 5755 | + | |
| 5756 | + | |
| 5757 | + | |
| 5758 | + | |
| 5759 | + | |
| 5760 | + | |
| 5761 | + | |
| 5762 | + | |
| 5763 | + | |
| 5764 | + | |
| 5765 | + | |
| 5766 | + | |
| 5767 | + | |
| 5768 | + | |
5744 | 5769 | | |
5745 | 5770 | | |
5746 | 5771 | | |
| |||
0 commit comments