fix: set a proper default value for non-nullable python fields#6489
fix: set a proper default value for non-nullable python fields#6489ntauth wants to merge 1 commit intomicrosoft:mainfrom
Conversation
@microsoft-github-policy-service agree company="Hoshii AG" |
| conventions.WriteInLineDescription(codeElement, writer); | ||
| var isNonNullableCollection = !codeElement.Type.IsNullable && codeElement.Type.CollectionKind != CodeTypeBase.CodeTypeCollectionKind.None; | ||
| writer.WriteLine($"{conventions.GetAccessModifier(codeElement.Access)}{codeElement.NamePrefix}{codeElement.Name}: {(codeElement.Type.IsNullable ? "Optional[" : string.Empty)}{returnType}{(codeElement.Type.IsNullable ? "]" : string.Empty)} {(isNonNullableCollection ? "= []" : "= None")}"); | ||
| var defaultFactoryType = codeElement.Type.CollectionKind.IsArray() ? "list" : "dict"; |
There was a problem hiding this comment.
I added "dict" as the other option because of the Complex type of CollectionKind. I assume Complex == object? That should never happen irl though
There was a problem hiding this comment.
None = single value,
Array = Array,
Complex = List or equivalent on the platform.
With that information in mind, can you please update the code?
baywet
left a comment
There was a problem hiding this comment.
also, can you please add a changelog entry (unreleased, changed)
| conventions.WriteInLineDescription(codeElement, writer); | ||
| var isNonNullableCollection = !codeElement.Type.IsNullable && codeElement.Type.CollectionKind != CodeTypeBase.CodeTypeCollectionKind.None; | ||
| writer.WriteLine($"{conventions.GetAccessModifier(codeElement.Access)}{codeElement.NamePrefix}{codeElement.Name}: {(codeElement.Type.IsNullable ? "Optional[" : string.Empty)}{returnType}{(codeElement.Type.IsNullable ? "]" : string.Empty)} {(isNonNullableCollection ? "= []" : "= None")}"); | ||
| var defaultFactoryType = codeElement.Type.CollectionKind.IsArray() ? "list" : "dict"; |
There was a problem hiding this comment.
None = single value,
Array = Array,
Complex = List or equivalent on the platform.
With that information in mind, can you please update the code?
|
@ntauth gentle reminder on this :) |
|
I am currently swamped with my own work, I will pick it back up when I have time and headroom. Feel free to fix the review comments if in a rush 👍
Il lun, giu 9, 2025 alle 21:20, Vincent Biret ***@***.***(mailto:Il lun, giu 9, 2025 alle 21:20, Vincent Biret <<a href=)> ha scritto:
… baywet left a comment [(microsoft/kiota#6489)](#6489 (comment))
***@***.***(https://github.com/ntauth) gentle reminder on this :)
—
Reply to this email directly, [view it on GitHub](#6489 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ADEKROBNVDVBW6RCXGSIQCL3CXNBRAVCNFSM6AAAAAB3TDPPSSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNJWG42DKNZQGE).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Fixes #6350