Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EG] update pyproject and samples #35857

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions scripts/devops_tasks/test_run_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,6 @@
"consume_eventgrid_events_from_service_bus_queue.py",
"sample_publish_events_to_a_topic_using_sas_credential.py",
"sample_publish_events_to_a_topic_using_sas_credential_async.py",
'sample_publish_operation.py',
'sample_receive_operation.py',
'sample_reject_operation.py',
'sample_eg_client_authentication.py',
'sample_all_operations.py',
'sample_release_operation.py',
'sample_acknowledge_operation.py',
'sample_publish_operation_async.py',
'sample_release_operation_async.py',
'sample_reject_operation_async.py',
'sample_acknowledge_operation_async.py',
'sample_receive_operation_async.py',
'sample_all_operations_async.py'
],
"azure-eventhub": [
"client_identity_authentication.py", # TODO: remove after fixing issue #29177
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
Optional,
TypeVar,
Union,
overload,
TYPE_CHECKING,
)

Expand All @@ -28,7 +27,6 @@
from azure.core.tracing.decorator import distributed_trace
from azure.core.pipeline import PipelineResponse
from azure.core.rest import HttpRequest, HttpResponse
from azure.core.utils import case_insensitive_dict

from ._operations import (
EventGridPublisherClientOperationsMixin as PublisherOperationsMixin,
Expand Down Expand Up @@ -105,8 +103,6 @@ def send(
) -> None: # pylint: disable=docstring-should-be-keyword, docstring-missing-param
"""Send events to the Event Grid Service.

:param topic_name: The name of the topic to send the event to.
:type topic_name: str
:param events: The event to send.
:type events: CloudEvent or List[CloudEvent] or Dict[str, Any] or List[Dict[str, Any]]
or CNCFCloudEvent or List[CNCFCloudEvent] or EventGridEvent or List[EventGridEvent]
Expand Down Expand Up @@ -143,24 +139,24 @@ def send(
# Try to send via namespace
self._publish(self._namespace, _serialize_events(events), **kwargs)
except Exception as exception: # pylint: disable=broad-except
self._http_response_error_handler(exception, "Namespaces")
self._http_response_error_handler(exception)
raise exception
else:
kwargs["content_type"] = content_type if content_type else "application/json; charset=utf-8"
try:
self._publish(events, channel_name=channel_name, **kwargs)
except Exception as exception:
self._http_response_error_handler(exception, "Basic")
self._http_response_error_handler(exception)
raise exception

def _http_response_error_handler(self, exception, level):
def _http_response_error_handler(self, exception):
if isinstance(exception, HttpResponseError):
if exception.status_code == 400:
raise HttpResponseError("Invalid event data. Please check the data and try again.") from exception
if exception.status_code == 404:
raise ResourceNotFoundError(
"Resource not found. "
f"Please check that the tier you are using, corresponds to the correct "
"Please check that the tier you are using, corresponds to the correct "
"endpoint and/or topic name."
) from exception
raise exception
Expand Down
3 changes: 2 additions & 1 deletion sdk/eventgrid/azure-eventgrid/azure/eventgrid/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ def __init__(
)

def __repr__(self) -> str:
return f"<EventGridConsumerClient: namespace_topic={self._namespace}, subscription={self._subscription}, credential type={type(self._credential)}>"
return f"<EventGridConsumerClient: namespace_topic={self._namespace}, \
subscription={self._subscription}, credential type={type(self._credential)}>"


def patch_sdk():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from azure.core.pipeline import PipelineResponse
from azure.core.rest import HttpRequest, AsyncHttpResponse
from ...models._patch import ReceiveDetails
from ..._operations._patch import use_standard_only
from ._operations import (
EventGridPublisherClientOperationsMixin as PublisherOperationsMixin,
EventGridConsumerClientOperationsMixin as ConsumerOperationsMixin,
Expand All @@ -29,7 +28,7 @@
)

from ..._legacy import EventGridEvent
from ..._legacy._helpers import _is_eventgrid_event_format, _from_cncf_events
from ..._legacy._helpers import _is_eventgrid_event_format

if sys.version_info >= (3, 9):
from collections.abc import MutableMapping
Expand Down Expand Up @@ -65,8 +64,6 @@ async def send(
) -> None: # pylint: disable=docstring-should-be-keyword, docstring-missing-param
"""Send events to the Event Grid Service.

:param topic_name: The name of the topic to send the event to.
:type topic_name: str
:param events: The event to send.
:type events: CloudEvent or List[CloudEvent] or Dict[str, Any] or List[Dict[str, Any]]
or CNCFCloudEvent or List[CNCFCloudEvent] or EventGridEvent or List[EventGridEvent]
Expand Down Expand Up @@ -104,24 +101,24 @@ async def send(
# Try to send via namespace
await self._publish(self._namespace, _serialize_events(events), **kwargs)
except Exception as exception: # pylint: disable=broad-except
self._http_response_error_handler(exception, "Namespaces")
self._http_response_error_handler(exception)
raise exception
else:
kwargs["content_type"] = content_type if content_type else "application/json; charset=utf-8"
try:
await self._publish(events, channel_name=channel_name, **kwargs)
except Exception as exception:
self._http_response_error_handler(exception, "Basic")
self._http_response_error_handler(exception)
raise exception

def _http_response_error_handler(self, exception, level):
def _http_response_error_handler(self, exception):
if isinstance(exception, HttpResponseError):
if exception.status_code == 400:
raise HttpResponseError("Invalid event data. Please check the data and try again.") from exception
if exception.status_code == 404:
raise ResourceNotFoundError(
"Resource not found. "
f"Please check that the tier you are using, corresponds to the correct "
"Please check that the tier you are using, corresponds to the correct "
"endpoint and/or topic name."
) from exception
raise exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def __init__(
)

def __repr__(self) -> str:
return f"<EventGridConsumerClient: namespace_topic={self._namespace}, subscription={self._subscription}, credential type={type(self._credential)}>"
return f"<EventGridConsumerClient: namespace_topic={self._namespace}, \
subscription={self._subscription}, credential type={type(self._credential)}>"


def patch_sdk():
Expand Down
4 changes: 1 addition & 3 deletions sdk/eventgrid/azure-eventgrid/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[tool.azure-sdk-build]
pyright = false
verifytypes = false
strict_sphinx = false
pylint = false
verifytypes = false