diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 51720d14..2ceec4eb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -54,4 +54,5 @@ jobs: run: hatch build - name: Publish a Python distribution to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + # pinning till fixed https://github.com/pypa/gh-action-pypi-publish/issues/300 + uses: pypa/gh-action-pypi-publish@release/v1.11 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6258c8e4..c2b32957 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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] diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 449ac20d..967ffcc2 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1 +1 @@ -{".":"0.7.3"} \ No newline at end of file +{".":"0.7.4"} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index bb1297ac..2f734242 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.7.4](https://github.com/open-feature/python-sdk/compare/v0.7.3...v0.7.4) (2024-11-25) + + +### 🧹 Chore + +* **deps:** update pre-commit hook astral-sh/ruff-pre-commit to v0.8.0 ([#395](https://github.com/open-feature/python-sdk/issues/395)) ([cd737a9](https://github.com/open-feature/python-sdk/commit/cd737a9a6aeb6ff64050f759749aab96e73a8c34)) + ## [0.7.3](https://github.com/open-feature/python-sdk/compare/v0.7.2...v0.7.3) (2024-11-24) diff --git a/README.md b/README.md index 689706a9..8c078fab 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ - - Latest version + + Latest version @@ -60,13 +60,13 @@ #### Pip install ```bash -pip install openfeature-sdk==0.7.3 +pip install openfeature-sdk==0.7.4 ``` #### requirements.txt ```bash -openfeature-sdk==0.7.3 +openfeature-sdk==0.7.4 ``` ```python diff --git a/openfeature/api.py b/openfeature/api.py index c7d29c48..4460b695 100644 --- a/openfeature/api.py +++ b/openfeature/api.py @@ -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() diff --git a/openfeature/event.py b/openfeature/event.py index e41a3704..23210771 100644 --- a/openfeature/event.py +++ b/openfeature/event.py @@ -6,7 +6,7 @@ from openfeature.exception import ErrorCode -__all__ = ["ProviderEvent", "ProviderEventDetails", "EventDetails", "EventHandler"] +__all__ = ["EventDetails", "EventHandler", "ProviderEvent", "ProviderEventDetails"] class ProviderEvent(Enum): diff --git a/openfeature/exception.py b/openfeature/exception.py index 3ae54a56..0576ec17 100644 --- a/openfeature/exception.py +++ b/openfeature/exception.py @@ -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", ] diff --git a/openfeature/flag_evaluation.py b/openfeature/flag_evaluation.py index db9cea1b..1f83fd1b 100644 --- a/openfeature/flag_evaluation.py +++ b/openfeature/flag_evaluation.py @@ -12,12 +12,12 @@ __all__ = [ - "FlagType", - "Reason", - "FlagMetadata", "FlagEvaluationDetails", "FlagEvaluationOptions", + "FlagMetadata", "FlagResolutionDetails", + "FlagType", + "Reason", ] diff --git a/openfeature/hook/__init__.py b/openfeature/hook/__init__.py index e98301fa..77190dc0 100644 --- a/openfeature/hook/__init__.py +++ b/openfeature/hook/__init__.py @@ -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): diff --git a/openfeature/provider/__init__.py b/openfeature/provider/__init__.py index 8927551e..b390f928 100644 --- a/openfeature/provider/__init__.py +++ b/openfeature/provider/__init__.py @@ -11,7 +11,7 @@ from .metadata import Metadata -__all__ = ["AbstractProvider", "ProviderStatus", "FeatureProvider", "Metadata"] +__all__ = ["AbstractProvider", "FeatureProvider", "Metadata", "ProviderStatus"] class ProviderStatus(Enum): diff --git a/openfeature/transaction_context/__init__.py b/openfeature/transaction_context/__init__.py index e97fd36f..ca711cbf 100644 --- a/openfeature/transaction_context/__init__.py +++ b/openfeature/transaction_context/__init__.py @@ -6,6 +6,6 @@ ) __all__ = [ - "TransactionContextPropagator", "ContextVarsTransactionContextPropagator", + "TransactionContextPropagator", ] diff --git a/openfeature/transaction_context/context_var_transaction_context_propagator.py b/openfeature/transaction_context/context_var_transaction_context_propagator.py index 1abc04fa..5ffdae00 100644 --- a/openfeature/transaction_context/context_var_transaction_context_propagator.py +++ b/openfeature/transaction_context/context_var_transaction_context_propagator.py @@ -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 ( @@ -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) diff --git a/openfeature/version.py b/openfeature/version.py index 4910b9ec..ed9d4d87 100644 --- a/openfeature/version.py +++ b/openfeature/version.py @@ -1 +1 @@ -__version__ = "0.7.3" +__version__ = "0.7.4" diff --git a/pyproject.toml b/pyproject.toml index 49b667f7..394947a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "hatchling.build" [project] name = "openfeature_sdk" -version = "0.7.3" +version = "0.7.4" description = "Standardizing Feature Flagging for Everyone" readme = "README.md" authors = [{ name = "OpenFeature", email = "openfeature-core@groups.io" }]