|
10 | 10 | from six import string_types |
11 | 11 | from typing_extensions import Unpack |
12 | 12 |
|
13 | | -from posthog.args import (ID_TYPES, ExceptionArg, OptionalCaptureArgs, |
14 | | - OptionalSetArgs) |
| 13 | +from posthog.args import ID_TYPES, ExceptionArg, OptionalCaptureArgs, OptionalSetArgs |
15 | 14 | from posthog.consumer import Consumer |
16 | | -from posthog.contexts import (_get_current_context, get_context_distinct_id, |
17 | | - get_context_session_id, new_context) |
| 15 | +from posthog.contexts import ( |
| 16 | + _get_current_context, |
| 17 | + get_context_distinct_id, |
| 18 | + get_context_session_id, |
| 19 | + new_context, |
| 20 | +) |
18 | 21 | from posthog.exception_capture import ExceptionCapture |
19 | | -from posthog.exception_utils import (exc_info_from_error, |
20 | | - exception_is_already_captured, |
21 | | - exceptions_from_error_tuple, |
22 | | - handle_in_app, mark_exception_as_captured) |
23 | | -from posthog.feature_flags import (InconclusiveMatchError, |
24 | | - match_feature_flag_properties) |
| 22 | +from posthog.exception_utils import ( |
| 23 | + exc_info_from_error, |
| 24 | + exception_is_already_captured, |
| 25 | + exceptions_from_error_tuple, |
| 26 | + handle_in_app, |
| 27 | + mark_exception_as_captured, |
| 28 | +) |
| 29 | +from posthog.feature_flags import InconclusiveMatchError, match_feature_flag_properties |
25 | 30 | from posthog.poller import Poller |
26 | | -from posthog.request import (DEFAULT_HOST, APIError, batch_post, |
27 | | - determine_server_host, flags, get, remote_config) |
28 | | -from posthog.types import (FeatureFlag, FeatureFlagResult, FlagMetadata, |
29 | | - FlagsAndPayloads, FlagsResponse, FlagValue, |
30 | | - normalize_flags_response, to_flags_and_payloads, |
31 | | - to_payloads, to_values) |
32 | | -from posthog.utils import (FlagCache, RedisFlagCache, SizeLimitedDict, clean, |
33 | | - guess_timezone, remove_trailing_slash, |
34 | | - system_context) |
| 31 | +from posthog.request import ( |
| 32 | + DEFAULT_HOST, |
| 33 | + APIError, |
| 34 | + batch_post, |
| 35 | + determine_server_host, |
| 36 | + flags, |
| 37 | + get, |
| 38 | + remote_config, |
| 39 | +) |
| 40 | +from posthog.types import ( |
| 41 | + FeatureFlag, |
| 42 | + FeatureFlagResult, |
| 43 | + FlagMetadata, |
| 44 | + FlagsAndPayloads, |
| 45 | + FlagsResponse, |
| 46 | + FlagValue, |
| 47 | + normalize_flags_response, |
| 48 | + to_flags_and_payloads, |
| 49 | + to_payloads, |
| 50 | + to_values, |
| 51 | +) |
| 52 | +from posthog.utils import ( |
| 53 | + FlagCache, |
| 54 | + RedisFlagCache, |
| 55 | + SizeLimitedDict, |
| 56 | + clean, |
| 57 | + guess_timezone, |
| 58 | + remove_trailing_slash, |
| 59 | + system_context, |
| 60 | +) |
35 | 61 | from posthog.version import VERSION |
36 | 62 |
|
37 | 63 | try: |
@@ -274,9 +300,9 @@ def feature_flags(self, flags): |
274 | 300 | for flag in self._feature_flags |
275 | 301 | if flag.get("key") is not None |
276 | 302 | } |
277 | | - assert ( |
278 | | - self.feature_flags_by_key is not None |
279 | | - ), "feature_flags_by_key should be initialized when feature_flags is set" |
| 303 | + assert self.feature_flags_by_key is not None, ( |
| 304 | + "feature_flags_by_key should be initialized when feature_flags is set" |
| 305 | + ) |
280 | 306 |
|
281 | 307 | def get_feature_variants( |
282 | 308 | self, |
@@ -1435,9 +1461,9 @@ def _locally_evaluate_flag( |
1435 | 1461 | response = None |
1436 | 1462 |
|
1437 | 1463 | if self.feature_flags: |
1438 | | - assert ( |
1439 | | - self.feature_flags_by_key is not None |
1440 | | - ), "feature_flags_by_key should be initialized when feature_flags is set" |
| 1464 | + assert self.feature_flags_by_key is not None, ( |
| 1465 | + "feature_flags_by_key should be initialized when feature_flags is set" |
| 1466 | + ) |
1441 | 1467 | # Local evaluation |
1442 | 1468 | flag = self.feature_flags_by_key.get(key) |
1443 | 1469 | if flag: |
|
0 commit comments