fb-python-sdk 1.2.1__py3-none-any.whl → 1.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
fbclient/event_types.py CHANGED
@@ -3,7 +3,7 @@ from threading import Event
3
3
  from time import time
4
4
  from typing import Optional
5
5
 
6
- from fbclient.common_types import _EvalResult, FBEvent, FBUser
6
+ from fbclient.common_types import FBEvent, FBUser, _EvalResult
7
7
 
8
8
 
9
9
  class MessageType(Enum):
@@ -16,7 +16,9 @@ class MessageType(Enum):
16
16
 
17
17
 
18
18
  class EventMessage:
19
- def __init__(self, type: MessageType, event: Optional[FBEvent], await_termination: bool):
19
+ def __init__(
20
+ self, type: MessageType, event: Optional[FBEvent], await_termination: bool
21
+ ):
20
22
  self.__type = type
21
23
  self.__event = event
22
24
  self.__wait_lock = Event() if await_termination else None
@@ -56,9 +58,9 @@ class Metric:
56
58
  def __init__(self, event_name: str, value: float):
57
59
  self.__event_name = event_name
58
60
  self.__value = value
59
- self.__route = 'index/metric'
60
- self.__type = 'CustomEvent'
61
- self.__app_type = 'pythonserverside'
61
+ self.__route = "index/metric"
62
+ self.__type = "CustomEvent"
63
+ self.__app_type = "pythonserverside"
62
64
  self.__timestamp = int(round(time() * 1000))
63
65
 
64
66
  @property
@@ -98,7 +100,7 @@ class UserEvent(FBEvent):
98
100
  return self._user is not None
99
101
 
100
102
  def to_json_dict(self) -> dict:
101
- return {'user': self._user.to_json_dict()}
103
+ return {"user": self._user.to_json_dict()}
102
104
 
103
105
 
104
106
  class FlagEvent(FBEvent):
@@ -117,18 +119,20 @@ class FlagEvent(FBEvent):
117
119
  return self._user and len(self.__variations) > 0
118
120
 
119
121
  def to_json_dict(self) -> dict:
120
- json_dict = {'user': self._user.to_json_dict()}
122
+ json_dict = {"user": self._user.to_json_dict()}
121
123
  arr = []
122
124
  for variation in self.__variations:
123
- flag_json_dict = {'featureFlagKey': variation.variation.key_name,
124
- 'timestamp': variation.timestamp,
125
- 'variation': {
126
- 'id': variation.variation.id,
127
- 'value': variation.variation.value,
128
- 'reason': variation.variation.reason
129
- }}
125
+ flag_json_dict = {
126
+ "featureFlagKey": variation.variation.key_name,
127
+ "timestamp": variation.timestamp,
128
+ "variation": {
129
+ "id": variation.variation.id,
130
+ "value": variation.variation.value,
131
+ "reason": variation.variation.reason,
132
+ },
133
+ }
130
134
  arr.append(flag_json_dict)
131
- json_dict['variations'] = arr # type: ignore
135
+ json_dict["variations"] = arr # type: ignore
132
136
  return json_dict
133
137
 
134
138
 
@@ -148,15 +152,17 @@ class MetricEvent(FBEvent):
148
152
  return self._user and len(self.__metrics) > 0
149
153
 
150
154
  def to_json_dict(self) -> dict:
151
- json_dict = {'user': self._user.to_json_dict()}
155
+ json_dict = {"user": self._user.to_json_dict()}
152
156
  arr = []
153
157
  for metric in self.__metrics:
154
- metric_json_dict = {'eventName': metric.event_name,
155
- 'numericValue': metric.value,
156
- 'route': metric.route,
157
- 'type': metric.type,
158
- 'appType': metric.app_type,
159
- 'timestamp': metric.timestamp}
158
+ metric_json_dict = {
159
+ "eventName": metric.event_name,
160
+ "numericValue": metric.value,
161
+ "route": metric.route,
162
+ "type": metric.type,
163
+ "appType": metric.app_type,
164
+ "timestamp": metric.timestamp,
165
+ }
160
166
  arr.append(metric_json_dict)
161
- json_dict['metrics'] = arr # type: ignore
167
+ json_dict["metrics"] = arr # type: ignore
162
168
  return json_dict
@@ -1,11 +1,11 @@
1
-
2
1
  from abc import ABC, abstractmethod
3
2
  from typing import Any, Callable
3
+
4
4
  from fbclient.common_types import FBUser
