Skip to content

Commit cd737a9

Browse files
chore(deps): update pre-commit hook astral-sh/ruff-pre-commit to v0.8.0 (#395)
* chore(deps): update pre-commit hook astral-sh/ruff-pre-commit to v0.8.0 * fix ruff issues Signed-off-by: gruebel <[email protected]> --------- Signed-off-by: gruebel <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: gruebel <[email protected]>
1 parent 70acd1d commit cd737a9

File tree

9 files changed

+33
-27
lines changed

9 files changed

+33
-27
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
default_stages: [commit]
22
repos:
33
- repo: https://github.com/astral-sh/ruff-pre-commit
4-
rev: v0.7.4
4+
rev: v0.8.0
55
hooks:
66
- id: ruff
77
args: [--fix]

openfeature/api.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@
1818
)
1919

2020
__all__ = [
21-
"get_client",
22-
"set_provider",
21+
"add_handler",
22+
"add_hooks",
23+
"clear_hooks",
2324
"clear_providers",
24-
"get_provider_metadata",
25+
"get_client",
2526
"get_evaluation_context",
26-
"set_evaluation_context",
27-
"set_transaction_context_propagator",
27+
"get_hooks",
28+
"get_provider_metadata",
2829
"get_transaction_context",
30+
"remove_handler",
31+
"set_evaluation_context",
32+
"set_provider",
2933
"set_transaction_context",
30-
"add_hooks",
31-
"clear_hooks",
32-
"get_hooks",
34+
"set_transaction_context_propagator",
3335
"shutdown",
34-
"add_handler",
35-
"remove_handler",
3636
]
3737

3838
_evaluation_context = EvaluationContext()

openfeature/event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from openfeature.exception import ErrorCode
88

9-
__all__ = ["ProviderEvent", "ProviderEventDetails", "EventDetails", "EventHandler"]
9+
__all__ = ["EventDetails", "EventHandler", "ProviderEvent", "ProviderEventDetails"]
1010

1111

1212
class ProviderEvent(Enum):

openfeature/exception.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
from enum import Enum
66

77
__all__ = [
8-
"OpenFeatureError",
9-
"ProviderNotReadyError",
10-
"ProviderFatalError",
8+
"ErrorCode",
119
"FlagNotFoundError",
1210
"GeneralError",
11+
"InvalidContextError",
12+
"OpenFeatureError",
1313
"ParseError",
14-
"TypeMismatchError",
14+
"ProviderFatalError",
15+
"ProviderNotReadyError",
1516
"TargetingKeyMissingError",
16-
"InvalidContextError",
17-
"ErrorCode",
17+
"TypeMismatchError",
1818
]
1919

2020

openfeature/flag_evaluation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313

1414
__all__ = [
15-
"FlagType",
16-
"Reason",
17-
"FlagMetadata",
1815
"FlagEvaluationDetails",
1916
"FlagEvaluationOptions",
17+
"FlagMetadata",
2018
"FlagResolutionDetails",
19+
"FlagType",
20+
"Reason",
2121
]
2222

2323

openfeature/hook/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from openfeature.client import ClientMetadata
1313
from openfeature.provider.metadata import Metadata
1414

15-
__all__ = ["HookType", "HookContext", "HookHints", "Hook"]
15+
__all__ = ["Hook", "HookContext", "HookHints", "HookType"]
1616

1717

1818
class HookType(Enum):

openfeature/provider/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from .metadata import Metadata
1313

14-
__all__ = ["AbstractProvider", "ProviderStatus", "FeatureProvider", "Metadata"]
14+
__all__ = ["AbstractProvider", "FeatureProvider", "Metadata", "ProviderStatus"]
1515

1616

1717
class ProviderStatus(Enum):

openfeature/transaction_context/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
)
77

88
__all__ = [
9-
"TransactionContextPropagator",
109
"ContextVarsTransactionContextPropagator",
10+
"TransactionContextPropagator",
1111
]
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from contextvars import ContextVar
2+
from typing import Optional
23

34
from openfeature.evaluation_context import EvaluationContext
45
from openfeature.transaction_context.transaction_context_propagator import (
@@ -7,12 +8,17 @@
78

89

910
class ContextVarsTransactionContextPropagator(TransactionContextPropagator):
10-
_transaction_context_var: ContextVar[EvaluationContext] = ContextVar(
11-
"transaction_context", default=EvaluationContext()
11+
_transaction_context_var: ContextVar[Optional[EvaluationContext]] = ContextVar(
12+
"transaction_context", default=None
1213
)
1314

1415
def get_transaction_context(self) -> EvaluationContext:
15-
return self._transaction_context_var.get()
16+
context = self._transaction_context_var.get()
17+
if context is None:
18+
context = EvaluationContext()
19+
self._transaction_context_var.set(context)
20+
21+
return context
1622

1723
def set_transaction_context(self, transaction_context: EvaluationContext) -> None:
1824
self._transaction_context_var.set(transaction_context)

0 commit comments

Comments
 (0)