-
Notifications
You must be signed in to change notification settings - Fork 753
Description
Describe your environment
mypy with no-implicit-reexport
enabled
pyright with default settings
Any OS or python version
Steps to reproduce
type check a line like
from opentelemetry.sdk.metrics import MeterProvider,
or open it in vscode with pylance and pyright enabled
What is the expected behavior?
Code to typecheck
What is the actual behavior?
Error such as (from pylance/pyright)
"MeterProvider" is not exported from module "opentelemetry.sdk.metrics"
Import from "opentelemetry.sdk.metrics._internal" insteadPylance[reportPrivateImportUsage](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportPrivateImportUsage)
Additional context
This is caused by __all__
being dynamically generated for example here https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py
The docs suggests to disable implicit_reexport as implemented here open-telemetry/opentelemetry.io#1611
This is problematic for a number of reasons.
It doesn't actually fix the issue with pyright/pylance
The implicit reexport feature is very useful and makes it much easier to spot that you are unintentionally importing symbols from the wrong location. Doing it like recommended disables this feature for all packages.
Would it be possible to replace those dynamically generated __all__
s with static ones