open-telemetry / opentelemetry-python-contrib

OpenTelemetry instrumentation for Python modules
https://opentelemetry.io
Apache License 2.0
739 stars 611 forks source link

Missing type stubs for instrumentation #3021

Open vikigenius opened 3 days ago

vikigenius commented 3 days ago

Describe your environment

OS: Void Linux Python version: Python 3.12 SDK version: 1.28.1 API version: 1.28.1

What happened?

Pyright type checker complains about missing type stubs for

Stub file not found for "opentelemetry.instrumentation.asgi"

And

Stub file not found for "opentelemetry.instrumentation.sqlalchemy"

These are the two I checked presumably there could be more missing type stubs.

Steps to Reproduce

Just import

    from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware
    from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor

And run pyright in strict mode. Or use basedpyright that is strict by default.

Expected Result

No complaints from pyright about missing type stubs

Actual Result

complaints from pyright about missing type stubs

Additional context

No response

Would you like to implement a fix?

None

aabmass commented 18 hours ago

I think in most cases, we are simply missing type stubs for most of this repo. PRs are always welcome to improve typing!

Kludex commented 2 hours ago

Can I enforce with a type checker on the files I improve them?

xrmx commented 2 hours ago

Can I enforce with a type checker on the files I improve them?

Sure, we are already doing partial type checking in the core repo