Skip to content

Commit 63e0064

Browse files
authored
Merge branch 'dev' into gaaguiar/sql_fix
2 parents b080559 + 0f155a9 commit 63e0064

File tree

6 files changed

+46
-66
lines changed

6 files changed

+46
-66
lines changed

azure/functions/_abc.py

-11
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ def message(self) -> str:
4747
pass
4848

4949

50-
class WarmUpContext(abc.ABC):
51-
"""Warmup context object."""
52-
pass
53-
54-
5550
class TraceContext(abc.ABC):
5651
"""Trace context object."""
5752

@@ -131,12 +126,6 @@ def retry_context(self) -> RetryContext:
131126
"""Context for retries to the function."""
132127
pass
133128

134-
@property
135-
@abc.abstractmethod
136-
def warmup_context(self) -> WarmUpContext:
137-
"""Context for warmup to the function."""
138-
pass
139-
140129

141130
class HttpRequest(abc.ABC):
142131
"""HTTP request object."""

azure/functions/_http_asgi.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ async def main(req, context):
164164
"""
165165
warn("handle() is deprecated. Please await .handle_async() instead.",
166166
DeprecationWarning, stacklevel=2)
167-
self._logger.debug(f"Handling {req.url} as an ASGI request.")
167+
self._logger.debug("Handling %s as an ASGI request.", req.url)
168168
self._logger.warning(
169169
"handle() is deprecated. Please `await .handle_async()` instead.")
170170
return self._handle(req, context)
@@ -194,7 +194,7 @@ async def main(req, context):
194194
return await func.AsgiMiddleware(app).handle_async(req,
195195
context)
196196
"""
197-
self._logger.debug(f"Awaiting {req.url} as an ASGI request.")
197+
self._logger.debug("Awaiting %s as an ASGI request.", req.url)
198198
return await self._handle_async(req, context)
199199

200200
async def _handle_async(self, req, context):

azure/functions/decorators/function_app.py

+34-31
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import json
44
import logging
55
from abc import ABC
6-
from typing import Callable, Dict, List, Optional, Union, Iterable
6+
from typing import Any, Callable, Dict, List, Optional, Union, \
7+
Iterable
78

89
from azure.functions.decorators.blob import BlobTrigger, BlobInput, BlobOutput
910
from azure.functions.decorators.core import Binding, Trigger, DataType, \
@@ -35,7 +36,7 @@ class Function(object):
3536
function indexing model. Ref: https://aka.ms/azure-function-ref
3637
"""
3738

38-
def __init__(self, func: Callable, script_file: str):
39+
def __init__(self, func: Callable[..., Any], script_file: str):
3940
"""Constructor of :class:`FunctionBuilder` object.
4041
4142
:param func: User defined python function instance.
@@ -133,7 +134,7 @@ def get_dict_repr(self) -> Dict:
133134
stub_f_json.update(self.get_bindings_dict()) # NoQA
134135
return stub_f_json
135136

136-
def get_user_function(self) -> Callable:
137+
def get_user_function(self) -> Callable[..., Any]:
137138
"""Get the python function customer defined.
138139
139140
:return: The python function customer defined.
@@ -249,7 +250,9 @@ def app_script_file(self) -> str:
249250
"""
250251
return self._app_script_file
251252

252-
def _validate_type(self, func: Union[Callable, FunctionBuilder]) \
253+
def _validate_type(self,
254+
func: Union[Callable[..., Any],
255+
FunctionBuilder]) \
253256
-> FunctionBuilder:
254257
"""Validate the type of the function object and return the created
255258
:class:`FunctionBuilder` object.
@@ -270,7 +273,7 @@ def _validate_type(self, func: Union[Callable, FunctionBuilder]) \
270273
"Unsupported type for function app decorator found.")
271274
return fb
272275

273-
def _configure_function_builder(self, wrap) -> Callable:
276+
def _configure_function_builder(self, wrap) -> Callable[..., Any]:
274277
"""Decorator function on user defined function to create and return
275278
:class:`FunctionBuilder` object from :class:`Callable` func.
276279
"""
@@ -282,7 +285,7 @@ def decorator(func):
282285

283286
return decorator
284287

285-
def function_name(self, name: str) -> Callable:
288+
def function_name(self, name: str) -> Callable[..., Any]:
286289
"""Set name of the :class:`Function` object.
287290
288291
:param name: Name of the function.
@@ -299,8 +302,8 @@ def decorator():
299302