5
5
  from fbclient.interfaces import Notice
6
6
  from fbclient.notice_broadcaster import NoticeBroadcater
7
7
 
8
- FLAG_CHANGE_NOTICE_TYPE = 'flag_change_notice'
8
+ FLAG_CHANGE_NOTICE_TYPE = "flag_change_notice"
9
9
 
10
10
 
11
11
  class FlagChangedNotice(Notice):
@@ -28,23 +28,28 @@ class FlagChangedListener(ABC):
28
28
  This is an abstract class. You need to implement your own listener by overriding the :func:`on_flag_change` method.
29
29
 
30
30
  """
31
+
31
32
  @abstractmethod
32
33
  def on_flag_change(self, notice: FlagChangedNotice):
33
34
  pass
34
35
 
35
36
 
36
37
  class FlagValueChangedListener(FlagChangedListener):
37
- def __init__(self,
38
- flag_key: str,
39
- user: dict,
40
- evaluate_fn: Callable[[str, dict, Any], Any],
41
- flag_value_changed_fn: Callable[[str, Any, Any], None]):
38
+ def __init__(
39
+ self,
40
+ flag_key: str,
41
+ user: dict,
42
+ evaluate_fn: Callable[[str, dict, Any], Any],
43
+ flag_value_changed_fn: Callable[[str, Any, Any], None],
44
+ ):
42
45
  self.__flag_key = flag_key
43
46
  self.__user = user
44
47
  self.__evaluate_fn = evaluate_fn
45
48
  self.__fn = flag_value_changed_fn
46
49
  # record the flag value when the listener is created
47
- self.__prvious_flag_value = self.__evaluate_fn(self.__flag_key, self.__user, None)
50
+ self.__prvious_flag_value = self.__evaluate_fn(
51
+ self.__flag_key, self.__user, None
52
+ )
48
53
 
49
54
  def on_flag_change(self, notice: FlagChangedNotice):
50
55
  if notice.flag_key == self.__flag_key:
@@ -56,11 +61,13 @@ class FlagValueChangedListener(FlagChangedListener):
56
61
 
57
62
 
58
63
  class FlagValueMaybeChangedListener(FlagChangedListener):
59
- def __init__(self,
60
- flag_key: str,
61
- user: dict,
62
- evaluate_fn: Callable[[str, dict, Any], Any],
63
- flag_value_maybe_changed_fn: Callable[[str, Any], None]):
64
+ def __init__(
65
+ self,
66
+ flag_key: str,
67
+ user: dict,
68
+ evaluate_fn: Callable[[str, dict, Any], Any],
69
+ flag_value_maybe_changed_fn: Callable[[str, Any], None],
70
+ ):
64
71
  self.__flag_key = flag_key
65
72
  self.__user = user
66
73
  self.__evaluate_fn = evaluate_fn
@@ -82,9 +89,11 @@ class FlagTracker:
82
89
  Application code never needs to initialize or extend this class directly.
83
90
  """
84
91
 
85
- def __init__(self,
86
- flag_change_broadcaster: NoticeBroadcater,
87
- evaluate_fn: Callable[[str, dict, Any], Any]):
92
+ def __init__(
93
+ self,
94
+ flag_change_broadcaster: NoticeBroadcater,
95
+ evaluate_fn: Callable[[str, dict, Any], Any],
96
+ ):
88
97
  """
89
98
  :param flag_change_broadcaster: The broadcaster that broadcasts the flag change notices
90
99
  :param evaluate_fn: The function to evaluate the flag value
@@ -92,10 +101,12 @@ class FlagTracker:
92
101
  self.__broadcater = flag_change_broadcaster
93
102
  self.__evaluate_fn = evaluate_fn
94
103
 
95
- def add_flag_value_changed_listener(self,
96
- flag_key: str,
97
- user: dict,
98
- flag_value_changed_fn: Callable[[str, Any, Any], None]) -> FlagValueChangedListener:
104
+ def add_flag_value_changed_listener(
105
+ self,
106
+ flag_key: str,
107
+ user: dict,
108
+ flag_value_changed_fn: Callable[[str, Any, Any], None],
109
+ ) -> FlagValueChangedListener:
99
110
  """
100
111
  Registers a listener to be notified of a change in a specific feature flag's value for a specific FeatBit user.
101
112
 
@@ -118,21 +129,25 @@ class FlagTracker:
118
129
 
119
130
  # check flag key
120
131
  if not isinstance(flag_key, str) or not flag_key:
121
- raise ValueError('flag_key must be a non-empty string')
132
+ raise ValueError("flag_key must be a non-empty string")
122
133
  # check user
123
134
  FBUser.from_dict(user)
124
135
  # check flag_value_changed_fn
125
136
  if not isinstance(flag_value_changed_fn, Callable) or not flag_value_changed_fn:
126
- raise ValueError('flag_value_changed_fn must be a callable function')
137
+ raise ValueError("flag_value_changed_fn must be a callable function")
127
138
 
128
- listener = FlagValueChangedListener(flag_key, user, self.__evaluate_fn, flag_value_changed_fn)
139
+ listener = FlagValueChangedListener(
140
+ flag_key, user, self.__evaluate_fn, flag_value_changed_fn
141
+ )
129
142
  self.add_flag_changed_listener(listener)
130
143
  return listener
131
144
 
132
- def add_flag_value_maybe_changed_listener(self,
133
- flag_key: str,
134
- user: dict,
135
- flag_value_maybe_changed_fn: Callable[[str, Any], None]) -> FlagValueMaybeChangedListener:
145
+ def add_flag_value_maybe_changed_listener(
146
+ self,
147
+ flag_key: str,
148
+ user: dict,
149
+ flag_value_maybe_changed_fn: Callable[[str, Any], None],
150
+ ) -> FlagValueMaybeChangedListener:
136
151
  """
137
152
  Registers a listener to be notified of a change in a specific feature flag's value for a specific FeatBit user.
138
153
 
@@ -156,14 +171,19 @@ class FlagTracker:
156
171
 
157
172
  # check flag key
158
173
  if not isinstance(flag_key, str) or not flag_key:
159
- raise ValueError('flag_key must be a non-empty string')
174
+ raise ValueError("flag_key must be a non-empty string")
160
175
  # check user
161
176
  FBUser.from_dict(user)
162
177
  # check flag_value_changed_fn
163
- if not isinstance(flag_value_maybe_changed_fn, Callable) or not flag_value_maybe_changed_fn:
164
- raise ValueError('flag_value_changed_fn must be a callable function')
165
-
166
- listener = FlagValueMaybeChangedListener(flag_key, user, self.__evaluate_fn, flag_value_maybe_changed_fn)
178
+ if (
179
+ not isinstance(flag_value_maybe_changed_fn, Callable)
180
+ or not flag_value_maybe_changed_fn
181
+ ):
182
+ raise ValueError("flag_value_changed_fn must be a callable function")
183
+
184
+ listener = FlagValueMaybeChangedListener(
185
+ flag_key, user, self.__evaluate_fn, flag_value_maybe_changed_fn
186
+ )
167
187
  self.add_flag_changed_listener(listener)
168
188
  return listener
169
189
 
@@ -184,4 +204,6 @@ class FlagTracker:
184
204
 
185
205
  :param listener: The listener to be unregistered. The listener must be the same object that was passed to :func:`add_flag_changed_listner` or :func:`add_flag_value_changed_listerner`
186
206
  """
187
- self.__broadcater.remove_listener(FLAG_CHANGE_NOTICE_TYPE, listener.on_flag_change) # type: ignore
207
+ self.__broadcater.remove_listener(
208
+ FLAG_CHANGE_NOTICE_TYPE, listener.on_flag_change
209
+ ) # type: ignore
fbclient/interfaces.py CHANGED
@@ -7,24 +7,24 @@ from fbclient.status_types import State
7
7
 
8
8
 
9
9
  class UpdateProcessor(ABC):
10
- '''
10
+ """
11
11
  Interface for the component that obtains feature flag data in some way and passes it to a
12
12
  :class:`DataStorage`. The built-in imp now of this is streaming, we will provide the polling update
13
13
  and file update soon
14
- '''
14
+ """
15
15
 
16
16
  @abstractmethod
17
17
  def start(self):
18
- '''
18
+ """
19
19
  Starts an operation in the background.
20
- '''
20
+ """
21
21
  pass
22
22
 
23
23
  @abstractmethod
24
24
  def stop(self):
25
- '''
25
+ """
26
26
  Stops an operation running in the background.
27
- '''
27
+ """
28
28
  pass
29
29
 
30
30
  @property
@@ -37,13 +37,15 @@ class UpdateProcessor(ABC):
37
37
 
38
38
 
39
39
  class DataUpdateStatusProvider(ABC):
40
- '''
40
+ """
41
41
  Interface for manipulating the data updates in :class: `DataStorage` and maintain the status of :class: `UpdateProcessor`.
42
42
  The implementation should be called in :class: `UpdateProcessor`.
43
- '''
43
+ """
44
44
 
45
45
  @abstractmethod
46
- def init(self, all_data: Mapping[Category, Mapping[str, dict]], version: int = 0) -> bool:
46
+ def init(
47
+ self, all_data: Mapping[Category, Mapping[str, dict]], version: int = 0
48
+ ) -> bool:
47
49
  """
48
50
  Manipulate the init operation in data storage. If the underlying data storage throws an error during this operation, the SDK will catch it, log it,
49
51
  and set the state of update process to INTERRUPTED. It will not rethrow the error to other level, but will simply return falseto indicate that the operation failed.
@@ -179,7 +181,9 @@ class DataStorage(ABC):
179
181
  pass
180
182
 
181
183
  @abstractmethod
182
- def init(self, all_data: Mapping[Category, Mapping[str, dict]], version: int = 0) -> bool:
184
+ def init(
185
+ self, all_data: Mapping[Category, Mapping[str, dict]], version: int = 0
186
+ ) -> bool:
183
187
  """
184
188
  Init (or re-init by data update process) the storage with the specified set of data.
185
189
  Any existing entries will be removed if the new data set's version is greater than the current version
@@ -266,7 +270,9 @@ class Sender(ABC):
266
270
  """
267
271
 
268
272
  @abstractmethod
269
- def postJson(self, url: str, json_str: str, fetch_response: bool = True) -> Optional[str]:
273
+ def postJson(
274
+ self, url: str, json_str: str, fetch_response: bool = True
275
+ ) -> Optional[str]:
270
276
  """
271
277
  Sends a json object via HTTP POST to the given URL
272
278
 
@@ -290,6 +296,7 @@ class Notice(ABC):
290
296
  This is not an insight event to be sent to FeatBit Flag Center; it is a notice to notify the SDK that something has happened,
291
297
  such as flag values updated
292
298
  """
299
+
293
300
  @property
294
301
  @abstractmethod
295
302
  def notice_type(self) -> str:
@@ -1,9 +1,8 @@
1
-
2
1
  from queue import Queue
3
2
  from threading import Lock, Thread, current_thread
4
3
  from typing import Callable
5
- from fbclient.interfaces import Notice
6
4
 
5
+ from fbclient.interfaces import Notice
7
6
  from fbclient.utils import log
8
7
 
9
8
 
@@ -14,15 +13,19 @@ class NoticeBroadcater:
14
13
  self.__listeners = {}
15
14
  self.__lock = Lock()
16
15
  self.__stop_notice = object()
17
- self.__thread = Thread(name='featbit-notice-broadcaster',
18
- daemon=True,
19
- target=self.__run)
20
- log.debug('notice broadcaster starting...')
16
+ self.__thread = Thread(
17
+ name="featbit-notice-broadcaster", daemon=True, target=self.__run
18
+ )
19
+ log.debug("notice broadcaster starting...")
21
20
  self.__thread.start()
22
21
 
23
22
  def add_listener(self, notice_type: str, listener: Callable[[Notice], None]):
24
- if isinstance(notice_type, str) and notice_type.strip() and listener is not None:
25
- log.debug('add a listener for notice type %s' % notice_type)
23
+ if (
24
+ isinstance(notice_type, str)
25
+ and notice_type.strip()
26
+ and listener is not None
27
+ ):
28
+ log.debug("add a listener for notice type %s" % notice_type)
26
29
  with self.__lock:
27
30
  if self.__closed:
28
31
  return
@@ -36,7 +39,7 @@ class NoticeBroadcater:
36
39
  def remove_listener(self, notice_type: str, listener: Callable[[Notice], None]):
37
40
  if listener is None:
38
41
  return
39
- log.debug('remove a listener for notice type %s' % notice_type)
42
+ log.debug("remove a listener for notice type %s" % notice_type)
40
43
  with self.__lock:
41
44
  notifiers = self.__listeners.get(notice_type)
42
45
  if not notifiers:
@@ -57,7 +60,7 @@ class NoticeBroadcater:
57
60
  self.__notice_queue.put(notice)
58
61
 
59
62
  def stop(self):
60
- log.debug('notice broadcaster stopping...')
63
+ log.debug("notice broadcaster stopping...")
61
64
  with self.__lock:
62
65
  if self.__closed:
63
66
  return
@@ -66,7 +69,7 @@ class NoticeBroadcater:
66
69
  if current_thread() is not self.__thread:
67
70
  self.__thread.join(5.0)
68
71
  if self.__thread.is_alive():
69
- log.warning('FB Python SDK: notice broadcaster did not stop in time')
72
+ log.warning("FB Python SDK: notice broadcaster did not stop in time")
70
73
 
71
74
  def __run(self):
72
75
  while True:
@@ -82,4 +85,7 @@ class NoticeBroadcater:
82
85
  try:
83
86
  listener(notice)
84
87
  except Exception as e:
85
- log.exception('FB Python SDK: unexpected error in handle notice %s: %s' % (notice.notice_type, str(e)))
88
+ log.exception(
89
+ "FB Python SDK: unexpected error in handle notice %s: %s"
90
+ % (notice.notice_type, str(e))
91
+ )
fbclient/status.py CHANGED
@@ -5,13 +5,16 @@ from typing import Callable, Deque, List, Mapping, Tuple
5
5
 
6
6
  from fbclient.category import Category
7
7
  from fbclient.interfaces import DataStorage, DataUpdateStatusProvider
8
- from fbclient.status_types import (DATA_STORAGE_INIT_ERROR,
9
- DATA_STORAGE_UPDATE_ERROR, State, StateType)
8
+ from fbclient.status_types import (
9
+ DATA_STORAGE_INIT_ERROR,
10
+ DATA_STORAGE_UPDATE_ERROR,
11
+ State,
12
+ StateType,
13
+ )
10
14
  from fbclient.utils import log
11
15
 
12
16
 
13
17
  class DataUpdateStatusProviderImpl(DataUpdateStatusProvider):
14
-
15
18
  def __init__(self, storage: DataStorage):
16
19
  self.__storage = storage
17
20
  self.__current_state = State.intializing_state()
@@ -22,7 +25,9 @@ class DataUpdateStatusProviderImpl(DataUpdateStatusProvider):
22
25
  ] = deque()
23
26
  self.__is_publishing_notifications = False
24
27
 
25
- def init(self, all_data: Mapping[Category, Mapping[str, dict]], version: int = 0) -> bool:
28
+ def init(
29
+ self, all_data: Mapping[Category, Mapping[str, dict]], version: int = 0
30
+ ) -> bool:
26
31
  try:
27
32
  result = self.__storage.init(all_data, version)
28
33
  except Exception as e:
@@ -42,7 +47,10 @@ class DataUpdateStatusProviderImpl(DataUpdateStatusProvider):
42
47
  return result is not False
43
48
 
44
49
  def __handle_exception(self, error: Exception, error_type: str, message: str):
45
- log.exception('FB Python SDK: Data Storage error: %s, UpdateProcessor will attempt to receive the data' % str(error))
50
+ log.exception(
51
+ "FB Python SDK: Data Storage error: %s, UpdateProcessor will attempt to receive the data"
52
+ % str(error)
53
+ )
46
54
  self.update_state(State.interrupted_state(error_type, message))
47
55
 
48
56
  def get_all(self, kind: Category) -> Mapping[str, dict]:
@@ -71,12 +79,19 @@ class DataUpdateStatusProviderImpl(DataUpdateStatusProvider):
71
79
  error = new_state.error_track
72
80
  # special case: if ``new_state`` is INTERRUPTED, but the previous state was INITIALIZING, the state will remain at INITIALIZING
73
81
  # INTERRUPTED is only meaningful after a successful startup
74
- if new_state_type == StateType.INTERRUPTED and old_state_type == StateType.INITIALIZING:
82
+ if (
83
+ new_state_type == StateType.INTERRUPTED
84
+ and old_state_type == StateType.INITIALIZING
85
+ ):
75
86
  new_state_type = StateType.INITIALIZING
76
87
 
77
88
  # normal case
78
89
  if new_state_type != old_state_type or error is not None:
79
- state_since = time() if new_state_type != old_state_type else self.__current_state.state_since
90
+ state_since = (
91
+ time()
92
+ if new_state_type != old_state_type
93
+ else self.__current_state.state_since
94
+ )
80
95
  self.__current_state = State(new_state_type, state_since, error)
81
96
  # wakes up all threads waiting for the ok state to check the new state
82
97
  self.__lock.notify_all()
@@ -102,7 +117,7 @@ class DataUpdateStatusProviderImpl(DataUpdateStatusProvider):
102
117
  try:
103
118
  listener(state)
104
119
  except Exception:
