Skip to content

Commit 34ac91c

Browse files
federicobondgruebelbeeme1mr
authored
fix!: restrict exported names with __all__ (#306)
* fix!: restrict exported names with __all__ Signed-off-by: Federico Bond <[email protected]> * restrict codecov upload to Python 3.11 Signed-off-by: gruebel <[email protected]> * disable codecov ci fail on error Signed-off-by: Michael Beemer <[email protected]> --------- Signed-off-by: Federico Bond <[email protected]> Signed-off-by: gruebel <[email protected]> Signed-off-by: Michael Beemer <[email protected]> Co-authored-by: gruebel <[email protected]> Co-authored-by: Michael Beemer <[email protected]>
1 parent 9966c14 commit 34ac91c

File tree

10 files changed

+56
-2
lines changed

10 files changed

+56
-2
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ jobs:
4343
- name: Run E2E tests with behave
4444
run: hatch run e2e
4545

46-
- name: Upload coverage to Codecov
46+
- if: matrix.python-version == '3.11'
47+
name: Upload coverage to Codecov
4748
uses: codecov/codecov-action@v3
4849
with:
4950
flags: unittests # optional
5051
name: coverage # optional
51-
fail_ci_if_error: true # optional (default = false)
52+
fail_ci_if_error: false # optional (default = false)
5253
verbose: true # optional (default = false)
5354

5455
lint:

openfeature/api.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@
1313
from openfeature.provider._registry import provider_registry
1414
from openfeature.provider.metadata import Metadata
1515

16+
__all__ = [
17+
"get_client",
18+
"set_provider",
19+
"clear_providers",
20+
"get_provider_metadata",
21+
"get_evaluation_context",
22+
"set_evaluation_context",
23+
"add_hooks",
24+
"clear_hooks",
25+
"get_hooks",
26+
"shutdown",
27+
"add_handler",
28+
"remove_handler",
29+
]
30+
1631
_evaluation_context = EvaluationContext()
1732

1833
_hooks: typing.List[Hook] = []

openfeature/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
from openfeature.provider import FeatureProvider, ProviderStatus
3131
from openfeature.provider._registry import provider_registry
3232

33+
__all__ = [
34+
"ClientMetadata",
35+
"OpenFeatureClient",
36+
]
37+
3338
logger = logging.getLogger("openfeature")
3439

3540
GetDetailCallable = typing.Union[

openfeature/evaluation_context.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import typing
22
from dataclasses import dataclass, field
33

4+
__all__ = ["EvaluationContext"]
5+
46

57
@dataclass
68
class EvaluationContext:

openfeature/event.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from openfeature.exception import ErrorCode
88
from openfeature.provider import ProviderStatus
99

10+
__all__ = ["ProviderEvent", "ProviderEventDetails", "EventDetails", "EventHandler"]
11+
1012

1113
class ProviderEvent(Enum):
1214
PROVIDER_READY = "PROVIDER_READY"

openfeature/exception.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44
from collections.abc import Mapping
55
from enum import Enum
66

7+
__all__ = [
8+
"OpenFeatureError",
9+
"ProviderNotReadyError",
10+
"ProviderFatalError",
11+
"FlagNotFoundError",
12+
"GeneralError",
13+
"ParseError",
14+
"TypeMismatchError",
15+
"TargetingKeyMissingError",
16+
"InvalidContextError",
17+
"ErrorCode",
18+
]
19+
720

821
class OpenFeatureError(Exception):
922
"""

openfeature/flag_evaluation.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
from openfeature.hook import Hook, HookHints
1212

1313

14+
__all__ = [
15+
"FlagType",
16+
"Reason",
17+
"FlagMetadata",
18+
"FlagEvaluationDetails",
19+
"FlagEvaluationOptions",
20+
"FlagResolutionDetails",
21+
]
22+
23+
1424
class FlagType(StrEnum):
1525
BOOLEAN = "BOOLEAN"
1626
STRING = "STRING"

openfeature/hook/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
from openfeature.client import ClientMetadata
1313
from openfeature.provider.metadata import Metadata
1414

15+
__all__ = ["HookType", "HookContext", "HookHints", "Hook"]
16+
1517

1618
class HookType(Enum):
1719
BEFORE = "before"

openfeature/provider/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
from .metadata import Metadata
99

10+
__all__ = ["ProviderStatus", "FeatureProvider", "Metadata"]
11+
1012

1113
class ProviderStatus(Enum):
1214
NOT_READY = "NOT_READY"

openfeature/provider/provider.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from openfeature.provider import FeatureProvider
99
from openfeature.provider.metadata import Metadata
1010

11+
__all__ = ["AbstractProvider"]
12+
1113

1214
class AbstractProvider(FeatureProvider):
1315
def initialize(self, evaluation_context: EvaluationContext) -> None:

0 commit comments

Comments
 (0)