diff --git a/.isort.cfg b/.isort.cfg index 12a52aa..a607a1e 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -3,4 +3,4 @@ use_parentheses=true multi_line_output=3 include_trailing_comma=true line_length=79 -known_third_party = pytest,requests,requests_futures,setuptools +known_third_party = flag_engine,flask,pytest,requests,requests_futures,responses diff --git a/flagsmith/flagsmith.py b/flagsmith/flagsmith.py index 3b444e7..8b1e28d 100644 --- a/flagsmith/flagsmith.py +++ b/flagsmith/flagsmith.py @@ -26,8 +26,8 @@ def __init__( environment_key: str, api_url: str = DEFAULT_API_URL, custom_headers: typing.Dict[str, typing.Any] = None, - request_timeout: int = None, - enable_client_side_evaluation: bool = False, + request_timeout_seconds: int = None, + enable_local_evaluation: bool = False, environment_refresh_interval_seconds: int = 60, retries: Retry = None, enable_analytics: bool = False, @@ -40,7 +40,7 @@ def __init__( retries = retries or Retry(total=3, backoff_factor=0.1) self.api_url = api_url if api_url.endswith("/") else f"{api_url}/" - self.request_timeout = request_timeout + self.request_timeout_seconds = request_timeout_seconds self.session.mount(self.api_url, HTTPAdapter(max_retries=retries)) self.environment_flags_url = f"{self.api_url}flags/" @@ -48,7 +48,7 @@ def __init__( self.environment_url = f"{self.api_url}environment-document/" self._environment = None - if enable_client_side_evaluation: + if enable_local_evaluation: self.environment_data_polling_manager_thread = ( EnvironmentDataPollingManager( main=self, @@ -59,7 +59,7 @@ def __init__( self._analytics_processor = ( AnalyticsProcessor( - environment_key, self.api_url, timeout=self.request_timeout + environment_key, self.api_url, timeout=self.request_timeout_seconds ) if enable_analytics else None @@ -151,7 +151,9 @@ def _get_identity_flags_from_api( def _get_json_response(self, url: str, method: str, body: dict = None): try: request_method = getattr(self.session, method.lower()) - response = request_method(url, json=body, timeout=self.request_timeout) + response = request_method( + url, json=body, timeout=self.request_timeout_seconds + ) if response.status_code != 200: raise FlagsmithAPIError( "Invalid request made to Flagsmith API. Response status code: %d", diff --git a/tests/test_flagsmith.py b/tests/test_flagsmith.py index 95d681f..b3fff22 100644 --- a/tests/test_flagsmith.py +++ b/tests/test_flagsmith.py @@ -20,7 +20,7 @@ def test_flagsmith_starts_polling_manager_on_init_if_enabled(mocker, api_key): ) # When - Flagsmith(environment_key=api_key, enable_client_side_evaluation=True) + Flagsmith(environment_key=api_key, enable_local_evaluation=True) # Then mock_polling_manager.start.assert_called_once()