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
use ParamSpec to enable intellisense with distributed_trace decorators #22891
Conversation
API changes have been detected in |
API changes have been detected in API changes - def azure.core.tracing.decorator.distributed_trace(__func = None, **kwargs) -> Callable[, T]
+ def azure.core.tracing.decorator.distributed_trace(__func: Callable[P, T] = None, **kwargs: Any) -> Callable[P, T]
- def azure.core.tracing.decorator_async.distributed_trace_async(__func: Callable[Ellipsis, Awaitable[T]] = None, **kwargs: Any) -> Callable[, Awaitable[T]]
+ def azure.core.tracing.decorator_async.distributed_trace_async(__func: Callable[P, Awaitable[T]] = None, **kwargs: Any) -> Callable[P, Awaitable[T]] |
API changes have been detected in |
API changes have been detected in API changes + def __str__(self)
+
+
+ def __str__(self) |
API changes have been detected in |
API changes have been detected in API changes + def __str__(self)
+
+
+ def __str__(self) |
API changes have been detected in API changes + def __str__(self)
+ |
API changes have been detected in |
We run mypy==0.782 in the CI and it erroneously calls out these errors in this PR:
Running with the latest release (mypy==0.931) does not raise these errors. Options I see...
|
Output on mypy opted-in packages using mypy==0.931 and Python 3.10
|
API changes have been detected in |
API changes have been detected in |
Azure#22891) * use ParamSpec in distributed_trace decorators to enable intellisense in py3.10+ * use backported ParamSpec from typings * add dependency on typing_extensions * fix name, remove from dev_reqs * fix typing-extensions version * update changelog
Azure#22891) * use ParamSpec in distributed_trace decorators to enable intellisense in py3.10+ * use backported ParamSpec from typings * add dependency on typing_extensions * fix name, remove from dev_reqs * fix typing-extensions version * update changelog
@kristapratico seems this PR introduces some import issue in databricks ML runtime (see this issue: feathr-ai/feathr#154). Also seems like ParamSpec is added in 3.10 (https://docs.python.org/3/library/typing.html#typing.ParamSpec) so maybe we should also have a way to relax this limitation? |
And can be repoduced by this (in databricks ML 10.2): and will throw out this error:
|
@xiaoyongzhu moving this conversation to #23697 |
@kristapratico @lmazuel Is there a particular reason why you are depending on I am asking because I am trying to upgrade We currently have I did some tests with the Azure SDK and CLI with |
Hey @glaubitz, if I recall correctly |
@kristapratico Thanks for the answer! Do you know whether is a way to reliably test the compatibility? |
@glaubitz here's what I did to test compatibility.
from azure.storage.blob import BlobServiceClient
client = BlobServiceClient(account_url="x")
client.set_service_properties(analytics_logging=True)
If you see the typing error, then typing is working correctly with the older version of typing-extensions (3.10.0.0) and using ParamSpec to forward the argument types to the client method. If you don't see the error (parameter gets typed as Any), then the typing experience is degraded with the older version. Note that I only tested this with Python 3.7 (although it appears to work on machine). |
@kristapratico Wow, thanks a lot! This is incredibly helpful! I will perform these tests with the various Python versions. |
Apologies for the late reply. I performed the check with
|
This PR is related to this discussion on Teams where we noticed that our
distributed_trace
decorators were blocking the intellisense type help. Fortunately there is a solution to this called typing.ParamSpec which forwards the parameter types of one callable to another callable and restores our type hinting!ParamSpec: https://docs.python.org/3/library/typing.html#typing.ParamSpec
This only works for py3.10+, but does enable intellisense as expected:This works for all supported Python versions.VSCode/pylance:
Pycharm: