microsoft / microsoft/FeatureManagement-Python

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

Offen
#62 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Python
Sterne
26
Forks
11
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Finde die Überladungsdeklarationen von FeatureManager.is_enabled und vergleiche sie mit der Laufzeitsignatur und dem einargumentigen Beispiel in diesem Issue. Füge die fehlende Typisierungsvariante mit einem Argument hinzu und überprüfe anschließend, dass die statische Analyse den Aufruf akzeptiert und bool ableitet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
developer-experience
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
55/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.