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

[ServiceBus] Add type hint #14507

Merged
merged 3 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AutoLockRenew:
tokens of messages and/or sessions in the background.

:param loop: An async event loop.
:type loop: ~asyncio.BaseEventLoop
:type loop: ~asyncio.AbstractEventLoop

.. admonition:: Example:

Expand All @@ -48,7 +48,7 @@ class AutoLockRenew:

"""

def __init__(self, loop: Optional[asyncio.BaseEventLoop] = None) -> None:
def __init__(self, loop: Optional[asyncio.AbstractEventLoop] = None) -> None:
self._shutdown = asyncio.Event()
self._futures = [] # type: List[asyncio.Future]
self._loop = loop or get_running_loop()
Expand Down Expand Up @@ -126,6 +126,7 @@ def register(self,
:param Optional[AsyncLockRenewFailureCallback] on_lock_renew_failure:
An async callback may be specified to be called when the lock is lost on the renewable being registered.
Default value is None (no callback).
:rtype: None
"""
if self._shutdown.is_set():
raise ServiceBusError("The AutoLockRenew has already been shutdown. Please create a new instance for"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,11 @@ async def receive_messages(self, max_message_count=None, max_wait_time=None):
operation_requires_timeout=True
)

async def receive_deferred_messages(self, sequence_numbers, **kwargs):
# type: (Union[int, List[int]], Any) -> List[ReceivedMessage]
async def receive_deferred_messages(
self,
sequence_numbers: Union[int, List[int]],
**kwargs: Any
) -> List[ReceivedMessage]:
"""Receive messages that have previously been deferred.

When receiving deferred messages from a partitioned entity, all of the supplied
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ServiceBusAdministrationClient: #pylint:disable=too-many-public-methods
def __init__(
self, fully_qualified_namespace: str,
credential: "AsyncTokenCredential",
**kwargs) -> None:
**kwargs: Any) -> None:

self.fully_qualified_namespace = fully_qualified_namespace
self._credential = credential
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def delete_queue(self, queue_name, **kwargs):
# type: (str, Any) -> None
"""Delete a queue.

:param str queue: The name of the queue or
:param str queue_name: The name of the queue or
a `QueueProperties` with name.
:rtype: None
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,49 +48,63 @@ def validate_extraction_missing_args(extraction_missing_args):
class DictMixin(object):

def __setitem__(self, key, item):
# type: (Any, Any) -> None
self.__dict__[key] = item

def __getitem__(self, key):
# type: (Any) -> Any
return self.__dict__[key]

def __repr__(self):
# type: () -> str
return str(self)

def __len__(self):
# type: () -> int
return len(self.keys())

def __delitem__(self, key):
# type: (Any) -> None
self.__dict__[key] = None

def __eq__(self, other):
# type: (Any) -> bool
"""Compare objects by comparing all attributes."""
if isinstance(other, self.__class__):
return self.__dict__ == other.__dict__
return False

def __ne__(self, other):
# type: (Any) -> bool
"""Compare objects by comparing all attributes."""
return not self.__eq__(other)

def __str__(self):
# type: () -> str
return str({k: v for k, v in self.__dict__.items() if not k.startswith('_')})

def has_key(self, k):
# type: (Any) -> bool
return k in self.__dict__

def update(self, *args, **kwargs):
# type: (Any, Any) -> None
return self.__dict__.update(*args, **kwargs)

def keys(self):
# type: () -> list
return [k for k in self.__dict__ if not k.startswith('_')]

def values(self):
# type: () -> list
return [v for k, v in self.__dict__.items() if not k.startswith('_')]

def items(self):
# type: () -> list
return [(k, v) for k, v in self.__dict__.items() if not k.startswith('_')]

def get(self, key, default=None):
# type: (Any, Optional[Any]) -> Any
if key in self.__dict__:
return self.__dict__[key]
return default
Expand Down