Skip to content
This repository was archived by the owner on May 22, 2026. It is now read-only.

default optional const parameter to none - #1171

Merged
iscai-msft merged 12 commits into
Azure:autorestv3from
changlong-liu:20220225-optional-const-default-none
Mar 3, 2022
Merged

default optional const parameter to none#1171
iscai-msft merged 12 commits into
Azure:autorestv3from
changlong-liu:20220225-optional-const-default-none

Conversation

@changlong-liu

Copy link
Copy Markdown
Member

for issue #893

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

@iscai-msft iscai-msft left a comment

Copy link
Copy Markdown
Member

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!

Comment thread ChangeLog.md Outdated
Comment thread autorest/codegen/models/parameter.py Outdated
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
Copy Markdown
Member

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
Copy Markdown
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.

into your code flow.

:keyword input: Default value is "value1".
:keyword input: Default value is None.

Copy link
Copy Markdown
Member

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
Copy Markdown
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

@iscai-msft iscai-msft left a comment

Copy link
Copy Markdown
Member

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!

into your code flow.

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

Copy link
Copy Markdown
Member

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
Copy Markdown
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

Comment thread ChangeLog.md Outdated

- 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
Copy Markdown
Member

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

@iscai-msft iscai-msft left a comment

Copy link
Copy Markdown
Member

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants