- Package Name: azure-servicebus
- Package Version: 7.14.3
- Operating System: Windows 11 Pro (10.0.26200)
- Python Version: 3.13.5
Describe the bug
The async client's receiver factory methods type the auto_lock_renewer keyword with the synchronous AutoLockRenewer, while their own docstrings - and the working runtime behavior - call for azure.servicebus.aio.AutoLockRenewer
Static type checkers therefore reject the documented, runtime-correct usage, forcing a cast() / suppression comment at every call site. Note the annotation doesn't merely disagree with the docs - it names the class that cannot work there: the sync renewer's renewal loop is thread-based and would invoke the async receiver's coroutine methods without awaiting them.
To Reproduce
Steps to reproduce the behavior:
- Type-check the following with pyright (or mypy/ty):
from azure.servicebus.aio import AutoLockRenewer, ServiceBusClient
async def main() -> None:
client = ServiceBusClient.from_connection_string("...")
renewer = AutoLockRenewer()
receiver = client.get_subscription_receiver(
"topic",
"subscription",
auto_lock_renewer=renewer,
)
- Pyright 1.1.411 reports:
Argument of type "AutoLockRenewer" cannot be assigned to parameter "auto_lock_renewer"
of type "AutoLockRenewer | None" in function "get_subscription_receiver"
"azure.servicebus.aio._async_auto_lock_renewer.AutoLockRenewer" is not assignable to
"azure.servicebus._common.auto_lock_renewer.AutoLockRenewer"
(ty 0.x reports the equivalent invalid-argument-type.)
Expected behavior
The aio module's annotations reference azure.servicebus.aio.AutoLockRenewer, matching the docstrings, so the documented usage type-checks without suppressions.
Screenshots
N/A - diags quoted above.
Additional context
Runtime behavior confirms the docstring, not the annotation: passing the aio AutoLockRenewer through this parameter against a live namespace works correctly (verified with a 30s-lock subscription and a 40s handler hold - the renewer fired on schedule, locked_until_utc advanced past the original expiry, and complete_message settled the message). The annotation appears to be a copy of the sync client's signature; the sync module (azure/servicebus/_servicebus_client.py) uses the same import legitimately.
Describe the bug
The async client's receiver factory methods type the
auto_lock_renewerkeyword with the synchronousAutoLockRenewer, while their own docstrings - and the working runtime behavior - call forazure.servicebus.aio.AutoLockRenewerStatic type checkers therefore reject the documented, runtime-correct usage, forcing a cast() / suppression comment at every call site. Note the annotation doesn't merely disagree with the docs - it names the class that cannot work there: the sync renewer's renewal loop is thread-based and would invoke the async receiver's coroutine methods without awaiting them.
To Reproduce
Steps to reproduce the behavior:
(ty 0.x reports the equivalent invalid-argument-type.)
Expected behavior
The aio module's annotations reference
azure.servicebus.aio.AutoLockRenewer, matching the docstrings, so the documented usage type-checks without suppressions.Screenshots
N/A - diags quoted above.
Additional context
Runtime behavior confirms the docstring, not the annotation: passing the aio
AutoLockRenewerthrough this parameter against a live namespace works correctly (verified with a 30s-lock subscription and a 40s handler hold - the renewer fired on schedule,locked_until_utcadvanced past the original expiry, andcomplete_messagesettled the message). The annotation appears to be a copy of the sync client's signature; the sync module (azure/servicebus/_servicebus_client.py) uses the same import legitimately.