Skip to content

[ServiceBus] aio client and receiver annotate auto_lock_renewer with the sync AutoLockRenewer class, contradicting their own docstrings #47948

Description

@SirPangolin
  • 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:

  1. 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,
      )
  1. 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.

Metadata

Metadata

Labels

ClientThis issue points to a problem in the data-plane of the library.Service AttentionWorkflow: This issue is responsible by Azure service team.Service Buscustomer-reportedIssues that are reported by GitHub users external to the Azure organization.issue-addressedWorkflow: The Azure SDK team believes it to be addressed and ready to close.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions