Skip to content
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

default optional const parameter to none #1171

Merged

Conversation

changlong-liu
Copy link
Member

for issue #893

@changlong-liu changlong-liu marked this pull request as draft March 1, 2022 08:05
Copy link
Contributor

@iscai-msft iscai-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks really good, I think good to go once these comments are addressed!

@@ -63,7 +63,6 @@ async def patch_single(self, body: Any, **kwargs: Any) -> None:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize("object", pipeline_response)
raise HttpResponseError(response=response, model=error)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you know why there's different white space for mergepatchjson? Doesn't look like there were any code changes that would have led to it, maybe did you accidentally format it my opening the generated code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be strange that this happen when I generate the test project in windows, and don't happen in Linux. So I committed the Linux result to undo the changes.

But I guess it's not related with this PR because this also happen in branch autorestv3 in my local machine. I will investigate further when have time.

@@ -107,15 +107,15 @@ def build_put_no_model_as_string_no_required_one_value_no_default_request(
See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder
into your code flow.

:keyword input: Default value is "value1".
:keyword input: Default value is None.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also update the documentation to say the other value is "value1"? I think playing with code here is good

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@changlong-liu changlong-liu requested a review from msyyc March 2, 2022 09:21
Copy link
Contributor

@iscai-msft iscai-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some last minute nits and changelog comments, otherwise looks good!

@@ -107,15 +107,15 @@ def build_put_no_model_as_string_no_required_one_value_no_default_request(
See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder
into your code flow.

:keyword input: Default value is "value1".
:keyword input: Default value is None. Another value candidate is "value1".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: (feel free to not take). For enum values for example, we do "Possible values are...". For consistency I think it would be nice to do: "Possible values are 'value1' and None". Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Isabella, It's important suggestion that we should follow existing pattern, and I will move "Possible values are..." ahead of "Default value is .." like

ChangeLog.md Outdated
@@ -14,6 +14,7 @@

- Add default value consistently for parameters #1164
- Make `content_type` param keyword-only if there are multiple content types #1167
- Add flag `--default-optional-constants-to-none` for optional constant parameters #1171
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have picked this up in the first review, but we should do a minor version bump. We should add two entries, one under "New Features", and one other "Breaking Changes in Version Tolerant Generation".

In "New Features", we add this entry, saying "default optional constant parameters to None with this flag", and in "Brekaing Changes in Version Tolerant Generation" we say that by default we generate with optional constant parameters as None now by defaulting this flag to true

@iscai-msft iscai-msft marked this pull request as ready for review March 3, 2022 15:34
Copy link
Contributor

@iscai-msft iscai-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great, thank you! I didn't actually end up releasing 5.13.0 yesterday, so I'll change the changelog later to move it to 5.13.0. Thanks again!

@iscai-msft iscai-msft merged commit 8a5350d into Azure:autorestv3 Mar 3, 2022
iscai-msft added a commit that referenced this pull request Mar 3, 2022
…into next_link_opaque

* 'autorestv3' of https://github.com/Azure/autorest.python:
  Update package.json
  Update ChangeLog.md
  default optional const parameter to none (#1171)
  add storage to ci checks (#1176)
  fail on regeneration diff (#1173)
  Drop Python 2.7 (#1175)
  Add secrets test (#1174)
  bump testserver version (#1172)
iscai-msft added a commit that referenced this pull request Mar 9, 2022
…into inherit_customization

* 'autorestv3' of https://github.com/Azure/autorest.python:
  Update package.json
  Update ChangeLog.md
  default optional const parameter to none (#1171)
  add storage to ci checks (#1176)
  fail on regeneration diff (#1173)
  Drop Python 2.7 (#1175)
iscai-msft added a commit that referenced this pull request Mar 10, 2022
…into mypy_code

* 'autorestv3' of https://github.com/Azure/autorest.python: (26 commits)
  dpg service-driven-test (#1180)
  prepare for release (#1181)
  [Package mode] add new flag `--package-mode` (#1154)
  hide operation group docs (#1179)
  add coverage var (#1178)
  improve logging (#1177)
  don't reformat query params for dpg next link calls (#1168)
  Update package.json
  Update ChangeLog.md
  default optional const parameter to none (#1171)
  add storage to ci checks (#1176)
  fail on regeneration diff (#1173)
  Drop Python 2.7 (#1175)
  Add secrets test (#1174)
  bump testserver version (#1172)
  make content type keyword only if multiple (#1167)
  add default value info for params to docs (#1164)
  update release tests to hopefully get coverage report green (#1152)
  fix windows: clean the outputFolderUri  (#1135)
  Update CODEOWNERS
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants