Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed a bug where the description special characters are encoded. [5286](https://github.com/microsoft/kiota/issues/5286)
- Fixed a bug where python constructor parameters are being cast to strings leading to bugs as the types is unknown on graph call. [microsoftgraph/msgraph-sdk-python#165](https://github.com/microsoftgraph/msgraph-sdk-python/issues/165)
- Fixed a bug where child path segment from single parameter path segment would be incorrectly escaped. [#5433](https://github.com/microsoft/kiota/issues/5433)
- Fixed inconsistent typing information generated for `ParsableFactory` and stream return types in python [kiota-abstractions-python#533](https://github.com/microsoft/kiota-abstractions-python/issues/333)

## [1.18.0] - 2024-09-05

Expand Down
7 changes: 4 additions & 3 deletions src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ private void WriteRequestExecutorBody(CodeMethod codeElement, RequestParams requ
{
_codeUsingWriter.WriteInternalErrorMappingImports(parentClass, writer);
errorMappingVarName = "error_mapping";
writer.StartBlock($"{errorMappingVarName}: Dict[str, ParsableFactory] = {{");
writer.StartBlock($"{errorMappingVarName}: Dict[str, type[ParsableFactory]] = {{");
foreach (var errorMapping in codeElement.ErrorMappings)
{
writer.WriteLine($"\"{errorMapping.Key.ToUpperInvariant()}\": {errorMapping.Value.Name},");
Expand Down Expand Up @@ -736,8 +736,9 @@ private void WriteMethodPrototype(CodeMethod code, LanguageWriter writer, string
.Select(p => new PythonConventionService() // requires a writer instance because method parameters use inline type definitions
.GetParameterSignature(p, code, writer))
.ToList());
var nullablePrefix = code.ReturnType.IsNullable && !isVoid ? "Optional[" : string.Empty;
var nullableSuffix = code.ReturnType.IsNullable && !isVoid ? "]" : string.Empty;
var isStreamType = conventions.StreamTypeName.Equals(returnType, StringComparison.OrdinalIgnoreCase);
var nullablePrefix = (code.ReturnType.IsNullable || isStreamType) && !isVoid ? "Optional[" : string.Empty;
var nullableSuffix = (code.ReturnType.IsNullable || isStreamType) && !isVoid ? "]" : string.Empty;
var propertyDecorator = code.Kind switch
{
CodeMethodKind.Getter => "@property",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ public void WritesRequestExecutorBody()
Assert.Contains("from .error401 import Error401", result);
Assert.Contains("from .error4_x_x import Error4XX", result);
Assert.Contains("from .error5_x_x import Error5XX", result);
Assert.Contains("error_mapping: Dict[str, ParsableFactory] =", result);
Assert.Contains("error_mapping: Dict[str, type[ParsableFactory]] =", result);
Assert.Contains("\"4XX\": Error4XX", result);
Assert.Contains("\"5XX\": Error5XX", result);
Assert.Contains("\"401\": Error401", result);
Expand Down