Skip to content

Commit

Permalink
fix!: restrict exported names with __all__ (#306)
Browse files Browse the repository at this point in the history
* fix!: restrict exported names with __all__

Signed-off-by: Federico Bond <federicobond@gmail.com>

* restrict codecov upload to Python 3.11

Signed-off-by: gruebel <anton.gruebel@gmail.com>

* disable codecov ci fail on error

Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>

---------

Signed-off-by: Federico Bond <federicobond@gmail.com>
Signed-off-by: gruebel <anton.gruebel@gmail.com>
Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
Co-authored-by: gruebel <anton.gruebel@gmail.com>
Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 9, 2024
1 parent 9966c14 commit 34ac91c
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ 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
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:
Expand Down
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 34ac91c

Please sign in to comment.