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 Feb 16, 2024
1 parent d397b62 commit d998006
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 26 deletions.
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 d998006

Please sign in to comment.