Skip to content

Commit

Permalink
Merge pull request #5119 from microsoft/shem/fix_null_for_zero_error
Browse files Browse the repository at this point in the history
remove falsy check for nulls in method parameters
  • Loading branch information
baywet authored Aug 9, 2024
2 parents b507208 + ba5e39c commit 71344c2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Adds generation of default 'color.png`and`outline.png` files when generating plugins. [#4993](https://github.com/microsoft/kiota/issues/4993)
- Adds generation of default `color.png` and `outline.png` files when generating plugins. [#4993](https://github.com/microsoft/kiota/issues/4993)

### Changed

Expand All @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Exclude the `x-openai-isConsequential` extension from cleanup. [#4962](https://github.com/microsoft/kiota/issues/4962)
- Fixed file name and namespace sanitization when generating plugins. [#5019](https://github.com/microsoft/kiota/issues/5019)
- Added TypeScript typecheck suppression to generated method prototype, where anused arguments can cause build fail in projects which use `noUnusedLocals: true` compiler option. [#5095](https://github.com/microsoft/kiota/issues/5095)
- Fixed a bug where defensive programming would consider some default values as invalid in Python.

## [1.16.0] - 2024-07-05

Expand Down
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override void WriteCodeElement(CodeMethod codeElement, LanguageWriter wri
foreach (var parameter in codeElement.Parameters.Where(static x => !x.Optional).OrderBy(static x => x.Name))
{
var parameterName = parameter.Name;
writer.StartBlock($"if not {parameterName}:");
writer.StartBlock($"if {parameterName} is None:");
writer.WriteLine($"raise TypeError(\"{parameterName} cannot be null.\")");
writer.DecreaseIndent();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2086,7 +2086,7 @@ public void WritesNameMapperMethod()
});
writer.Write(method);
var result = tw.ToString();
Assert.Contains("if not original_name:", result);
Assert.Contains("if original_name is None:", result);
Assert.Contains("if original_name == \"select\":", result);
Assert.Contains("return \"%24select\"", result);
Assert.Contains("if original_name == \"expand\":", result);
Expand Down Expand Up @@ -2124,7 +2124,7 @@ public void WritesNameMapperMethodWithUnescapedProperties()
});
writer.Write(method);
var result = tw.ToString();
Assert.Contains("if not original_name:", result);
Assert.Contains("if original_name is None:", result);
Assert.Contains("if original_name == \"start_date_time\":", result);
Assert.Contains("return \"startDateTime\"", result);
Assert.Contains("return original_name", result);
Expand Down

0 comments on commit 71344c2

Please sign in to comment.