From f5e89c08e01eca8f298e138b773e51562768dffa Mon Sep 17 00:00:00 2001 From: Cole Bailey Date: Thu, 20 Jun 2024 21:06:38 +0200 Subject: [PATCH] fix: remove hasattr usage Signed-off-by: Cole Bailey --- .../src/openfeature/contrib/provider/flagd/provider.py | 3 +-- .../openfeature/contrib/provider/flagd/resolvers/__init__.py | 3 +++ .../src/openfeature/contrib/provider/flagd/resolvers/grpc.py | 3 ++- providers/openfeature-provider-flagd/test-harness | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/provider.py b/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/provider.py index 2ba4945a..15c86f67 100644 --- a/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/provider.py +++ b/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/provider.py @@ -82,8 +82,7 @@ def setup_resolver(self) -> AbstractResolver: ) def initialize(self, evaluation_context: EvaluationContext) -> None: - if hasattr(self.resolver, "initialize"): - self.resolver.initialize(evaluation_context) + self.resolver.initialize(evaluation_context) def shutdown(self) -> None: if self.resolver: diff --git a/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/resolvers/__init__.py b/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/resolvers/__init__.py index 53e17938..1b77c0c8 100644 --- a/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/resolvers/__init__.py +++ b/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/resolvers/__init__.py @@ -10,6 +10,9 @@ class AbstractResolver(Protocol): + def initialize(self, evaluation_context: EvaluationContext) -> None: + return + def shutdown(self) -> None: ... def resolve_boolean_details( diff --git a/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/resolvers/grpc.py b/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/resolvers/grpc.py index caab101a..c2f98522 100644 --- a/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/resolvers/grpc.py +++ b/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/resolvers/grpc.py @@ -16,11 +16,12 @@ from ..config import Config from ..flag_type import FlagType from ..proto.schema.v1 import schema_pb2, schema_pb2_grpc +from . import AbstractResolver T = typing.TypeVar("T") -class GrpcResolver: +class GrpcResolver(AbstractResolver): def __init__(self, config: Config): self.config = config channel_factory = ( diff --git a/providers/openfeature-provider-flagd/test-harness b/providers/openfeature-provider-flagd/test-harness index 6197b3d9..c9e0be36 160000 --- a/providers/openfeature-provider-flagd/test-harness +++ b/providers/openfeature-provider-flagd/test-harness @@ -1 +1 @@ -Subproject commit 6197b3d956d358bf662e5b8e0aebdc4800480f6b +Subproject commit c9e0be36e89ad33aa99b8e32b40d67e9bf350f88