Skip to content

Commit ae0aaf5

Browse files
Fixing constants
1 parent 496c72f commit ae0aaf5

File tree

6 files changed

+35
-20
lines changed

6 files changed

+35
-20
lines changed

aws_lambda_powertools/utilities/feature_flags/comparators.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
from dateutil.tz import gettz
77

8-
from aws_lambda_powertools.utilities.feature_flags.schema import HOUR_MIN_SEPARATOR, ModuloRangeValues, TimeValues
8+
from aws_lambda_powertools.utilities.feature_flags.constants import HOUR_MIN_SEPARATOR
9+
from aws_lambda_powertools.utilities.feature_flags.schema import ModuloRangeValues, TimeValues
910

1011

1112
def _get_now_from_timezone(timezone: tzinfo | None) -> datetime:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import re
2+
3+
RULES_KEY = "rules"
4+
FEATURE_DEFAULT_VAL_KEY = "default"
5+
CONDITIONS_KEY = "conditions"
6+
RULE_MATCH_VALUE = "when_match"
7+
CONDITION_KEY = "key"
8+
CONDITION_VALUE = "value"
9+
CONDITION_ACTION = "action"
10+
FEATURE_DEFAULT_VAL_TYPE_KEY = "boolean_type"
11+
TIME_RANGE_FORMAT = "%H:%M" # hour:min 24 hours clock
12+
TIME_RANGE_PATTERN = re.compile(r"2[0-3]:[0-5]\d|[0-1]\d:[0-5]\d") # 24 hour clock
13+
HOUR_MIN_SEPARATOR = ":"

aws_lambda_powertools/utilities/feature_flags/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class SchemaValidationError(Exception):
77

88

99
class StoreClientError(Exception):
10-
"""When a store raises an exception that should be propagated to the client to fix
10+
"""When a store raises an exception that should be propagated to the client
1111
1212
For example, Access Denied errors when the client doesn't permissions to fetch config
1313
"""

aws_lambda_powertools/utilities/feature_flags/feature_flags.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from __future__ import annotations
22

33
import logging
4-
from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast
5-
6-
from typing_extensions import ParamSpec
4+
from typing import TYPE_CHECKING, Any, Callable, cast
75

86
from aws_lambda_powertools.utilities.feature_flags import schema
97
from aws_lambda_powertools.utilities.feature_flags.comparators import (
@@ -16,14 +14,13 @@
1614
compare_time_range,
1715
)
1816
from aws_lambda_powertools.utilities.feature_flags.exceptions import ConfigurationStoreError
17+
from aws_lambda_powertools.utilities.feature_flags.types import P, T
1918

2019
if TYPE_CHECKING:
2120
from aws_lambda_powertools.logging import Logger
2221
from aws_lambda_powertools.utilities.feature_flags.base import StoreProvider
2322
from aws_lambda_powertools.utilities.feature_flags.types import JSONType
2423

25-
T = TypeVar("T")
26-
P = ParamSpec("P")
2724

2825
RULE_ACTION_MAPPING = {
2926
schema.RuleAction.EQUALS.value: lambda a, b: a == b,

aws_lambda_powertools/utilities/feature_flags/schema.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import logging
4-
import re
54
from datetime import datetime
65
from enum import Enum
76
from functools import lru_cache
@@ -15,17 +14,18 @@
1514
if TYPE_CHECKING:
1615
from aws_lambda_powertools.logging import Logger
1716

18-
RULES_KEY = "rules"
19-
FEATURE_DEFAULT_VAL_KEY = "default"
20-
CONDITIONS_KEY = "conditions"
21-
RULE_MATCH_VALUE = "when_match"
22-
CONDITION_KEY = "key"
23-
CONDITION_VALUE = "value"
24-
CONDITION_ACTION = "action"
25-
FEATURE_DEFAULT_VAL_TYPE_KEY = "boolean_type"
26-
TIME_RANGE_FORMAT = "%H:%M" # hour:min 24 hours clock
27-
TIME_RANGE_PATTERN = re.compile(r"2[0-3]:[0-5]\d|[0-1]\d:[0-5]\d") # 24 hour clock
28-
HOUR_MIN_SEPARATOR = ":"
17+
from aws_lambda_powertools.utilities.feature_flags.constants import (
18+
CONDITION_ACTION,
19+
CONDITION_KEY,
20+
CONDITION_VALUE,
21+
CONDITIONS_KEY,
22+
FEATURE_DEFAULT_VAL_KEY,
23+
FEATURE_DEFAULT_VAL_TYPE_KEY,
24+
RULE_MATCH_VALUE,
25+
RULES_KEY,
26+
TIME_RANGE_FORMAT,
27+
TIME_RANGE_PATTERN,
28+
)
2929

3030
LOGGER: logging.Logger | Logger = logging.getLogger(__name__)
3131

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
from __future__ import annotations
22

3-
from typing import Any
3+
from typing import Any, TypeVar
4+
5+
from typing_extensions import ParamSpec
46

57
# JSON primitives only, mypy doesn't support recursive tho
68
JSONType = str | int | float | bool | None | dict[str, Any] | list[Any]
9+
T = TypeVar("T")
10+
P = ParamSpec("P")

0 commit comments

Comments
 (0)