Skip to content

Commit 8623ee9

Browse files
authored
Merge branch 'dev' into wangbill/fstring
2 parents d8714e5 + 29af5ef commit 8623ee9

File tree

5 files changed

+43
-45
lines changed

5 files changed

+43
-45
lines changed

azure/functions/_abc.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -422,32 +422,3 @@ class OrchestrationContext(abc.ABC):
422422
@abc.abstractmethod
423423
def body(self) -> str:
424424
pass
425-
426-
427-
class SqlRow(abc.ABC):
428-
429-
@classmethod
430-
@abc.abstractmethod
431-
def from_json(cls, json_data: str) -> 'SqlRow':
432-
pass
433-
434-
@classmethod
435-
@abc.abstractmethod
436-
def from_dict(cls, dct: dict) -> 'SqlRow':
437-
pass
438-
439-
@abc.abstractmethod
440-
def __getitem__(self, key):
441-
pass
442-
443-
@abc.abstractmethod
444-
def __setitem__(self, key, value):
445-
pass
446-
447-
@abc.abstractmethod
448-
def to_json(self) -> str:
449-
pass
450-
451-
452-
class SqlRowList(abc.ABC):
453-
pass

azure/functions/_sql.py

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,52 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
3-
3+
import abc
44
import collections
55
import json
66

7-
from . import _abc
7+
8+
class BaseSqlRow(abc.ABC):
9+
10+
@classmethod
11+
@abc.abstractmethod
12+
def from_json(cls, json_data: str) -> 'BaseSqlRow':
13+
raise NotImplementedError
14+
15+
@classmethod
16+
@abc.abstractmethod
17+
def from_dict(cls, dct: dict) -> 'BaseSqlRow':
18+
raise NotImplementedError
19+
20+
@abc.abstractmethod
21+
def __getitem__(self, key):
22+
raise NotImplementedError
23+
24+
@abc.abstractmethod
25+
def __setitem__(self, key, value):
26+
raise NotImplementedError
27+
28+
@abc.abstractmethod
29+
def to_json(self) -> str:
30+
raise NotImplementedError
31+
32+
33+
class BaseSqlRowList(abc.ABC):
34+
pass
835

936

10-
class SqlRow(_abc.SqlRow, collections.UserDict):
37+
class SqlRow(BaseSqlRow, collections.UserDict):
1138
"""A SQL Row.
1239
1340
SqlRow objects are ''UserDict'' subclasses and behave like dicts.
1441
"""
1542

1643
@classmethod
17-
def from_json(cls, json_data: str) -> 'SqlRow':
44+
def from_json(cls, json_data: str) -> 'BaseSqlRow':
1845
"""Create a SqlRow from a JSON string."""
1946
return cls.from_dict(json.loads(json_data))
2047

2148
@classmethod
22-
def from_dict(cls, dct: dict) -> 'SqlRow':
49+
def from_dict(cls, dct: dict) -> 'BaseSqlRow':
2350
"""Create a SqlRow from a dict object"""
2451
return cls({k: v for k, v in dct.items()})
2552

@@ -39,6 +66,6 @@ def __repr__(self) -> str:
3966
)
4067

4168

42-
class SqlRowList(_abc.SqlRowList, collections.UserList):
69+
class SqlRowList(BaseSqlRowList, collections.UserList):
4370
"A ''UserList'' subclass containing a list of :class:'~SqlRow' objects"
4471
pass

azure/functions/decorators/function_app.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ def route(self,
349349
methods: Optional[
350350
Union[Iterable[str], Iterable[HttpMethod]]] = None,
351351
auth_level: Optional[Union[AuthLevel, str]] = None,
352-
trigger_extra_fields: Dict = {},
353-
binding_extra_fields: Dict = {}
352+
trigger_extra_fields: Dict[str, Any] = {},
353+
binding_extra_fields: Dict[str, Any] = {}
354354
) -> Callable[..., Any]:
355355
"""The route decorator adds :class:`HttpTrigger` and
356356
:class:`HttpOutput` binding to the :class:`FunctionBuilder` object
@@ -405,7 +405,7 @@ def schedule(self,
405405
run_on_startup: Optional[bool] = None,
406406
use_monitor: Optional[bool] = None,
407407
data_type: Optional[Union[DataType, str]] = None,
408-
**kwargs) -> Callable[..., Any]:
408+
**kwargs: Any) -> Callable[..., Any]:
409409
"""The schedule decorator adds :class:`TimerTrigger` to the
410410
:class:`FunctionBuilder` object
411411
for building :class:`Function` object used in worker function
@@ -457,7 +457,7 @@ def service_bus_queue_trigger(
457457
access_rights: Optional[Union[AccessRights, str]] = None,
458458
is_sessions_enabled: Optional[bool] = None,
459459
cardinality: Optional[Union[Cardinality, str]] = None,
460-
**kwargs) -> Callable[..., Any]:
460+
**kwargs: Any) -> Callable[..., Any]:
461461
"""The on_service_bus_queue_change decorator adds
462462
:class:`ServiceBusQueueTrigger` to the :class:`FunctionBuilder` object
463463
for building :class:`Function` object used in worker function
@@ -516,7 +516,7 @@ def service_bus_topic_trigger(
516516
access_rights: Optional[Union[AccessRights, str]] = None,
517517
is_sessions_enabled: Optional[bool] = None,
518518
cardinality: Optional[Union[Cardinality, str]] = None,
519-
**kwargs) -> Callable[..., Any]:
519+
**kwargs: Any) -> Callable[..., Any]:
520520
"""The on_service_bus_topic_change decorator adds
521521
:class:`ServiceBusTopicTrigger` to the :class:`FunctionBuilder` object
522522
for building :class:`Function` object used in worker function
@@ -624,7 +624,7 @@ def event_hub_message_trigger(self,
624624
Union[Cardinality, str]] = None,
625625
consumer_group: Optional[
626626
str] = None,
627-
**kwargs) -> Callable[..., Any]:
627+
**kwargs: Any) -> Callable[..., Any]:
628628
"""The event_hub_message_trigger decorator adds
629629
:class:`EventHubTrigger`
630630
to the :class:`FunctionBuilder` object
@@ -697,7 +697,7 @@ def cosmos_db_trigger(self,
697697
preferred_locations: Optional[str] = None,
698698
data_type: Optional[
699699
Union[DataType, str]] = None,
700-
**kwargs) -> \
700+
**kwargs: Any) -> \
701701
Callable[..., Any]:
702702
"""The cosmos_db_trigger decorator adds :class:`CosmosDBTrigger`
703703
to the :class:`FunctionBuilder` object

azure/functions/sql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ class SqlConverter(meta.InConverter, meta.OutConverter,
1515

1616
@classmethod
1717
def check_input_type_annotation(cls, pytype: type) -> bool:
18-
return issubclass(pytype, sql.SqlRowList)
18+
return issubclass(pytype, sql.BaseSqlRowList)
1919

2020
@classmethod
2121
def check_output_type_annotation(cls, pytype: type) -> bool:
22-
return issubclass(pytype, (sql.SqlRowList, sql.SqlRow))
22+
return issubclass(pytype, (sql.BaseSqlRowList, sql.BaseSqlRow))
2323

2424
@classmethod
2525
def decode(cls,

tests/test_sql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4+
import json
45
import unittest
56

67
import azure.functions as func
78
import azure.functions.sql as sql
89
from azure.functions.meta import Datum
9-
import json
1010

1111

1212
class TestSql(unittest.TestCase):

0 commit comments

Comments
 (0)