From 93de1c74824485d6b587579a7958c2f53fcb6f62 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Thu, 28 Mar 2024 10:52:55 +1100 Subject: [PATCH 1/3] fix!: restrict exported names with __all__ Signed-off-by: Federico Bond --- openfeature/api.py | 15 +++++++++++++++ openfeature/client.py | 5 +++++ openfeature/evaluation_context.py | 2 ++ openfeature/event.py | 2 ++ openfeature/exception.py | 13 +++++++++++++ openfeature/flag_evaluation.py | 10 ++++++++++ openfeature/hook/__init__.py | 2 ++ openfeature/provider/__init__.py | 2 ++ openfeature/provider/provider.py | 2 ++ 9 files changed, 53 insertions(+) diff --git a/openfeature/api.py b/openfeature/api.py index cbff4b62..c04d423e 100644 --- a/openfeature/api.py +++ b/openfeature/api.py @@ -13,6 +13,21 @@ from openfeature.provider._registry import provider_registry from openfeature.provider.metadata import Metadata +__all__ = [ + "get_client", + "set_provider", + "clear_providers", + "get_provider_metadata", + "get_evaluation_context", + "set_evaluation_context", + "add_hooks", + "clear_hooks", + "get_hooks", + "shutdown", + "add_handler", + "remove_handler", +] + _evaluation_context = EvaluationContext() _hooks: typing.List[Hook] = [] diff --git a/openfeature/client.py b/openfeature/client.py index c2203ca1..0429911a 100644 --- a/openfeature/client.py +++ b/openfeature/client.py @@ -30,6 +30,11 @@ from openfeature.provider import FeatureProvider, ProviderStatus from openfeature.provider._registry import provider_registry +__all__ = [ + "ClientMetadata", + "OpenFeatureClient", +] + logger = logging.getLogger("openfeature") GetDetailCallable = typing.Union[ diff --git a/openfeature/evaluation_context.py b/openfeature/evaluation_context.py index 829ada63..c3af350c 100644 --- a/openfeature/evaluation_context.py +++ b/openfeature/evaluation_context.py @@ -1,6 +1,8 @@ import typing from dataclasses import dataclass, field +__all__ = ["EvaluationContext"] + @dataclass class EvaluationContext: diff --git a/openfeature/event.py b/openfeature/event.py index 367e5859..5fd64d2d 100644 --- a/openfeature/event.py +++ b/openfeature/event.py @@ -7,6 +7,8 @@ from openfeature.exception import ErrorCode from openfeature.provider import ProviderStatus +__all__ = ["ProviderEvent", "ProviderEventDetails", "EventDetails", "EventHandler"] + class ProviderEvent(Enum): PROVIDER_READY = "PROVIDER_READY" diff --git a/openfeature/exception.py b/openfeature/exception.py index d17c28fb..3ae54a56 100644 --- a/openfeature/exception.py +++ b/openfeature/exception.py @@ -4,6 +4,19 @@ from collections.abc import Mapping from enum import Enum +__all__ = [ + "OpenFeatureError", + "ProviderNotReadyError", + "ProviderFatalError", + "FlagNotFoundError", + "GeneralError", + "ParseError", + "TypeMismatchError", + "TargetingKeyMissingError", + "InvalidContextError", + "ErrorCode", +] + class OpenFeatureError(Exception): """ diff --git a/openfeature/flag_evaluation.py b/openfeature/flag_evaluation.py index 86233ed2..db9cea1b 100644 --- a/openfeature/flag_evaluation.py +++ b/openfeature/flag_evaluation.py @@ -11,6 +11,16 @@ from openfeature.hook import Hook, HookHints +__all__ = [ + "FlagType", + "Reason", + "FlagMetadata", + "FlagEvaluationDetails", + "FlagEvaluationOptions", + "FlagResolutionDetails", +] + + class FlagType(StrEnum): BOOLEAN = "BOOLEAN" STRING = "STRING" diff --git a/openfeature/hook/__init__.py b/openfeature/hook/__init__.py index 8cb1c14c..e1524ad1 100644 --- a/openfeature/hook/__init__.py +++ b/openfeature/hook/__init__.py @@ -12,6 +12,8 @@ from openfeature.client import ClientMetadata from openfeature.provider.metadata import Metadata +__all__ = ["HookType", "HookContext", "HookHints", "Hook"] + class HookType(Enum): BEFORE = "before" diff --git a/openfeature/provider/__init__.py b/openfeature/provider/__init__.py index 30ed103f..77111f29 100644 --- a/openfeature/provider/__init__.py +++ b/openfeature/provider/__init__.py @@ -7,6 +7,8 @@ from .metadata import Metadata +__all__ = ["ProviderStatus", "FeatureProvider", "Metadata"] + class ProviderStatus(Enum): NOT_READY = "NOT_READY" diff --git a/openfeature/provider/provider.py b/openfeature/provider/provider.py index debc1d56..9fc85946 100644 --- a/openfeature/provider/provider.py +++ b/openfeature/provider/provider.py @@ -8,6 +8,8 @@ from openfeature.provider import FeatureProvider from openfeature.provider.metadata import Metadata +__all__ = ["AbstractProvider"] + class AbstractProvider(FeatureProvider): def initialize(self, evaluation_context: EvaluationContext) -> None: From cfd5f8a3b2254de57c0f25604c0051ff901a24c2 Mon Sep 17 00:00:00 2001 From: gruebel Date: Tue, 9 Apr 2024 00:34:12 +0900 Subject: [PATCH 2/3] restrict codecov upload to Python 3.11 Signed-off-by: gruebel --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9cb863d6..3c7d9fda 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,7 +43,8 @@ jobs: - name: Run E2E tests with behave run: hatch run e2e - - name: Upload coverage to Codecov + - if: matrix.python-version == '3.11' + name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: flags: unittests # optional From 56136680c3fe773dfe41986ef7a040a71cf0dcb0 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 8 Apr 2024 22:10:34 -0400 Subject: [PATCH 3/3] disable codecov ci fail on error Signed-off-by: Michael Beemer --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3c7d9fda..f78ea064 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,7 +49,7 @@ jobs: with: flags: unittests # optional name: coverage # optional - fail_ci_if_error: true # optional (default = false) + fail_ci_if_error: false # optional (default = false) verbose: true # optional (default = false) lint: