Skip to content

Commit 8942418

Browse files
committed
fix merge conflicts
Signed-off-by: gruebel <[email protected]>
1 parent c21eae4 commit 8942418

File tree

5 files changed

+32
-25
lines changed

5 files changed

+32
-25
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ jobs:
4646
working-directory: ${{ matrix.package }}
4747

4848
- name: Type checking
49-
if: matrix.package == 'providers/openfeature-provider-flagd'
49+
# TODO: migrate other packages to use their own 'mypy' setup
50+
if: matrix.python-version == '3.11' && matrix.package == 'providers/openfeature-provider-flagd'
5051
working-directory: ${{ matrix.package }}
51-
run: hatch run mypy
52+
run: hatch run mypy:run
5253

5354
- name: Test with pytest
5455
run: hatch test -c

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ We use `pytest` for our unit testing, making use of `parametrized` to inject cas
3232

3333
These are planned once the SDK has been stabilized and a Flagd provider implemented. At that point, we will utilize the [gherkin integration tests](https://github.com/open-feature/test-harness/blob/main/features/evaluation.feature) to validate against a live, seeded Flagd instance.
3434

35+
### Type checking
36+
37+
Run `mypy` by entering the package directory and running `hatch run mypy:run`.
38+
3539
## Pull Request
3640

3741
All contributions to the OpenFeature project are welcome via GitHub pull requests.

providers/openfeature-provider-flagd/pyproject.toml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ dependencies = [
4040
"testcontainers",
4141
"asserts",
4242
"grpcio-health-checking==1.60.0",
43-
"mypy[faster-cache]>=1.13.0",
44-
"types-protobuf",
45-
"types-pyyaml",
4643
]
4744
pre-install-commands = [
4845
"hatch build",
@@ -62,6 +59,19 @@ cov = [
6259
"cov-report",
6360
]
6461

62+
[tool.hatch.envs.mypy]
63+
dependencies = [
64+
"mypy[faster-cache]>=1.13.0",
65+
"types-protobuf",
66+
"types-pyyaml",
67+
]
68+
pre-install-commands = [
69+
"hatch build",
70+
]
71+
72+
[tool.hatch.envs.mypy.scripts]
73+
run = "mypy"
74+
6575
[tool.hatch.build.hooks.protobuf]
6676
generate_pyi = false
6777
dependencies = [
@@ -93,17 +103,15 @@ packages = ["src/openfeature"]
93103
[tool.coverage.run]
94104
omit = [
95105
# exclude generated files
96-
"src/openfeature/contrib/provider/flagd/proto/*",
106+
"src/openfeature/schemas/*",
97107
"tests/**",
98108
]
99109

100110
[tool.mypy]
101111
mypy_path = "src"
102112
files = "src"
103-
exclude = [
104-
"src/openfeature/contrib/provider/flagd/protobuf"
105-
]
106113

114+
python_version = "3.8" # should be identical to the minimum supported version
107115
namespace_packages = true
108116
explicit_package_bases = true
109117
local_partial_types = true
@@ -114,12 +122,13 @@ disallow_any_generics = false
114122

115123
[[tool.mypy.overrides]]
116124
module = [
117-
"grpc"
125+
"grpc.*",
126+
"json_logic.*",
118127
]
119128
ignore_missing_imports = true
120129

121130
[[tool.mypy.overrides]]
122131
module = [
123-
"openfeature.contrib.provider.flagd.protobuf.*"
132+
"openfeature.schemas.*"
124133
]
125-
follow_imports = "silent"
134+
warn_unused_ignores = false

providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/resolvers/grpc.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313
TypeMismatchError,
1414
)
1515
from openfeature.flag_evaluation import FlagResolutionDetails
16-
from openfeature.schemas.protobuf.flagd.evaluation.v1 import ( # type:ignore[import-not-found]
16+
from openfeature.schemas.protobuf.flagd.evaluation.v1 import (
1717
evaluation_pb2,
1818
evaluation_pb2_grpc,
1919
)
2020

2121
from ..config import Config
2222
from ..flag_type import FlagType
23-
from ..protobuf.flagd.evaluation.v1 import evaluation_pb2, evaluation_pb2_grpc
2423

2524
if typing.TYPE_CHECKING:
2625
from google.protobuf.message import Message
@@ -35,7 +34,7 @@ def __init__(self, config: Config):
3534
grpc.secure_channel if self.config.tls else grpc.insecure_channel
3635
)
3736
self.channel = channel_factory(f"{self.config.host}:{self.config.port}")
38-
self.stub = evaluation_pb2_grpc.ServiceStub(self.channel) # type: ignore[no-untyped-call]
37+
self.stub = evaluation_pb2_grpc.ServiceStub(self.channel)
3938

4039
def shutdown(self) -> None:
4140
self.channel.close()
@@ -90,15 +89,9 @@ def _resolve( # noqa: PLR0915
9089
context = self._convert_context(evaluation_context)
9190
call_args = {"timeout": self.config.timeout}
9291
try:
93-
request: typing.Union[
94-
evaluation_pb2.ResolveBooleanRequest,
95-
evaluation_pb2.ResolveIntRequest,
96-
evaluation_pb2.ResolveStringRequest,
97-
evaluation_pb2.ResolveObjectRequest,
98-
evaluation_pb2.ResolveFloatRequest,
99-
]
92+
request: Message
10093
if flag_type == FlagType.BOOLEAN:
101-
request: Message = evaluation_pb2.ResolveBooleanRequest(
94+
request = evaluation_pb2.ResolveBooleanRequest(
10295
flag_key=flag_key, context=context
10396
)
10497
response = self.stub.ResolveBoolean(request, **call_args)

providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/resolvers/process/targeting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import time
22
import typing
33

4-
from json_logic import builtins, jsonLogic # type: ignore[import-untyped]
5-
from json_logic.types import JsonValue # type: ignore[import-untyped]
4+
from json_logic import builtins, jsonLogic
5+
from json_logic.types import JsonValue
66

77
from openfeature.evaluation_context import EvaluationContext
88

0 commit comments

Comments
 (0)