File tree Expand file tree Collapse file tree 7 files changed +60
-25
lines changed
hooks/openfeature-hooks-opentelemetry
providers/openfeature-provider-flagd
openfeature/contrib/provider/flagd/resolvers Expand file tree Collapse file tree 7 files changed +60
-25
lines changed Original file line number Diff line number Diff line change @@ -38,16 +38,15 @@ jobs:
3838 python-version : ${{ matrix.python-version }}
3939 cache : " pip"
4040
41- - uses : bufbuild/buf-action@v1
42- with :
43- github_token : ${{ github.token }}
44- setup_only : true
45-
4641 - name : Install hatch
4742 run : pip install hatch
4843
44+ - name : Building first to generate files
45+ run : hatch build
46+ working-directory : ${{ matrix.package }}
47+
4948 - name : Test with pytest
50- run : hatch run cov
49+ run : hatch test -c
5150 working-directory : ${{ matrix.package }}
5251
5352 - if : matrix.python-version == '3.11'
Original file line number Diff line number Diff line change @@ -18,9 +18,13 @@ To install Hatch, just run `pip install hatch`.
1818
1919You will also need to setup the ` pre-commit ` hooks. Run ` pre-commit install ` in the root directory of the repository. If you don't have ` pre-commit ` installed, you can install it with ` pip install pre-commit ` .
2020
21+ > ** Note**
22+ > Currently our protobuf files will be generated during ` hatch build `
23+ > Please run this command once, to generate all necessary files.
24+
2125### Testing
2226
23- Run tests by entering the package directory and running ` hatch run test ` .
27+ Run tests by entering the package directory and running ` hatch test ` .
2428
2529We use ` pytest ` for our unit testing, making use of ` parametrized ` to inject cases at scale.
2630
Original file line number Diff line number Diff line change @@ -27,17 +27,23 @@ Homepage = "https://github.com/open-feature/python-sdk-contrib"
2727
2828[tool .hatch ]
2929
30- [tool .hatch .envs .default ]
30+ [tool .hatch .envs .hatch-test ]
3131dependencies = [
3232 " coverage[toml]>=6.5" ,
3333 " pytest" ,
3434]
35+ pre-install-commands = [
36+ " hatch build" ,
37+ ]
3538
36- [tool .hatch .envs .default .scripts ]
37- test = " pytest {args:tests}"
38- test-cov = " coverage run -m pytest {args:tests}"
39+ [tool .hatch .envs .hatch-test .scripts ]
40+ run = " pytest {args:tests}"
41+ run-cov = " coverage run -m pytest {args:tests}"
42+ cov-combine = " coverage combine"
3943cov-report = [
4044 " coverage xml" ,
45+ " coverage html" ,
46+ " coverage report" ,
4147]
4248cov = [
4349 " test-cov" ,
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ Homepage = "https://github.com/open-feature/python-sdk-contrib"
3232
3333[tool .hatch ]
3434
35- [tool .hatch .envs .default ]
35+ [tool .hatch .envs .hatch-test ]
3636dependencies = [
3737 " coverage[toml]>=6.5" ,
3838 " pytest" ,
@@ -41,28 +41,49 @@ dependencies = [
4141 " asserts" ,
4242 " grpcio-health-checking==1.60.0" ,
4343]
44+ pre-install-commands = [
45+ " hatch build" ,
46+ ]
4447
45- [tool .hatch .envs .default .scripts ]
46- test = " pytest {args:tests}"
47- test-cov = " coverage run -m pytest {args:tests}"
48+ [tool .hatch .envs .hatch-test .scripts ]
49+ run = " pytest {args:tests}"
50+ run-cov = " coverage run -m pytest {args:tests}"
51+ cov-combine = " coverage combine"
4852cov-report = [
4953 " coverage xml" ,
5054 " coverage html" ,
55+ " coverage report" ,
5156]
5257cov = [
5358 " test-cov" ,
5459 " cov-report" ,
5560]
5661
5762[tool .hatch .build .hooks .protobuf ]
58- dependencies = [" hatch-protobuf" ]
59- paths = [" schemas/protobuf/schema/v1/schema.proto" , " schemas/protobuf/sync/v1/sync_service.proto" ]
60- output_path = " src"
63+ generate_pyi = false
64+ dependencies = [
65+ " hatch-protobuf" ,
66+ " mypy-protobuf~=3.0" ,
67+ ]
68+ proto_paths = [
69+ " schemas/protobuf/" ,
70+ ]
71+ output_path = " src/"
72+
73+ [[tool .hatch .build .hooks .protobuf .generators ]]
74+ name = " mypy"
75+ outputs = [" {proto_path}/{proto_name}_pb2.pyi" ]
76+
77+ [[tool .hatch .build .hooks .protobuf .generators ]]
78+ name = " mypy_grpc"
79+ outputs = [" {proto_path}/{proto_name}_pb2_grpc.pyi" ]
6180
6281[tool .hatch .build .targets .sdist ]
6382exclude = [
6483 " .gitignore" ,
6584 " schemas" ,
85+ " src/schema" ,
86+ " src/sync" ,
6687]
6788
6889[tool .hatch .build .targets .wheel ]
Original file line number Diff line number Diff line change 1+ flagd
2+ schema
3+ sync
Original file line number Diff line number Diff line change 33import grpc
44from google .protobuf .json_format import MessageToDict
55from google .protobuf .struct_pb2 import Struct
6- from schemas .protobuf .flagd .evaluation .v1 import ( # type:ignore[import-not-found]
6+
7+ from flagd .evaluation .v1 import ( # type:ignore[import-not-found]
78 evaluation_pb2 ,
89 evaluation_pb2_grpc ,
910)
10-
1111from openfeature .evaluation_context import EvaluationContext
1212from openfeature .exception import (
1313 FlagNotFoundError ,
@@ -86,6 +86,13 @@ def _resolve( # noqa: PLR0915
8686 context = self ._convert_context (evaluation_context )
8787 call_args = {"timeout" : self .config .timeout }
8888 try :
89+ request : typing .Union [
90+ evaluation_pb2 .ResolveBooleanRequest ,
91+ evaluation_pb2 .ResolveIntRequest ,
92+ evaluation_pb2 .ResolveStringRequest ,
93+ evaluation_pb2 .ResolveObjectRequest ,
94+ evaluation_pb2 .ResolveFloatRequest ,
95+ ]
8996 if flag_type == FlagType .BOOLEAN :
9097 request = evaluation_pb2 .ResolveBooleanRequest (
9198 flag_key = flag_key , context = context
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments