66"""Synchronous feature manager implementation."""
77
88import logging
9- from typing import cast , overload , Any , Optional , Dict , Mapping , List , Tuple
9+ from typing import cast , overload , Any , Optional , Dict , Mapping , List , Tuple , Union
1010from ._defaultfilters import TimeWindowFilter , TargetingFilter
1111from ._featurefilters import FeatureFilter
1212from ._models import EvaluationEvent , Variant , TargetingContext
@@ -44,13 +44,17 @@ def __init__(self, configuration: Mapping[str, Any], **kwargs: Any):
4444 raise ValueError ("Custom filter must be a subclass of FeatureFilter" )
4545 self ._filters [feature_filter .name ] = feature_filter
4646
47- @overload # type: ignore
48- def is_enabled (self , feature_flag_id : str , user_id : str , ** kwargs : Any ) -> bool :
47+ @overload
48+ def is_enabled (self , feature_flag_id : str , ** kwargs : Any ) -> bool : ...
49+
50+ @overload
51+ def is_enabled (self , feature_flag_id : str , user_id : Union [str , TargetingContext ], ** kwargs : Any ) -> bool :
4952 """
5053 Determine if the feature flag is enabled for the given context.
5154
5255 :param str feature_flag_id: Name of the feature flag.
53- :param str user_id: User identifier.
56+ :param user_id: User identifier or targeting context, passed positionally.
57+ :type user_id: str or TargetingContext
5458 :return: True if the feature flag is enabled for the given context.
5559 :rtype: bool
5660 """
@@ -60,6 +64,7 @@ def is_enabled(self, feature_flag_id: str, *args: Any, **kwargs: Any) -> bool:
6064 Determine if the feature flag is enabled for the given context.
6165
6266 :param str feature_flag_id: Name of the feature flag.
67+ :param args: Optional positional user identifier or TargetingContext.
6368 :return: True if the feature flag is enabled for the given context.
6469 :rtype: bool
6570 """
@@ -76,13 +81,19 @@ def is_enabled(self, feature_flag_id: str, *args: Any, **kwargs: Any) -> bool:
7681 self ._on_feature_evaluated (result )
7782 return result .enabled
7883
79- @overload # type: ignore
80- def get_variant (self , feature_flag_id : str , user_id : str , ** kwargs : Any ) -> Optional [Variant ]:
84+ @overload
85+ def get_variant (self , feature_flag_id : str , ** kwargs : Any ) -> Optional [Variant ]: ...
86+
87+ @overload
88+ def get_variant (
89+ self , feature_flag_id : str , user_id : Union [str , TargetingContext ], ** kwargs : Any
90+ ) -> Optional [Variant ]:
8191 """
8292 Determine the variant for the given context.
8393
8494 :param str feature_flag_id: Name of the feature flag.
85- :param str user_id: User identifier.
95+ :param user_id: User identifier or targeting context, passed positionally.
96+ :type user_id: str or TargetingContext
8697 :return: return: Variant instance.
8798 :rtype: Variant
8899 """
@@ -92,7 +103,7 @@ def get_variant(self, feature_flag_id: str, *args: Any, **kwargs: Any) -> Option
92103 Determine the variant for the given context.
93104
94105 :param str feature_flag_id: Name of the feature flag
95- :keyword TargetingContext targeting_context: Targeting context .
106+ :param args: Optional positional user identifier or TargetingContext .
96107 :return: Variant instance.
97108 :rtype: Variant
98109 """
0 commit comments