microsoft / microsoft/FeatureManagement-Python

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

Open
#62 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
26
Forks
11
PR merge metrics
No merged PRs in 30d

Description

  • 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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the FeatureManager.is_enabled overload declarations and compare them with the runtime signature and the single-argument example in this issue. Add the missing one-argument typing variant, then verify that static analysis accepts the call and infers bool.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.