Skip to content

fix(http): pass mypy --strict in middleware options and fix three option bugs - #809

Merged
Vincent Biret (baywet) merged 2 commits into
microsoft:mainfrom
HardMax71:fix/strict-typing-middleware-options
Oct 16, 2026
Merged

Vincent Biret (baywet) merged 2 commits into
microsoft:mainfrom
HardMax71:fix/strict-typing-middleware-options

Conversation

@HardMax71

Copy link
Copy Markdown
Contributor

Overview

Seventh item in #722. kiota_http.middleware.options now passes mypy --strict, so errors in kiota_http go from 115 to 88 (mypy 2.4.0). The typed get_key() methods also clear three untyped calls in the adapter, the client factory and the retry handler.

Related Issue

Part of #722.

Demo

Not needed for this change.

Notes

While adding the types I found three bugs, and their fixes are the only runtime changes. UserAgentHandlerOption.is_enabled = False did nothing, because the setter wrote self._value (L31). It now sets self._enabled. UrlReplaceHandlerOption (L10) and ParametersNameDecodingHandlerOption (L11) used a dict and a list as default arguments. Python builds those once, so every option made with the default shared them, and a change to one showed up in all. The defaults are None now, and each option gets its own dict or list with the same default values.

Testing Instructions

  • mypy --strict kiota_http in packages/http/httpx shows nothing under middleware/options/, also with --python-version 3.10, and 88 errors overall instead of 115.
  • mypy kiota_http, yapf -dr kiota_http, pylint and pytest pass.
  • The three new tests fail without the source change.

…ion bugs

Add the missing return types in kiota_http.middleware.options. Part of microsoft#722.

UserAgentHandlerOption.is_enabled set self._value, so setting it to False did nothing. It now sets self._enabled.

UrlReplaceHandlerOption and ParametersNameDecodingHandlerOption used a dict and a list as default arguments. Python builds those once, so every option made with the default shared them, and a change to one showed up in all of them. The defaults are None now, and each option gets its own dict or list.
@HardMax71
Max Azatian (HardMax71) requested a review from a team as a code owner October 16, 2026 16:14
Copilot AI balanced review requested due to automatic review settings October 16, 2026 16:14

This comment was marked as off-topic.

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are localized, the three runtime fixes have regression coverage, and no blocking issues were identified.

0 open findings

🧠 Review effort: Balanced

@baywet Vincent Biret (baywet) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@github-project-automation github-project-automation Bot moved this to In Progress 🚧 in Kiota Oct 16, 2026
@baywet
Vincent Biret (baywet) merged commit 2d13770 into microsoft:main Oct 16, 2026
63 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress 🚧 to Done ✔️ in Kiota Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done ✔️

Development

Successfully merging this pull request may close these issues.

3 participants