Commit d81401b
feat(python): add Python 3.11+ StrEnum compatibility (#11105)
* feat(python): add Python 3.11+ StrEnum compatibility
Generated enums now use StrEnum for Python >= 3.11 and the (str, Enum)
mixin for older versions, fixing compatibility issues with Python 3.11's
stricter enum mixin handling.
- Add fern_enum.py utility with version-aware enum base class
- Update pydantic CoreUtilities to copy fern_enum.py
- Update SDK CoreUtilities to copy fern_enum.py
- Update enum generator to use FernEnum base class
Co-Authored-By: [email protected] <[email protected]>
* chore(python): address PR feedback - rename to StrEnum, rename file to enum.py, add comments, don't re-export
- Rename FernEnum to StrEnum (use native StrEnum for Python >= 3.11)
- Rename fern_enum.py to enum.py
- Add docstring explaining the version-aware enum base class
- Don't re-export StrEnum from __init__.py (internal use only)
Co-Authored-By: [email protected] <[email protected]>
* chore(python): add StrEnum support to fastapi and pydantic generators
- Update fastapi versions.yml with changelog entry for v1.12.2
- Update pydantic versions.yml with changelog entry for v1.10.2
- Add generated enum.py to pydantic seed output
Co-Authored-By: [email protected] <[email protected]>
* fix(python): change changelog type from feat to fix for fastapi and pydantic
The semver validator requires patch version bumps to use 'fix' type, not 'feat'.
This change is semantically correct since we're fixing Python 3.11 compatibility.
Co-Authored-By: [email protected] <[email protected]>
* chore(python): use module import pattern for StrEnum to avoid naming conflicts
Change import from 'from ..core.enum import StrEnum' to 'from ..core import enum'
so generated enums use 'enum.StrEnum' instead of 'StrEnum' directly.
This avoids potential naming conflicts with user-defined classes named StrEnum.
Co-Authored-By: [email protected] <[email protected]>
* chore(python): only copy enum.py when generating actual enum classes
Co-Authored-By: [email protected] <[email protected]>
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>1 parent 774f6e2 commit d81401b
File tree
23 files changed
+191
-31
lines changed- generators/python
- core_utilities
- pydantic
- sdk
- fastapi
- pydantic
- sdk
- src/fern_python/generators
- core_utilities
- pydantic_model/type_declaration_handler
- sdk/core_utilities
- seed
- pydantic/enum/src/seed/enum/core
- python-sdk/enum
- real-enum-forward-compat/src/seed
- core
- types
- unknown/types
- real-enum/src/seed
- core
- types
- unknown/types
23 files changed
+191
-31
lines changed| 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 | + | |
| 17 | + | |
| 18 | + | |
| 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 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
3 | 13 | | |
4 | 14 | | |
5 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
3 | 13 | | |
4 | 14 | | |
5 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
3 | 13 | | |
4 | 14 | | |
5 | 15 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
45 | 55 | | |
46 | 56 | | |
47 | 57 | | |
| |||
119 | 129 | | |
120 | 130 | | |
121 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
122 | 138 | | |
123 | 139 | | |
124 | 140 | | |
| |||
Lines changed: 1 addition & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 67 | + | |
74 | 68 | | |
75 | 69 | | |
76 | 70 | | |
| |||
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
56 | 68 | | |
57 | 69 | | |
58 | 70 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments