microsoft / microsoft/FeatureManagement-Python

Typing bug in FeatureManager.is_enabled overloads: single argument call not supported by type hints

未關閉
#62 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Python
星號
26
分支
11
PR 合併指標
30 天內沒有已合併 PR

描述

  • Package Version: 2.1.0
  • Operating System: Ubuntu
  • Python Version: 3.12

Describe the bug
The FeatureManager.is_enabled method has incorrect type hints in the published SDK.

The implementation accepts a single argument:

await feature_manager.is_enabled("my-flag")

This works at runtime because the method signature is:

async def is_enabled(self, feature_flag_id: str, *args, **kwargs) -> bool

However, the declared overloads do not include a signature that accepts only one argument. The only available overload is:

@overload
async def is_enabled(self, feature_flag_id: str, user_id: str, **kwargs) -> bool:
    ...

Type checkers such as Mypy report this usage as invalid and treat the return type as Any.

Expected Behavior
The type hints should describe all valid usages. Since the runtime implementation allows calling the method with only feature_flag_id, the overloads should include a matching variant.

Proposed Fix
Add a second overload:

@overload
async def is_enabled(self, feature_flag_id: str) -> bool:
    ...

This aligns the type hints with the implementation and returns the correct bool type to static analysis tools.

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

找出 FeatureManager.is_enabled 的多載宣告,並將其與此 issue 中的執行階段簽章和單一引數範例進行比較。加入缺少的單一引數型別標註變體,然後驗證靜態分析接受該呼叫並推斷出 bool。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
developer-experience
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
描述清楚
新手友好度
55/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。