You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd expect it to not fail, since the third, target_datetime_class, is not used anyway.
I'd suggest setting a default:
target_datetime_class: Optional[DatetimeClassType] = None, since it's not used anyway. See this fork branch
target_datetime_class: DatetimeClassType = DatetimeClassType.Datetime, if we want an actual useful choice. See this fork branch
In fact -- personally, I'd set a default for the target_python_version as well, setting it to the python version where the module is being run.
Yes, explicit over implicit, and having defaults has disadvantages, always. It does a lot for UX though.
Personally, I'd set these defaults in the format.py module, where the DataModelType and PythonVersion enums are defined, and use them throughout.
I tried, but ran into some test errors I didn't understand, so defined the defaults in model/__init__.py itself in this pull request #2196.
Version:
OS: Sanoma
Python version: 3.10
datamodel-code-generator version: 0.26.3
The text was updated successfully, but these errors were encountered:
thorwhalen
added a commit
to thorwhalen/datamodel-code-generator
that referenced
this issue
Nov 27, 2024
* fix: get_data_model_types argument target_datetime_class has None default. See #2195
* fix: target_datetime_class defaults to DatetimeClassType.Datetime. See #2195
* fix: set defaults in module to make it easier to move to global defaults
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Koudai Aono <[email protected]>
Describe the bug
It's not a bug, but a code smell that led to errors on my side.
Simply put:
target_datetime_class
is not used in the get_data_model_types function, and yet it's a required argument.To Reproduce
Expected behavior
I'd expect it to not fail, since the third,
target_datetime_class
, is not used anyway.I'd suggest setting a default:
target_datetime_class: Optional[DatetimeClassType] = None
, since it's not used anyway. See this fork branchtarget_datetime_class: DatetimeClassType = DatetimeClassType.Datetime
, if we want an actual useful choice. See this fork branchIn fact -- personally, I'd set a default for the
target_python_version
as well, setting it to the python version where the module is being run.Yes, explicit over implicit, and having defaults has disadvantages, always. It does a lot for UX though.
Personally, I'd set these defaults in the
format.py
module, where theDataModelType
andPythonVersion
enums are defined, and use them throughout.I tried, but ran into some test errors I didn't understand, so defined the defaults in
model/__init__.py
itself in this pull request #2196.Version:
The text was updated successfully, but these errors were encountered: