Repository navigation
fix: pass mypy --strict in the small packages and read "false" as False in text - #785
Merged
Vincent Biret (baywet) merged 3 commits intoOct 14, 2026
Conversation
…se in text Fill the remaining annotation gaps in kiota_authentication_azure, kiota_bundle and the json, form, text and multipart serialization packages, and set strict = true in their [tool.mypy] sections so CI keeps them at zero. Bundle's two errors were calls to the untyped __new__ of ParseNodeFactoryRegistry and SerializationWriterFactoryRegistry, so those get annotated in kiota_abstractions too. TextParseNode.get_bool_value returned bool(text), so any non-empty text read as True, including a text/plain body of "false". It now compares the stripped, lowercased text to "true", like the form parse node does. Part of microsoft#722.
There was a problem hiding this comment.
🟢 Approval recommended
The implementation is consistent and low risk, with only a non-blocking empty-input regression-test gap.
1 open finding
What changed in this PR
Adds strict mypy enforcement to six smaller packages, completes required annotations, and fixes text deserialization of false.
Changes:
- Enables strict mypy checking across six packages.
- Adds missing generic, return, registry, URL, and tracing annotations.
- Corrects text boolean parsing and updates its regression test.
| File | Description |
|---|---|
packages/serialization/text/tests/unit/test_text_parse_node.py |
Tests textual boolean parsing. |
packages/serialization/text/pyproject.toml |
Enables strict mypy. |
packages/serialization/text/kiota_serialization_text/text_parse_node.py |
Initializes empty text and parses booleans correctly. |
packages/serialization/multipart/pyproject.toml |
Enables strict mypy. |
packages/serialization/multipart/kiota_serialization_multipart/multipart_serialization_writer.py |
Adds a return annotation. |
packages/serialization/json/pyproject.toml |
Enables strict mypy. |
packages/serialization/json/kiota_serialization_json/json_serialization_writer.py |
Tightens writer and helper annotations. |
packages/serialization/json/kiota_serialization_json/json_parse_node.py |
Annotates primitive conversion and removes an obsolete suppression. |
packages/serialization/form/pyproject.toml |
Enables strict mypy. |
packages/serialization/form/kiota_serialization_form/form_serialization_writer.py |
Adds a return annotation. |
packages/bundle/pyproject.toml |
Enables strict mypy. |
packages/authentication/azure/pyproject.toml |
Enables strict mypy. |
packages/authentication/azure/kiota_authentication_azure/azure_identity_authentication_provider.py |
Types authentication options. |
packages/authentication/azure/kiota_authentication_azure/azure_identity_access_token_provider.py |
Types options, parsed URLs, and spans. |
packages/abstractions/kiota_abstractions/serialization/serialization_writer_factory_registry.py |
Types the singleton constructor. |
packages/abstractions/kiota_abstractions/serialization/parse_node_factory_registry.py |
Types the singleton constructor. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Member
|
Max Azatian (@HardMax71) would you mind addressing copilot's feedback please? |
Contributor
Author
|
Vincent Biret (@baywet) addressed |
Vincent Biret (baywet)
approved these changes
Oct 14, 2026
Vincent Biret (baywet)
left a comment
Member
There was a problem hiding this comment.
Thank you for making the changes!
Vincent Biret (baywet)
enabled auto-merge
October 14, 2026 17:18
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Overview
Second item of the checklist in #722. It brings
kiota_authentication_azure,kiota_bundleand the json, form, text and multipart serialization packages to zero errors undermypy --strict, and setsstrict = truein their[tool.mypy]sections, so the existing CI mypy step keeps them there.Most of it is missing return annotations and bare
dicts. Bundle's two errors were calls to the untyped__new__ofParseNodeFactoryRegistryandSerializationWriterFactoryRegistry, so those two get annotated inkiota_abstractionstoo.Typing
TextParseNodeturned up a real bug.get_bool_valuereturnedbool(self._text), so any non-empty text came backTrue, including atext/plainbody offalse, which is whatTextSerializationWriterwrites forFalse. It now compares the stripped, lowercased text to"true", the wayFormParseNodedoes.Related Issue
Part of #722, which stays open for the remaining items.
Notes
Nothing here should break callers. The azure
optionsparameter goes fromdicttodict[str, Any], which**optionsalready required at runtime, and the registry constructors still accept and ignore any arguments.The old
test_get_bool_valuepassed the boolFalseinto thetext: strparameter, which is why theis Falsechecks were there. The test now uses strings.TextParseNode("")also stops leaving_textunset, so its getters returnNoneinstead of raisingAttributeError. The factory rejects empty content before that point anyway.In
JsonParseNode.get_collection_of_primitive_values, the innerfuncis annotated-> Any. It dispatches through a dict of converters, and mypy can't tie each converter back toT, so this only spells out the type it already had.Typing the registry constructors also clears the five untyped calls in
api_client_builderand two inhttpx_request_adapter. With mypy 2.4.0,mypy --strictacross the eight packages goes from 203 to 179 errors.Testing Instructions
mypy <package>passes from each of the six package folders, and it's a strict run now through the config. It passes with--python-version 3.10and--python-version 3.14too.mypy kiota_abstractionsfrompackages/abstractionsandmypy validationfromtests/validationstill pass.yapf -dr,pylint --disable=Wandpytestpass for the six packages and abstractions.pytest tests/unit/test_text_parse_node.pyinpackages/serialization/textfails ontest_get_bool_value[false-False].