Skip to content

Commit a19e5bf

Browse files
committed
fix lint issues
1 parent 6959036 commit a19e5bf

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

ldclient/config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99

1010
from ldclient.feature_store import InMemoryFeatureStore
1111
from ldclient.hook import Hook
12-
from ldclient.impl.util import log, validate_application_info, validate_sdk_key_format
12+
from ldclient.impl.util import (
13+
log,
14+
validate_application_info,
15+
validate_sdk_key_format
16+
)
1317
from ldclient.interfaces import (
1418
BigSegmentStore,
1519
DataSourceUpdateSink,

ldclient/impl/util.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def validate_application_value(value: Any, name: str, logger: logging.Logger) ->
6161
def validate_sdk_key_format(sdk_key: str, logger: logging.Logger) -> str:
6262
"""
6363
Validates that an SDK key does not contain invalid characters and is not too long for our systems.
64-
64+
6565
:param sdk_key: the SDK key to validate
6666
:param logger: the logger to use for logging warnings
6767
:return: the validated SDK key, or empty string if the SDK key is invalid
@@ -71,15 +71,12 @@ def validate_sdk_key_format(sdk_key: str, logger: logging.Logger) -> str:
7171

7272
if not isinstance(sdk_key, str):
7373
return ""
74-
7574
if len(sdk_key) > _MAX_SDK_KEY_LENGTH:
7675
logger.warning('SDK key was longer than %d characters and was discarded' % _MAX_SDK_KEY_LENGTH)
7776
return ""
78-
7977
if _VALID_CHARACTERS_REGEX.search(sdk_key):
8078
logger.warning('SDK key contained invalid characters and was discarded')
8179
return ""
82-
8380
return sdk_key
8481

8582

ldclient/testing/impl/test_util.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
23
from ldclient.impl.util import validate_sdk_key_format
34

45

@@ -12,7 +13,7 @@ def test_validate_sdk_key_format_valid():
1213
"test.key_with.dots",
1314
"test-key-with-hyphens"
1415
]
15-
16+
1617
for key in valid_keys:
1718
result = validate_sdk_key_format(key, logger)
1819
assert result == key # Should return the same key if valid
@@ -23,13 +24,13 @@ def test_validate_sdk_key_format_invalid():
2324
logger = logging.getLogger('test')
2425
invalid_keys = [
2526
"sdk-key-with-\x00-null",
26-
"sdk-key-with-\n-newline",
27+
"sdk-key-with-\n-newline",
2728
"sdk-key-with-\t-tab",
2829
"sdk key with spaces",
2930
"sdk@key#with$special%chars",
3031
"sdk/key\\with/slashes"
3132
]
32-
33+
3334
for key in invalid_keys:
3435
result = validate_sdk_key_format(key, logger)
3536
assert result == '' # Should return empty string for invalid keys
@@ -39,7 +40,7 @@ def test_validate_sdk_key_format_non_string():
3940
"""Test validation of non-string SDK keys"""
4041
logger = logging.getLogger('test')
4142
non_string_values = [123, object(), [], {}]
42-
43+
4344
for value in non_string_values:
4445
result = validate_sdk_key_format(value, logger)
4546
assert result == '' # Should return empty string for non-string values
@@ -58,7 +59,7 @@ def test_validate_sdk_key_format_max_length():
5859
valid_key = "a" * 8192
5960
result = validate_sdk_key_format(valid_key, logger)
6061
assert result == valid_key # Should return the same key if valid
61-
62+
6263
invalid_key = "a" * 8193
6364
result = validate_sdk_key_format(invalid_key, logger)
6465
assert result == '' # Should return empty string for keys that are too long

ldclient/testing/test_config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_sdk_key_validation_valid_keys():
5454
"test.key_with.dots",
5555
"test-key-with-hyphens"
5656
]
57-
57+
5858
for key in valid_keys:
5959
config = Config(sdk_key=key)
6060
assert config.sdk_key == key
@@ -70,7 +70,7 @@ def test_sdk_key_validation_invalid_keys():
7070
"sdk@key#with$special%chars",
7171
"sdk/key\\with/slashes"
7272
]
73-
73+
7474
for key in invalid_keys:
7575
config = Config(sdk_key=key)
7676
assert config.sdk_key == ''
@@ -93,7 +93,7 @@ def test_sdk_key_validation_max_length():
9393
valid_key = "a" * 8192
9494
config = Config(sdk_key=valid_key)
9595
assert config.sdk_key == valid_key
96-
96+
9797
invalid_key = "a" * 8193
9898
config = Config(sdk_key=invalid_key)
9999
assert config.sdk_key == ''
@@ -102,10 +102,10 @@ def test_sdk_key_validation_max_length():
102102
def test_copy_with_new_sdk_key_validation():
103103
"""Test that copy_with_new_sdk_key validates the new key"""
104104
original_config = Config(sdk_key="valid-key")
105-
105+
106106
new_config = original_config.copy_with_new_sdk_key("another-valid-key")
107107
assert new_config.sdk_key == "another-valid-key"
108-
108+
109109
invalid_config = original_config.copy_with_new_sdk_key("invalid key with spaces")
110110
assert invalid_config.sdk_key == ''
111111

0 commit comments

Comments
 (0)