Skip to content

Commit acf64d4

Browse files
swathipill0lawrence
authored andcommitted
[EventHub] l0lawrence's fix import (Azure#34269)
* fixes * drop 3.7 * had to switch * fix typing for exception --------- Co-authored-by: Libba Lawrence <[email protected]>
1 parent 579b6f6 commit acf64d4

File tree

5 files changed

+26
-39
lines changed

5 files changed

+26
-39
lines changed

sdk/eventhub/azure-eventhub/CHANGELOG.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
# Release History
22

3-
## 5.11.6 (Unreleased)
3+
## 5.11.6 (2024-02-12)
44

55
### Features Added
6-
7-
### Breaking Changes
8-
9-
### Bugs Fixed
10-
11-
### Other Changes
6+
- Added `keep_alive` functionality on EventHubProducerClient to allow for long-living producers. [#33726](https://github.com/Azure/azure-sdk-for-python/issues/33726)
127

138
## 5.11.5 (2023-11-13)
149

sdk/eventhub/azure-eventhub/azure/eventhub/_transport/_pyamqp_transport.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,8 @@ def _handle_exception(
676676
# raise error
677677
elif isinstance(exception, errors.MessageException):
678678
_LOGGER.info("%r Event data send error (%r)", name, exception)
679-
error = EventDataSendError(str(exception), exception)
679+
# TODO: issue #34266
680+
error = EventDataSendError(str(exception), exception) # type: ignore[arg-type]
680681
raise error
681682
else:
682683
if isinstance(exception, errors.AuthenticationException):

sdk/eventhub/azure-eventhub/azure/eventhub/aio/_transport/_pyamqp_transport_async.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ async def _handle_exception_async( # pylint:disable=too-many-branches, too-many
376376
# raise error
377377
elif isinstance(exception, errors.MessageException):
378378
_LOGGER.info("%r Event data send error (%r)", name, exception)
379-
error = EventDataSendError(str(exception), exception)
379+
# TODO: issue #34266
380+
error = EventDataSendError(str(exception), exception) # type: ignore[arg-type]
380381
raise error
381382
else:
382383
try:

sdk/eventhub/azure-eventhub/azure/eventhub/exceptions.py

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
# Copyright (c) Microsoft Corporation. All rights reserved.
33
# Licensed under the MIT License. See License.txt in the project root for license information.
44
# --------------------------------------------------------------------------------------------
5-
from typing import Union, List, Optional, cast, TYPE_CHECKING
6-
from ._pyamqp.error import AMQPException
7-
8-
if TYPE_CHECKING:
9-
from ._pyamqp.error import ErrorCondition
5+
from typing import Union, List, Optional
106

117

128
class EventHubError(Exception):
@@ -18,36 +14,31 @@ class EventHubError(Exception):
1814
:vartype error: str
1915
:ivar details: The error details, if included in the
2016
service response.
21-
:vartype details: list[str] or AMQPException
17+
:vartype details: list[str]
2218
"""
2319

24-
def __init__(self, message: str, details: Optional[Union[List[str], "AMQPException"]] = None) -> None:
20+
def __init__(self, message: str, details: Optional[List[str]] = None) -> None:
2521
self.error: Optional[str] = None
2622
self.message: str = message
27-
self.details: Union[List[str], "AMQPException"]
23+
self.details: Union[List[str]]
2824
if details and isinstance(details, Exception):
29-
self.details = details
30-
if isinstance(self.details, AMQPException):
25+
# TODO: issue #34266
26+
try:
27+
condition = details.condition.value.decode("UTF-8") # type: ignore[attr-defined]
28+
except AttributeError:
3129
try:
32-
details.condition = cast("ErrorCondition", details.condition)
33-
condition = details.condition.value.decode("UTF-8")
30+
condition = details.condition.decode("UTF-8") # type: ignore[attr-defined]
3431
except AttributeError:
35-
try:
36-
details.condition = cast(bytes, details.condition)
37-
condition = details.condition.decode("UTF-8")
38-
except AttributeError:
39-
condition = None
40-
if condition:
41-
_, _, self.error = condition.partition(":")
42-
self.message += "\nError: {}".format(self.error)
43-
elif isinstance(self.details, list):
44-
try:
45-
details.description = cast(str, details.description)
46-
self._parse_error(details.description)
47-
for detail in self.details:
48-
self.message += "\n{}".format(detail)
49-
except: # pylint: disable=bare-except
50-
self.message += "\n{}".format(details)
32+
condition = None
33+
if condition:
34+
_, _, self.error = condition.partition(":")
35+
self.message += "\nError: {}".format(self.error)
36+
try:
37+
self._parse_error(details.description) # type: ignore[attr-defined]
38+
for detail in self.details:
39+
self.message += "\n{}".format(detail)
40+
except: # pylint: disable=bare-except
41+
self.message += "\n{}".format(details)
5142
super(EventHubError, self).__init__(self.message)
5243

5344
def _parse_error(self, error_list: Union[str, bytes]) -> None:

sdk/eventhub/azure-eventhub/setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,13 @@
5959
"Development Status :: 5 - Production/Stable",
6060
'Programming Language :: Python',
6161
'Programming Language :: Python :: 3 :: Only',
62-
'Programming Language :: Python :: 3.7',
6362
'Programming Language :: Python :: 3.8',
6463
'Programming Language :: Python :: 3.9',
6564
'Programming Language :: Python :: 3.10',
6665
'Programming Language :: Python :: 3.11',
6766
'License :: OSI Approved :: MIT License',
6867
],
69-
python_requires=">=3.7",
68+
python_requires=">=3.8",
7069
zip_safe=False,
7170
packages=find_packages(exclude=exclude_packages),
7271
install_requires=[

0 commit comments

Comments
 (0)