Skip to content

Commit

Permalink
[EGv2] Eg typing/formatting (Azure#30492)
Browse files Browse the repository at this point in the history
* mypy pylint

* update samples

* remove version disclaimer
  • Loading branch information
l0lawrence committed Sep 6, 2023
1 parent 76f270e commit 32385e2
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 28 deletions.
2 changes: 0 additions & 2 deletions sdk/eventgrid/azure-eventgrid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ Azure Event Grid is a fully-managed intelligent event routing service that allow

## _Disclaimer_

_Azure SDK Python packages support for Python 2.7 has ended on 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_

This is the first beta release of Azure EventGrid's `EventGridClient`, along with the GA `EventGridPublisherClient`. `EventGridClient` supports `publish_cloud_events`, `receive_cloud_events`, `acknowledge_cloud_events` , `release_cloud_events`, and `reject_cloud_events` operations. Please refer to the [samples](https://github.com/Azure/azure-sdk-for-python/tree/feature/eventgrid/sdk/eventgrid/azure-eventgrid/samples/sync_samples/eventgrid_client_samples) for further information.

## Getting started
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

def build_event_grid_publish_cloud_event_request(
topic_name: str,
*,
content: _models._models.CloudEvent,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
Expand All @@ -57,15 +55,12 @@ def build_event_grid_publish_cloud_event_request(
url=_url,
params=_params,
headers=_headers,
content=content,
**kwargs
)


def build_event_grid_publish_cloud_events_request(
topic_name: str,
*,
content: List[_models._models.CloudEvent],
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
Expand All @@ -92,7 +87,6 @@ def build_event_grid_publish_cloud_events_request(
url=_url,
params=_params,
headers=_headers,
content=content,
**kwargs
)

Expand Down Expand Up @@ -142,8 +136,6 @@ def build_event_grid_receive_cloud_events_request(
def build_event_grid_acknowledge_cloud_events_request(
topic_name: str,
event_subscription_name: str,
*,
content: _models.AcknowledgeOptions,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
Expand Down Expand Up @@ -174,16 +166,13 @@ def build_event_grid_acknowledge_cloud_events_request(
url=_url,
params=_params,
headers=_headers,
content=content,
**kwargs
)


def build_event_grid_release_cloud_events_request(
topic_name: str,
event_subscription_name: str,
*,
content: _models.ReleaseOptions,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
Expand Down Expand Up @@ -214,16 +203,13 @@ def build_event_grid_release_cloud_events_request(
url=_url,
params=_params,
headers=_headers,
content=content,
**kwargs
)


def build_event_grid_reject_cloud_events_request(
topic_name: str,
event_subscription_name: str,
*,
content: _models.RejectOptions,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
Expand Down Expand Up @@ -254,14 +240,13 @@ def build_event_grid_reject_cloud_events_request(
url=_url,
params=_params,
headers=_headers,
content=content,
**kwargs
)

class EventGridClientOperationsMixin(EventGridClientMixinABC):

@distributed_trace
def _publish_cloud_event( # pylint: disable=inconsistent-return-statements
def _publish_cloud_event( # pylint: disable=inconsistent-return-statements,protected-access
self,
topic_name: str,
event: _models._models.CloudEvent,
Expand Down Expand Up @@ -405,7 +390,7 @@ def _publish_cloud_events( # pylint: disable=inconsistent-return-statements


@distributed_trace
def _receive_cloud_events(
def _receive_cloud_events( # pylint: disable=protected-access
self,
topic_name: str,
event_subscription_name: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class EventGridClientOperationsMixin(EventGridClientMixinABC):

@distributed_trace_async
async def _publish_cloud_event( # pylint: disable=inconsistent-return-statements
async def _publish_cloud_event( # pylint: disable=inconsistent-return-statements,protected-access
self,
topic_name: str,
event: _models._models.CloudEvent,
Expand Down Expand Up @@ -170,7 +170,7 @@ async def _publish_cloud_events( # pylint: disable=inconsistent-return-statemen


@distributed_trace_async
async def _receive_cloud_events(
async def _receive_cloud_events( # pylint: disable=protected-access
self,
topic_name: str,
event_subscription_name: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ async def run():


if __name__ == "__main__":
asyncio.run(run())
asyncio.get_event_loop().run_until_complete(run())
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
)


async def main():
async def run():
async with client:
# Publish a CloudEvent
try:
Expand Down Expand Up @@ -123,4 +123,5 @@ async def main():
print(f"Succeeded Lock Token:{succeeded_lock_token}")


asyncio.run(main())
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(run())
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ async def run():


if __name__ == "__main__":
asyncio.run(run())
asyncio.get_event_loop().run_until_complete(run())
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ async def run():


if __name__ == "__main__":
asyncio.run(run())
asyncio.get_event_loop().run_until_complete(run())
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ async def run():


if __name__ == "__main__":
asyncio.run(run())
asyncio.get_event_loop().run_until_complete(run())
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ async def run():


if __name__ == "__main__":
asyncio.run(run())
asyncio.get_event_loop().run_until_complete(run())

0 comments on commit 32385e2

Please sign in to comment.