Open PietroPasotti opened 6 months ago
@PietroPasotti thanks for reporting, any idea on how to fix that?
Sorry but no, I looked a bit into it but I'm not familiar enough with ParamSpec to be useful. Will take another look if I have time next week.
@PietroPasotti do you get the error when you run pyright against docs/examples/auto-instrumentation/client.py on latest main? I'm getting a different error, but not one for start_as_current_span
:
auto-instrumentation % pyright client.py
/Users/x/python/open-telemetry/opentelemetry-python/docs/examples/auto-instrumentation/client.py
/Users/x/python/open-telemetry/opentelemetry-python/docs/examples/auto-instrumentation/client.py:30:29 - error: Cannot access member "add_span_processor" for type "TracerProvider"
Member "add_span_processor" is unknown (reportAttributeAccessIssue)
1 error, 0 warnings, 0 informations
@PietroPasotti does this happen for you with 3.11. I am seeing a similar issue with 3.9 and older https://github.com/microsoft/Qcodes/pull/5899
I believe the 3.9 issue is caused by typing.ParamSpec not existing on 3.9 which results in the type effectivly just being a string that would never type check with 3.9. Normally I would suggest that opentelemetry should depend on typing_extensions and use the backported version for older python versions but I am not sure if that is against some policy?
For 3.11 I guess it could be an issue specific to an older patch version. Which exact version are you running? I think there may have been some fixes to paramspec in the patch versions. Note also that the version of pyright that you are using is fairly old. Latest version is 1.1.358. Could you try with a newer one?
tried with pyright 1.1.358, the error is different but on the same line. Now it gives:
error: Expected 0 positional arguments (reportCallIssue)
on tracer.start_as_current_span(name)
Modifying the source to import ParamSpec from typing_extensions fixes it. that's obviously not a solution for the issue, but it might be useful debugging info :)
@PietroPasotti Which exact version of python 3.11 are you using. Looks like there were bugfixes to Paramspec in 3.11.1 and 3.11.3 which may be the reason
https://docs.python.org/release/3.11.9/whatsnew/changelog.html#python-3-11-9
3.11.8
I suspect #3633 broke type checkers' ability to inspect the signature of
start_as_current_span
.Describe your environment python 3.11
opentelemetry-exporter-otlp-proto-http==1.24.0
pyright==1.1.331
Steps to reproduce run pyright on code using
tracer.start_as_current_span(name)
ortracer.start_as_current_span(name=name)
What is the expected behavior? nothing :)
What is the actual behavior?
error: No parameter named "name" (reportGeneralTypeIssues)
orerror: Expected 0 positional arguments (reportGeneralTypeIssues)
Additional context Probably introduced by #3633