Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 23, 2023
1 parent ffce1ff commit 1ac2ed0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
12 changes: 9 additions & 3 deletions UnleashClient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
from apscheduler.triggers.interval import IntervalTrigger

from UnleashClient.api import register_client
from UnleashClient.constants import DISABLED_VARIATION, ETAG, METRIC_LAST_SENT_TIME, REQUEST_TIMEOUT, REQUEST_RETRIES
from UnleashClient.constants import (
DISABLED_VARIATION,
ETAG,
METRIC_LAST_SENT_TIME,
REQUEST_RETRIES,
REQUEST_TIMEOUT,
)
from UnleashClient.events import UnleashEvent, UnleashEventType
from UnleashClient.features import Feature
from UnleashClient.loader import load_features
Expand Down Expand Up @@ -230,7 +236,7 @@ def initialize_client(self, fetch_toggles: bool = True) -> None:
"custom_options": self.unleash_custom_options,
"features": self.features,
"cache": self.cache,
"request_timeout": self.unleash_request_timeout
"request_timeout": self.unleash_request_timeout,
}

# Register app
Expand All @@ -243,7 +249,7 @@ def initialize_client(self, fetch_toggles: bool = True) -> None:
self.unleash_custom_headers,
self.unleash_custom_options,
self.strategy_mapping,
self.unleash_request_timeout
self.unleash_request_timeout,
)

if fetch_toggles:
Expand Down
6 changes: 4 additions & 2 deletions UnleashClient/periodic_tasks/send_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def aggregate_and_send_metrics(
custom_options: dict,
features: dict,
cache: BaseCache,
request_timeout: int
request_timeout: int,
) -> None:
feature_stats_list = []

Expand Down Expand Up @@ -45,7 +45,9 @@ def aggregate_and_send_metrics(
}

if feature_stats_list:
send_metrics(url, metrics_request, custom_headers, custom_options, request_timeout)
send_metrics(
url, metrics_request, custom_headers, custom_options, request_timeout
)
cache.set(METRIC_LAST_SENT_TIME, datetime.now(timezone.utc))
else:
LOGGER.debug("No feature flags with metrics, skipping metrics submission.")
9 changes: 8 additions & 1 deletion tests/unit_tests/api/test_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,14 @@ def test_get_feature_toggle_failed_etag():
)

(result, etag) = get_feature_toggles(
URL, APP_NAME, INSTANCE_ID, CUSTOM_HEADERS, CUSTOM_OPTIONS, 30, 3, PROJECT_NAME,
URL,
APP_NAME,
INSTANCE_ID,
CUSTOM_HEADERS,
CUSTOM_OPTIONS,
30,
3,
PROJECT_NAME,
)

assert len(responses.calls) == 4
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/api/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_register_client(payload, status, expected):
CUSTOM_HEADERS,
CUSTOM_OPTIONS,
DEFAULT_STRATEGY_MAPPING,
30
30,
)

assert len(responses.calls) == 1
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
PROJECT_URL,
REFRESH_INTERVAL,
REFRESH_JITTER,
URL,
REQUEST_RETRIES,
REQUEST_TIMEOUT,
REQUEST_RETRIES
URL,
)
from UnleashClient import INSTANCES, UnleashClient
from UnleashClient.cache import FileCache
Expand Down Expand Up @@ -163,7 +163,7 @@ def test_UC_initialize_full():
CUSTOM_HEADERS,
CUSTOM_OPTIONS,
REQUEST_TIMEOUT,
REQUEST_RETRIES
REQUEST_RETRIES,
)
assert client.unleash_instance_id == INSTANCE_ID
assert client.unleash_refresh_interval == REFRESH_INTERVAL
Expand Down

0 comments on commit 1ac2ed0

Please sign in to comment.