Skip to content
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

Update __all__ to statically define reexports #3143

Merged
merged 10 commits into from
Feb 15, 2023
Next Next commit
Statically define __all__ for stable modules
This prevents errors from typecheckers since
they can now see that members are explicitly reexported
jenshnielsen committed Jan 25, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit a95bde91ed17e5f6d041417236590379451e69e4
28 changes: 14 additions & 14 deletions opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -12,16 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# pylint: disable=unused-import

from opentelemetry.sdk.metrics._internal import ( # noqa: F401
Meter,
MeterProvider,
)
from opentelemetry.sdk.metrics._internal.exceptions import ( # noqa: F401
MetricsTimeoutError,
)
from opentelemetry.sdk.metrics._internal.instrument import ( # noqa: F401
from opentelemetry.sdk.metrics._internal import Meter, MeterProvider
from opentelemetry.sdk.metrics._internal.exceptions import MetricsTimeoutError
from opentelemetry.sdk.metrics._internal.instrument import (
Counter,
Histogram,
ObservableCounter,
@@ -30,8 +24,14 @@
UpDownCounter,
)

__all__ = []
for key, value in globals().copy().items():
if not key.startswith("_"):
value.__module__ = __name__
__all__.append(key)
__all__ = [
"Meter",
"MeterProvider",
"MetricsTimeoutError",
"Counter",
"Histogram",
"ObservableCounter",
"ObservableGauge",
"ObservableUpDownCounter",
"UpDownCounter",
]
Original file line number Diff line number Diff line change
@@ -12,9 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# pylint: disable=unused-import

from opentelemetry.sdk.metrics._internal.export import ( # noqa: F401
from opentelemetry.sdk.metrics._internal.export import (
AggregationTemporality,
ConsoleMetricExporter,
InMemoryMetricReader,
@@ -25,7 +24,7 @@
)

# The point module is not in the export directory to avoid a circular import.
from opentelemetry.sdk.metrics._internal.point import ( # noqa: F401
from opentelemetry.sdk.metrics._internal.point import (
DataPointT,
DataT,
Gauge,
@@ -39,8 +38,23 @@
Sum,
)

__all__ = []
for key, value in globals().copy().items():
if not key.startswith("_"):
value.__module__ = __name__
__all__.append(key)
__all__ = [
"AggregationTemporality",
"ConsoleMetricExporter",
"InMemoryMetricReader",
"MetricExporter",
"MetricExportResult",
"MetricReader",
"PeriodicExportingMetricReader",
"DataPointT",
"DataT",
"Gauge",
"Histogram",
"HistogramDataPoint",
"Metric",
"MetricsData",
"NumberDataPoint",
"ResourceMetrics",
"ScopeMetrics",
"Sum",
]
Original file line number Diff line number Diff line change
@@ -12,20 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# pylint: disable=unused-import

from opentelemetry.sdk.metrics._internal.aggregation import ( # noqa: F401
from opentelemetry.sdk.metrics._internal.aggregation import (
Aggregation,
DefaultAggregation,
DropAggregation,
ExplicitBucketHistogramAggregation,
LastValueAggregation,
SumAggregation,
)
from opentelemetry.sdk.metrics._internal.view import View # noqa: F401
from opentelemetry.sdk.metrics._internal.view import View

__all__ = []
for key, value in globals().copy().items():
if not key.startswith("_"):
value.__module__ = __name__
__all__.append(key)
__all__ = [
"Aggregation",
"DefaultAggregation",
"DropAggregation",
"ExplicitBucketHistogramAggregation",
"LastValueAggregation",
"SumAggregation",
"View",
]