-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[EventGrid] Fix lint errors #13640
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
[EventGrid] Fix lint errors #13640
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| __path__ = __import__('pkgutil').extend_path(__path__, __name__) | ||
| __path__ = __import__('pkgutil').extend_path(__path__, __name__) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,16 +3,12 @@ | |
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| # pylint:disable=protected-access | ||
| from typing import Optional | ||
| from msrest.serialization import UTC | ||
| import datetime as dt | ||
| import uuid | ||
| import json | ||
| import six | ||
| from ._generated import models | ||
| from ._generated.models import StorageBlobCreatedEventData, \ | ||
| EventGridEvent as InternalEventGridEvent, \ | ||
| CloudEvent as InternalCloudEvent | ||
| from msrest.serialization import UTC | ||
| from ._generated.models import EventGridEvent as InternalEventGridEvent, CloudEvent as InternalCloudEvent | ||
| from ._shared.mixins import DictMixin | ||
lmazuel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| from ._event_mappings import _event_mappings | ||
|
|
||
|
|
@@ -55,8 +51,8 @@ class CloudEvent(EventMixin): #pylint:disable=too-many-instance-attributes | |
|
|
||
| All required parameters must be populated in order to send to Azure. | ||
|
|
||
| :param source: Required. Identifies the context in which an event happened. The combination of id and source must be | ||
| unique for each distinct event. If publishing to a domain topic, source must be the domain name. | ||
| :param source: Required. Identifies the context in which an event happened. The combination of id and source must | ||
| be unique for each distinct event. If publishing to a domain topic, source must be the domain name. | ||
| :type source: str | ||
| :param data: Event data specific to the event type. | ||
| :type data: object | ||
|
|
@@ -75,7 +71,7 @@ class CloudEvent(EventMixin): #pylint:disable=too-many-instance-attributes | |
| unique for each distinct event. | ||
| :type id: Optional[str] | ||
| """ | ||
| def __init__(self, source, type, **kwargs): | ||
| def __init__(self, source, type, **kwargs): # pylint: disable=redefined-builtin | ||
lmazuel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # type: (str, str, Any) -> None | ||
| self.source = source | ||
| self.type = type | ||
|
|
@@ -87,13 +83,13 @@ def __init__(self, source, type, **kwargs): | |
| self.dataschema = kwargs.pop("dataschema", None) | ||
| self.subject = kwargs.pop("subject", None) | ||
| self.extensions = {} | ||
| self.extensions.update({k:v for k, v in kwargs.pop('extensions', {}).items()}) | ||
| self.extensions.update(dict(kwargs.pop('extensions', {}))) | ||
|
|
||
| @classmethod | ||
| def _from_generated(cls, cloud_event, **kwargs): | ||
| generated = InternalCloudEvent.deserialize(cloud_event) | ||
| if generated.additional_properties: | ||
| extensions = {k:v for k, v in generated.additional_properties.items()} | ||
| extensions = dict(generated.additional_properties) | ||
| kwargs.setdefault('extensions', extensions) | ||
| return cls( | ||
| id=generated.id, | ||
|
|
@@ -154,7 +150,8 @@ class EventGridEvent(InternalEventGridEvent, EventMixin): | |
| :param id: Optional. An identifier for the event. The combination of id and source must be | ||
| unique for each distinct event. | ||
| :type id: Optional[str] | ||
| :param event_time: Optional.The time (in UTC) of the event. If not provided, it will be the time (in UTC) the event was generated. | ||
| :param event_time: Optional.The time (in UTC) of the event. If not provided, | ||
| it will be the time (in UTC) the event was generated. | ||
|
||
| :type event_time: Optional[~datetime.datetime] | ||
| """ | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,11 +5,11 @@ | |
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
|
|
||
| from typing import TYPE_CHECKING, Sequence | ||
| import json | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| from azure.core import PipelineClient | ||
| from msrest import Deserializer, Serializer | ||
| from ._models import CloudEvent, EventGridEvent, CustomEvent | ||
| from ._helpers import _get_topic_hostname_only_fqdn, _get_authentication_policy, _is_cloud_event | ||
| from ._generated._event_grid_publisher_client import EventGridPublisherClient as EventGridPublisherClientImpl | ||
|
|
||
| if TYPE_CHECKING: | ||
| # pylint: disable=unused-import,ungrouped-imports | ||
|
|
@@ -25,18 +25,17 @@ | |
| List[Dict] | ||
| ] | ||
|
|
||
| from ._models import CloudEvent, EventGridEvent, CustomEvent | ||
| from ._helpers import _get_topic_hostname_only_fqdn, _get_authentication_policy, _is_cloud_event | ||
| from ._generated._event_grid_publisher_client import EventGridPublisherClient as EventGridPublisherClientImpl | ||
| from . import _constants as constants | ||
|
|
||
|
|
||
| class EventGridPublisherClient(object): | ||
| """EventGrid Python Publisher Client. | ||
|
|
||
| :param str topic_hostname: The topic endpoint to send the events to. | ||
| :param credential: The credential object used for authentication which implements SAS key authentication or SAS token authentication. | ||
| :type credential: Union[~azure.core.credentials.AzureKeyCredential, azure.eventgrid.EventGridSharedAccessSignatureCredential] | ||
| :param credential: The credential object used for authentication which | ||
| implements SAS key authentication or SAS token authentication. | ||
|
||
| :type credential: Union[ | ||
|
||
| ~azure.core.credentials.AzureKeyCredential, | ||
| azure.eventgrid.EventGridSharedAccessSignatureCredential | ||
| ] | ||
| """ | ||
|
|
||
| def __init__(self, topic_hostname, credential, **kwargs): | ||
|
|
@@ -54,7 +53,8 @@ def send(self, events, **kwargs): | |
| :param events: A list or an instance of CloudEvent/EventGridEvent/CustomEvent to be sent. | ||
| :type events: SendType | ||
| :keyword str content_type: The type of content to be used to send the events. | ||
| Has default value "application/json; charset=utf-8" for EventGridEvents, with "cloudevents-batch+json" for CloudEvents | ||
| Has default value "application/json; charset=utf-8" for EventGridEvents, | ||
|
||
| with "cloudevents-batch+json" for CloudEvents | ||
| :rtype: None | ||
| :raises: :class:`ValueError`, when events do not follow specified SendType. | ||
| """ | ||
|
|
@@ -63,7 +63,7 @@ def send(self, events, **kwargs): | |
|
|
||
| if all(isinstance(e, CloudEvent) for e in events) or all(_is_cloud_event(e) for e in events): | ||
| try: | ||
| events = [e._to_generated(**kwargs) for e in events] | ||
| events = [e._to_generated(**kwargs) for e in events] # pylint: disable=protected-access | ||
| except AttributeError: | ||
| pass # means it's a dictionary | ||
| kwargs.setdefault("content_type", "application/cloudevents-batch+json; charset=utf-8") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a space to keep it part of the param doc