Repository navigation
fix: pass mypy --strict in the small packages and read "false" as False in text - #785
Open
Max Azatian (HardMax71) wants to merge 1 commit into
Open
Max Azatian (HardMax71) wants to merge 1 commit into
Max Azatian (HardMax71) wants to merge 1 commit into
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.
1 of 11 tasks
|
This was referenced Oct 10, 2026
This branch has not been deployed
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].