microsoft / microsoft/FeatureManagement-Python

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

Aperta
#62 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
26
Fork
11
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Individua le dichiarazioni degli overload di FeatureManager.is_enabled e confrontale con la firma a runtime e con l’esempio con un singolo argomento presente in questa issue. Aggiungi la variante di tipizzazione con un argomento mancante, quindi verifica che l’analisi statica accetti la chiamata e inferisca bool.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
developer-experience
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.