-
-
Notifications
You must be signed in to change notification settings - Fork 333
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 #2333. Remove not none arg parse defaults. #2334
base: main
Are you sure you want to change the base?
Fix #2333. Remove not none arg parse defaults. #2334
Conversation
aee8044
to
81fce3f
Compare
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.
Please add tests validating the change.
CodSpeed Performance ReportMerging #2334 will not alter performanceComparing Summary
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2334 +/- ##
=======================================
Coverage 98.39% 98.39%
=======================================
Files 65 65
Lines 7792 7798 +6
Branches 775 776 +1
=======================================
+ Hits 7667 7673 +6
Misses 91 91
Partials 34 34
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
883b50d
to
17b9a3c
Compare
@@ -71,6 +71,19 @@ def test_show_help_when_no_input(mocker: MockerFixture) -> None: | |||
assert print_help_mock.called | |||
|
|||
|
|||
def test_no_args_has_default(monkeypatch: pytest.MonkeyPatch) -> None: |
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.
I don't think this is the right test. We want to see that the pyprojct.toml
values are respected, not that no values have default values.
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.
I know but... Do you have any idea how to test that for all values without setting them by hand? I can't find a way to test the code in __main__.py
easily.
datamodel-code-generator/src/datamodel_code_generator/__main__.py
Lines 366 to 377 in ef0c97c
pyproject_config = _get_pyproject_toml_config(Path.cwd()) | |
if pyproject_config is not None: | |
pyproject_toml = {k.replace("-", "_"): v for k, v in pyproject_config.items()} | |
else: | |
pyproject_toml = {} | |
try: | |
config = Config.parse_obj(pyproject_toml) | |
config.merge_args(namespace) | |
except Error as e: | |
print(e.message, file=sys.stderr) # noqa: T201 | |
return Exit.ERROR |
This tests ensure that if a parameter is not given, then namespace
has no parameters set. This will ensure that no values from pyproject.toml
(L373) is overwritten (L374)
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.
CC: @koxudaxi
Steps
None
arg parse defaults__main__.Config
, are the same.Fix #2333
Breaking changes
None