Skip to content

Commit

Permalink
chore(deps): update pre-commit hook astral-sh/ruff-pre-commit to v0.8…
Browse files Browse the repository at this point in the history
….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]>
  • Loading branch information
renovate[bot] and gruebel authored Nov 25, 2024
1 parent 70acd1d commit cd737a9
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
default_stages: [commit]
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4
rev: v0.8.0
hooks:
- id: ruff
args: [--fix]
Expand Down
20 changes: 10 additions & 10 deletions openfeature/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@
)

__all__ = [
"get_client",
"set_provider",
"add_handler",
"add_hooks",
"clear_hooks",
"clear_providers",
"get_provider_metadata",
"get_client",
"get_evaluation_context",
"set_evaluation_context",
"set_transaction_context_propagator",
"get_hooks",
"get_provider_metadata",
"get_transaction_context",
"remove_handler",
"set_evaluation_context",
"set_provider",
"set_transaction_context",
"add_hooks",
"clear_hooks",
"get_hooks",
"set_transaction_context_propagator",
"shutdown",
"add_handler",
"remove_handler",
]

_evaluation_context = EvaluationContext()
Expand Down
2 changes: 1 addition & 1 deletion openfeature/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from openfeature.exception import ErrorCode

__all__ = ["ProviderEvent", "ProviderEventDetails", "EventDetails", "EventHandler"]
__all__ = ["EventDetails", "EventHandler", "ProviderEvent", "ProviderEventDetails"]


class ProviderEvent(Enum):
Expand Down
12 changes: 6 additions & 6 deletions openfeature/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
from enum import Enum

__all__ = [
"OpenFeatureError",
"ProviderNotReadyError",
"ProviderFatalError",
"ErrorCode",
"FlagNotFoundError",
"GeneralError",
"InvalidContextError",
"OpenFeatureError",
"ParseError",
"TypeMismatchError",
"ProviderFatalError",
"ProviderNotReadyError",
"TargetingKeyMissingError",
"InvalidContextError",
"ErrorCode",
"TypeMismatchError",
]


Expand Down
6 changes: 3 additions & 3 deletions openfeature/flag_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@


__all__ = [
"FlagType",
"Reason",
"FlagMetadata",
"FlagEvaluationDetails",
"FlagEvaluationOptions",
"FlagMetadata",
"FlagResolutionDetails",
"FlagType",
"Reason",
]


Expand Down
2 changes: 1 addition & 1 deletion openfeature/hook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from openfeature.client import ClientMetadata
from openfeature.provider.metadata import Metadata

__all__ = ["HookType", "HookContext", "HookHints", "Hook"]
__all__ = ["Hook", "HookContext", "HookHints", "HookType"]


class HookType(Enum):
Expand Down
2 changes: 1 addition & 1 deletion openfeature/provider/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from .metadata import Metadata

__all__ = ["AbstractProvider", "ProviderStatus", "FeatureProvider", "Metadata"]
__all__ = ["AbstractProvider", "FeatureProvider", "Metadata", "ProviderStatus"]


class ProviderStatus(Enum):
Expand Down
2 changes: 1 addition & 1 deletion openfeature/transaction_context/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
)

__all__ = [
"TransactionContextPropagator",
"ContextVarsTransactionContextPropagator",
"TransactionContextPropagator",
]
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from contextvars import ContextVar
from typing import Optional

from openfeature.evaluation_context import EvaluationContext
from openfeature.transaction_context.transaction_context_propagator import (
Expand All @@ -7,12 +8,17 @@


class ContextVarsTransactionContextPropagator(TransactionContextPropagator):
_transaction_context_var: ContextVar[EvaluationContext] = ContextVar(
"transaction_context", default=EvaluationContext()
_transaction_context_var: ContextVar[Optional[EvaluationContext]] = ContextVar(
"transaction_context", default=None
)

def get_transaction_context(self) -> EvaluationContext:
return self._transaction_context_var.get()
context = self._transaction_context_var.get()
if context is None:
context = EvaluationContext()
self._transaction_context_var.set(context)

return context

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

0 comments on commit cd737a9

Please sign in to comment.