Skip to content

Commit

Permalink
fix!: restrict exported names with __all__
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Bond <federicobond@gmail.com>
  • Loading branch information
federicobond committed Apr 7, 2024
1 parent 9966c14 commit 93de1c7
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 0 deletions.
15 changes: 15 additions & 0 deletions openfeature/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []
Expand Down
5 changes: 5 additions & 0 deletions openfeature/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[
Expand Down
2 changes: 2 additions & 0 deletions openfeature/evaluation_context.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import typing
from dataclasses import dataclass, field

__all__ = ["EvaluationContext"]


@dataclass
class EvaluationContext:
Expand Down
2 changes: 2 additions & 0 deletions openfeature/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 13 additions & 0 deletions openfeature/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
10 changes: 10 additions & 0 deletions openfeature/flag_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
from openfeature.hook import Hook, HookHints


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


class FlagType(StrEnum):
BOOLEAN = "BOOLEAN"
STRING = "STRING"
Expand Down
2 changes: 2 additions & 0 deletions openfeature/hook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions openfeature/provider/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from .metadata import Metadata

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


class ProviderStatus(Enum):
NOT_READY = "NOT_READY"
Expand Down
2 changes: 2 additions & 0 deletions openfeature/provider/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 93de1c7

Please sign in to comment.