Skip to content

Commit 3fd84f5

Browse files
committed
revert return none supp
1 parent 66da8e2 commit 3fd84f5

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

azure_functions_worker/bindings/datumdef.py

-2
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,6 @@ def datum_as_proto(datum: Datum) -> protos.TypedData:
197197
enable_content_negotiation=False,
198198
body=datum_as_proto(datum.value['body']),
199199
))
200-
elif datum.type is None:
201-
return None
202200
else:
203201
raise NotImplementedError(
204202
'unexpected Datum type: {!r}'.format(datum.type)

azure_functions_worker/bindings/generic.py

-4
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ def encode(cls, obj: Any, *,
2828

2929
elif isinstance(obj, (bytes, bytearray)):
3030
return datumdef.Datum(type='bytes', value=bytes(obj))
31-
elif obj is None:
32-
return datumdef.Datum(type=None, value=obj)
3331
else:
3432
raise NotImplementedError
3533

@@ -47,8 +45,6 @@ def decode(cls, data: datumdef.Datum, *, trigger_metadata) -> typing.Any:
4745
result = data.value
4846
elif data_type == 'json':
4947
result = data.value
50-
elif data_type is None:
51-
result = None
5248
else:
5349
raise ValueError(
5450
f'unexpected type of data received for the "generic" binding '

azure_functions_worker/bindings/meta.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ def to_outgoing_param_binding(binding: str, obj: typing.Any, *,
178178
rpc_shared_memory=shared_mem_value)
179179
else:
180180
# If not, send it as part of the response message over RPC
181-
# rpc_val can be None here as we now support a None return type
182181
rpc_val = datumdef.datum_as_proto(datum)
182+
if rpc_val is None:
183+
raise TypeError('Cannot convert datum to rpc_val')
183184
return protos.ParameterBinding(
184185
name=out_name,
185186
data=rpc_val)

tests/unittests/generic_functions/foobar_nil_data/main.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
import logging
44

55

6-
def main(input) -> None:
6+
def main(input):
77
logging.info("Hello World")
8+
# The function must return a non-None value
9+
return "This is fine"

tests/unittests/test_mock_generic_functions.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ async def test_mock_generic_should_support_implicit_output(self):
144144
# implicitly
145145
self.assertEqual(r.response.result.status,
146146
protos.StatusResult.Success)
147+
self.assertEqual(
148+
r.response.return_value,
149+
protos.TypedData(bytes=b'\x00\x01'))
147150

148151
async def test_mock_generic_should_support_without_datatype(self):
149152
async with testutils.start_mockhost(
@@ -219,4 +222,4 @@ async def test_mock_generic_as_nil_data(self):
219222
protos.StatusResult.Success)
220223
self.assertEqual(
221224
r.response.return_value,
222-
protos.TypedData())
225+
protos.TypedData(string="This is fine"))

0 commit comments

Comments
 (0)