Skip to content

Commit 5a4a3d4

Browse files
committed
fix mypy
1 parent 0d21579 commit 5a4a3d4

File tree

6 files changed

+15
-11
lines changed

6 files changed

+15
-11
lines changed

azure/functions/_eventhub.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class EventHubEvent(func_abc.EventHubEvent):
1313

1414
def __init__(self, *,
1515
body: bytes,
16-
trigger_metadata: typing.Mapping[str, meta.Datum] = None,
16+
trigger_metadata: typing.Optional[
17+
typing.Mapping[str, meta.Datum]] = None,
1718
enqueued_time: typing.Optional[datetime.datetime] = None,
1819
partition_key: typing.Optional[str] = None,
1920
sequence_number: typing.Optional[int] = None,

azure/functions/_http.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ class HttpResponse(_abc.HttpResponse):
6666
"""
6767

6868
def __init__(self,
69-
body: typing.Union[str, bytes] = None, *,
70-
status_code: int = None,
69+
body: typing.Optional[typing.Union[str, bytes]] = None, *,
70+
status_code: typing.Optional[int] = None,
7171
headers: typing.Optional[typing.Mapping[str, str]] = None,
7272
mimetype: typing.Optional[str] = None,
73-
charset: str = None) -> None:
73+
charset: typing.Optional[str] = None) -> None:
7474
if status_code is None:
7575
status_code = 200
7676
self.__status_code = status_code

azure/functions/_http_wsgi.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,14 @@ def from_app(cls, app, environ) -> 'WsgiResponse':
132132

133133
def to_func_response(self) -> HttpResponse:
134134
lowercased_headers = {k.lower(): v for k, v in self._headers.items()}
135+
mimetype = str(lowercased_headers.get('content-type', ''))
136+
charset = str(lowercased_headers.get('content-encoding', ''))
135137
return HttpResponse(
136138
body=b''.join(self._buffer),
137139
status_code=self._status_code,
138140
headers=self._headers,
139-
mimetype=lowercased_headers.get('content-type'),
140-
charset=lowercased_headers.get('content-encoding')
141+
mimetype=mimetype,
142+
charset=charset
141143
)
142144

143145
# PEP 3333 start response implementation

azure/functions/decorators/generic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class GenericInputBinding(InputBinding):
1010

11-
@staticmethod
11+
@staticmethod # type: ignore
1212
def get_binding_name() -> str:
1313
pass
1414

@@ -22,7 +22,7 @@ def __init__(self,
2222

2323
class GenericOutputBinding(OutputBinding):
2424

25-
@staticmethod
25+
@staticmethod # type: ignore
2626
def get_binding_name() -> str:
2727
pass
2828

@@ -36,7 +36,7 @@ def __init__(self,
3636

3737
class GenericTrigger(Trigger):
3838

39-
@staticmethod
39+
@staticmethod # type: ignore
4040
def get_binding_name() -> str:
4141
pass
4242

azure/functions/kafka.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class KafkaEvent(AbstractKafkaEvent):
1616

1717
def __init__(self, *,
1818
body: bytes,
19-
trigger_metadata: typing.Mapping[str, meta.Datum] = None,
19+
trigger_metadata: typing.Optional[
20+
typing.Mapping[str, meta.Datum]] = None,
2021
key: typing.Optional[str] = None,
2122
offset: typing.Optional[int] = None,
2223
partition: typing.Optional[int] = None,

azure/functions/servicebus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ServiceBusMessage(azf_sbus.ServiceBusMessage):
1616
def __init__(
1717
self, *,
1818
body: bytes,
19-
trigger_metadata: Mapping[str, Any] = None,
19+
trigger_metadata: Optional[Mapping[str, Any]] = None,
2020
content_type: Optional[str] = None,
2121
correlation_id: Optional[str] = None,
2222
dead_letter_source: Optional[str] = None,

0 commit comments

Comments
 (0)