105
- log.exception('FB Python SDK: Update status listener failed')
120
+ log.exception("FB Python SDK: Update status listener failed")
106
121
 
107
122
  def add_listener(self, listener: Callable[[State], None]):
108
123
  if not callable(listener):
@@ -112,7 +127,7 @@ class DataUpdateStatusProviderImpl(DataUpdateStatusProvider):
112
127
  if listener not in self.__listeners:
113
128
  self.__listeners.append(listener)
114
129
  except Exception:
115
- log.exception('FB Python SDK: Could not add update status listener')
130
+ log.exception("FB Python SDK: Could not add update status listener")
116
131
 
117
132
  def remove_listener(self, listener: Callable[[State], None]):
118
133
  with self.__lock:
@@ -121,7 +136,7 @@ class DataUpdateStatusProviderImpl(DataUpdateStatusProvider):
121
136
  except ValueError:
122
137
  pass
123
138
  except Exception:
124
- log.exception('FB Python SDK: Could not remove update status listener')
139
+ log.exception("FB Python SDK: Could not remove update status listener")
125
140
 
126
141
  def wait_for_OKState(self, timeout: float = 0) -> bool:
127
142
  _timeout = 0 if timeout is None or timeout <= 0 else timeout
@@ -133,7 +148,7 @@ class DataUpdateStatusProviderImpl(DataUpdateStatusProvider):
133
148
  elif StateType.OFF == self.__current_state.state_type:
134
149
  return False
135
150
  else:
136
- if (_timeout == 0):
151
+ if _timeout == 0:
137
152
  self.__lock.wait()
138
153
  else:
139
154
  now = time()
fbclient/status_types.py CHANGED
@@ -2,27 +2,27 @@ from enum import Enum
2
2
  from time import time
3
3
  from typing import Optional
4
4
 
5
- DATA_STORAGE_INIT_ERROR = 'Data Storage init error'
5
+ DATA_STORAGE_INIT_ERROR = "Data Storage init error"
6
6
 
7
- DATA_STORAGE_UPDATE_ERROR = 'Data Storage update error'
7
+ DATA_STORAGE_UPDATE_ERROR = "Data Storage update error"
8
8
 
9
- REQUEST_INVALID_ERROR = 'Request invalid'
9
+ REQUEST_INVALID_ERROR = "Request invalid"
10
10
 
11
- DATA_INVALID_ERROR = 'Received Data invalid'
11
+ DATA_INVALID_ERROR = "Received Data invalid"
12
12
 
13
- NETWORK_ERROR = 'Network error'
13
+ NETWORK_ERROR = "Network error"
14
14
 
15
- RUNTIME_ERROR = 'Runtime error'
15
+ RUNTIME_ERROR = "Runtime error"
16
16
 
17
- WEBSOCKET_ERROR = 'WebSocket error'
17
+ WEBSOCKET_ERROR = "WebSocket error"
18
18
 
19
- UNKNOWN_ERROR = 'Unknown error'
19
+ UNKNOWN_ERROR = "Unknown error"
20
20
 
21
- UNKNOWN_CLOSE_CODE = 'Unknown close code'
21
+ UNKNOWN_CLOSE_CODE = "Unknown close code"
22
22
 
23
- SYSTEM_ERROR = 'System error'
23
+ SYSTEM_ERROR = "System error"
24
24
 
25
- SYSTEM_QUIT = 'System quit'
25
+ SYSTEM_QUIT = "System quit"
26
26
 
27
27
 
28
28
  class StateType(Enum):
@@ -31,6 +31,7 @@ class StateType(Enum):
31
31
  If it encounters an error that requires it to retry initialization, the state will remain at
32
32
  INITIALIZING until it either succeeds and becomes OK, or permanently fails and becomes OFF.
33
33
  """
34
+
34
35
  INITIALIZING = 1
35
36
  """
36
37
  Indicates that the update processing is currently operational and has not had any problems since the
@@ -68,7 +69,12 @@ class ErrorTrack:
68
69
 
69
70
 
70
71
  class State:
71
- def __init__(self, state_type: "StateType", state_since: float, error_track: Optional["ErrorTrack"] = None):
72
+ def __init__(
73
+ self,
74
+ state_type: "StateType",
75
+ state_since: float,
76
+ error_track: Optional["ErrorTrack"] = None,
77
+ ):
72
78
  self.__state_type = state_type
73
79
  self.__state_since = state_since
74
80
  self.__error_track = error_track