300303
return wrap
301304

302-
def http_type(self, http_type: str) -> Callable:
303-
"""Set http type of the :class:`Function` object.
305+
def http_type(self, http_type: str) -> Callable[..., Any]:
306+
"""Set http type of the :class:`Function` object.
304307
305308
:param http_type: Http type of the function.
306309
:return: Decorator function.
@@ -348,7 +351,7 @@ def route(self,
348351
auth_level: Optional[Union[AuthLevel, str]] = None,
349352
trigger_extra_fields: Dict = {},
350353
binding_extra_fields: Dict = {}
351-
) -> Callable:
354+
) -> Callable[..., Any]:
352355
"""The route decorator adds :class:`HttpTrigger` and
353356
:class:`HttpOutput` binding to the :class:`FunctionBuilder` object
354357
for building :class:`Function` object used in worker function
@@ -402,7 +405,7 @@ def schedule(self,
402405
run_on_startup: Optional[bool] = None,
403406
use_monitor: Optional[bool] = None,
404407
data_type: Optional[Union[DataType, str]] = None,
405-
**kwargs) -> Callable:
408+
**kwargs) -> Callable[..., Any]:
406409
"""The schedule decorator adds :class:`TimerTrigger` to the
407410
:class:`FunctionBuilder` object
408411
for building :class:`Function` object used in worker function
@@ -454,7 +457,7 @@ def service_bus_queue_trigger(
454457
access_rights: Optional[Union[AccessRights, str]] = None,
455458
is_sessions_enabled: Optional[bool] = None,
456459
cardinality: Optional[Union[Cardinality, str]] = None,
457-
**kwargs) -> Callable:
460+
**kwargs) -> Callable[..., Any]:
458461
"""The on_service_bus_queue_change decorator adds
459462
:class:`ServiceBusQueueTrigger` to the :class:`FunctionBuilder` object
460463
for building :class:`Function` object used in worker function
@@ -513,7 +516,7 @@ def service_bus_topic_trigger(
513516
access_rights: Optional[Union[AccessRights, str]] = None,
514517
is_sessions_enabled: Optional[bool] = None,
515518
cardinality: Optional[Union[Cardinality, str]] = None,
516-
**kwargs) -> Callable:
519+
**kwargs) -> Callable[..., Any]:
517520
"""The on_service_bus_topic_change decorator adds
518521
:class:`ServiceBusTopicTrigger` to the :class:`FunctionBuilder` object
519522
for building :class:`Function` object used in worker function
@@ -569,7 +572,7 @@ def queue_trigger(self,
569572
queue_name: str,
570573
connection: str,
571574
data_type: Optional[DataType] = None,
572-
**kwargs) -> Callable:
575+
**kwargs) -> Callable[..., Any]:
573576
"""The queue_trigger decorator adds :class:`QueueTrigger` to the
574577
:class:`FunctionBuilder` object
575578
for building :class:`Function` object used in worker function
@@ -621,7 +624,7 @@ def event_hub_message_trigger(self,
621624
Union[Cardinality, str]] = None,
622625
consumer_group: Optional[
623626
str] = None,
624-
**kwargs) -> Callable:
627+
**kwargs) -> Callable[..., Any]:
625628
"""The event_hub_message_trigger decorator adds
626629
:class:`EventHubTrigger`
627630
to the :class:`FunctionBuilder` object
@@ -695,7 +698,7 @@ def cosmos_db_trigger(self,
695698
data_type: Optional[
696699
Union[DataType, str]] = None,
697700
**kwargs) -> \
698-
Callable:
701+
Callable[..., Any]:
699702
"""The cosmos_db_trigger decorator adds :class:`CosmosDBTrigger`
700703
to the :class:`FunctionBuilder` object
701704
for building :class:`Function` object used in worker function
@@ -799,7 +802,7 @@ def blob_trigger(self,
799802
path: str,
800803
connection: str,
801804
data_type: Optional[DataType] = None,
802-
**kwargs) -> Callable:
805+
**kwargs) -> Callable[..., Any]:
803806
"""
804807
The blob_change_trigger decorator adds :class:`BlobTrigger` to the
805808
:class:`FunctionBuilder` object
@@ -844,7 +847,7 @@ def event_grid_trigger(self,
844847
arg_name: str,
845848
data_type: Optional[
846849
Union[DataType, str]] = None,
847-
**kwargs) -> Callable:
850+
**kwargs) -> Callable[..., Any]:
848851
"""
849852
The event_grid_trigger decorator adds
850853
:class:`EventGridTrigger`
@@ -885,7 +888,7 @@ def generic_trigger(self,
885888
type: str,
886889
data_type: Optional[Union[DataType, str]] = None,
887890
**kwargs
888-
) -> Callable:
891+
) -> Callable[..., Any]:
889892
"""
890893
The generic_trigger decorator adds :class:`GenericTrigger`
891894
to the :class:`FunctionBuilder` object for building :class:`Function`
@@ -937,7 +940,7 @@ def service_bus_queue_output(self,
937940
access_rights: Optional[Union[
938941
AccessRights, str]] = None,
939942
**kwargs) -> \
940-
Callable:
943+
Callable[..., Any]:
941944
"""The service_bus_queue_output decorator adds
942945
:class:`ServiceBusQueueOutput` to the :class:`FunctionBuilder` object
943946
for building :class:`Function` object used in worker function
@@ -989,7 +992,7 @@ def service_bus_topic_output(self,
989992
access_rights: Optional[Union[
990993
AccessRights, str]] = None,
991994
**kwargs) -> \
992-
Callable:
995+
Callable[..., Any]:
993996
"""The service_bus_topic_output decorator adds
994997
:class:`ServiceBusTopicOutput` to the :class:`FunctionBuilder` object
995998
for building :class:`Function` object used in worker function
@@ -1039,7 +1042,7 @@ def queue_output(self,
10391042
queue_name: str,
10401043
connection: str,
10411044
data_type: Optional[DataType] = None,
1042-
**kwargs) -> Callable:
1045+
**kwargs) -> Callable[..., Any]:
10431046
"""The queue_output decorator adds :class:`QueueOutput` to the
10441047
:class:`FunctionBuilder` object
10451048
for building :class:`Function` object used in worker function
@@ -1087,7 +1090,7 @@ def event_hub_output(self,
10871090
data_type: Optional[
10881091
Union[DataType, str]] = None,
10891092
**kwargs) -> \
1090-
Callable:
1093+
Callable[..., Any]:
10911094
"""The event_hub_output decorator adds
10921095
:class:`EventHubOutput` to the :class:`FunctionBuilder` object
10931096
for building :class:`Function` object used in worker function
@@ -1143,7 +1146,7 @@ def cosmos_db_output(self,
11431146
data_type: Optional[
11441147
Union[DataType, str]] = None,
11451148
**kwargs) \
1146-
-> Callable:
1149+
-> Callable[..., Any]:
11471150
"""The cosmos_db_output decorator adds
11481151
:class:`CosmosDBOutput` to the :class:`FunctionBuilder` object
11491152
for building :class:`Function` object used in worker function
@@ -1215,7 +1218,7 @@ def cosmos_db_input(self,
12151218
data_type: Optional[
12161219
Union[DataType, str]] = None,
12171220
**kwargs) \
1218-
-> Callable:
1221+
-> Callable[..., Any]:
12191222
"""The cosmos_db_input decorator adds
12201223
:class:`CosmosDBInput` to the :class:`FunctionBuilder` object
12211224
for building :class:`Function` object used in worker function
@@ -1272,7 +1275,7 @@ def blob_input(self,
12721275
path: str,
12731276
connection: str,
12741277
data_type: Optional[DataType] = None,
1275-
**kwargs) -> Callable:
1278+
**kwargs) -> Callable[..., Any]:
12761279
"""
12771280
The blob_input decorator adds :class:`BlobInput` to the
12781281
:class:`FunctionBuilder` object
@@ -1320,7 +1323,7 @@ def blob_output(self,
13201323
path: str,
13211324
connection: str,
13221325
data_type: Optional[DataType] = None,
1323-
**kwargs) -> Callable:
1326+
**kwargs) -> Callable[..., Any]:
13241327
"""
13251328
The blob_output decorator adds :class:`BlobOutput` to the
13261329
:class:`FunctionBuilder` object
@@ -1368,7 +1371,7 @@ def event_grid_output(self,
13681371
topic_key_setting: str,
13691372
data_type: Optional[
13701373
Union[DataType, str]] = None,
1371-
**kwargs) -> Callable:
1374+
**kwargs) -> Callable[..., Any]:
13721375
"""
13731376
The event_grid_output decorator adds
13741377
:class:`EventGridOutput`
@@ -1419,7 +1422,7 @@ def table_input(self,
14191422
take: Optional[int] = None,
14201423
filter: Optional[str] = None,
14211424
data_type: Optional[
1422-
Union[DataType, str]] = None) -> Callable:
1425+
Union[DataType, str]] = None) -> Callable[..., Any]:
14231426
"""
14241427
The table_input decorator adds :class:`TableInput` to the
14251428
:class:`FunctionBuilder` object
@@ -1474,7 +1477,7 @@ def table_output(self,
14741477
row_key: Optional[str] = None,
14751478
partition_key: Optional[str] = None,
14761479
data_type: Optional[
1477-
Union[DataType, str]] = None) -> Callable:
1480+
Union[DataType, str]] = None) -> Callable[..., Any]:
14781481
"""
14791482
The table_output decorator adds :class:`TableOutput` to the
14801483
:class:`FunctionBuilder` object
@@ -1522,7 +1525,7 @@ def generic_input_binding(self,
15221525
type: str,
15231526
data_type: Optional[Union[DataType, str]] = None,
15241527
**kwargs
1525-
) -> Callable:
1528+
) -> Callable[..., Any]:
15261529
"""
15271530
The generic_input_binding decorator adds :class:`GenericInputBinding`
15281531
to the :class:`FunctionBuilder` object for building :class:`Function`
@@ -1567,7 +1570,7 @@ def generic_output_binding(self,
15671570
data_type: Optional[
15681571
Union[DataType, str]] = None,
15691572
**kwargs
1570-
) -> Callable:
1573+
) -> Callable[..., Any]:
15711574
"""
15721575
The generic_output_binding decorator adds :class:`GenericOutputBinding`
15731576
to the :class:`FunctionBuilder` object for building :class:`Function`

azure/functions/decorators/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from abc import ABCMeta
66
from enum import Enum
77
from json import JSONEncoder
8-
from typing import TypeVar, Optional, Union, Iterable, Type, Callable
8+
from typing import Any, TypeVar, Optional, Union, Iterable, Type, Callable
99

1010
T = TypeVar("T", bound=Enum)
1111
SNAKE_CASE_RE = re.compile(r'^([a-zA-Z]+\d*_|_+[a-zA-Z\d])\w*$')
@@ -45,7 +45,7 @@ def wrapper(*args, **kw):
4545
return wrapper
4646

4747
@staticmethod
48-
def add_to_dict(func: Callable):
48+
def add_to_dict(func: Callable[..., Any]):
4949
def wrapper(*args, **kwargs):
5050
if args is None or len(args) == 0:
5151
raise ValueError(

tests/test_http_asgi.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import unittest
66

77
import azure.functions as func
8-
from azure.functions._abc import TraceContext, RetryContext, WarmUpContext
8+
from azure.functions._abc import TraceContext, RetryContext
99
from azure.functions._http_asgi import (
1010
AsgiMiddleware
1111
)
@@ -114,17 +114,15 @@ def _generate_func_context(
114114
function_name='httptrigger',
115115
function_directory='/home/roger/wwwroot/httptrigger',
116116
trace_context=TraceContext,
117-
retry_context=RetryContext,
118-
warmup_context=WarmUpContext
117+
retry_context=RetryContext
119118
) -> func.Context:
120119
class MockContext(func.Context):
121-
def __init__(self, ii, fn, fd, tc, rc, wc):
120+
def __init__(self, ii, fn, fd, tc, rc):
122121
self._invocation_id = ii
123122
self._function_name = fn
124123
self._function_directory = fd
125124
self._trace_context = tc
126125
self._retry_context = rc
127-
self._warmup_context = wc
128126

129127
@property
130128
def invocation_id(self):
@@ -146,12 +144,8 @@ def trace_context(self):
146144
def retry_context(self):
147145
return self._retry_context
148146

149-
@property
150-
def warmup_context(self):
151-
return self._warmup_context
152-
153147
return MockContext(invocation_id, function_name, function_directory,
154-
trace_context, retry_context, warmup_context)
148+
trace_context, retry_context)
155149

156150
def test_middleware_calls_app(self):
157151
app = MockAsgiApplication()

0 commit comments

Comments
 (0)