From fd169a7c1b22e11b3e45d83a087667b4afa20996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Jagie=C5=82=C5=82o?= Date: Mon, 30 Sep 2024 22:45:04 +0200 Subject: [PATCH] Fix the py.typed marker file usage (#4172) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix the py.typed marker file usage As defined in PEP 561, the py.typed marker files for namespace packages should be placed "in the submodules of the namespace". In commit 732ea8a, the markers were added to the subpackage roots, which serves no purpose. This changeset addresses all marker-related issues in this repository. A summary of the changes: - Removed the unnecessary py.typed markers from the subpackage roots. - Added the missing marker to the prometheus exporter. Fixes #4113. - Added the missing marker to opentelemetry._events. - Removed the accidentally reintroduced jaeger exporters, which were originally removed in commit 1625b35. * Add missing py.typed * Add pyright and fix the reported issues * Update the generated workflow --------- Co-authored-by: Riccardo Magliocchetti Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com> Co-authored-by: Diego Hurtado --- .github/workflows/misc_0.yml | 18 ++++++++++++++++++ CHANGELOG.md | 2 ++ .../py.typed | 0 exporter/opentelemetry-exporter-otlp/py.typed | 0 .../opentelemetry-exporter-prometheus/py.typed | 0 .../exporter/prometheus}/py.typed | 0 .../py.typed | 0 .../py.typed | 0 .../opentelemetry-exporter-zipkin/py.typed | 0 opentelemetry-api/py.typed | 0 .../src/opentelemetry/_events}/py.typed | 0 opentelemetry-proto/py.typed | 0 .../src/opentelemetry/proto}/py.typed | 0 opentelemetry-sdk/py.typed | 0 .../opentelemetry/sdk/_configuration/py.typed | 0 .../src/opentelemetry/sdk/_logs/py.typed | 0 .../sdk/environment_variables/py.typed | 0 .../opentelemetry/sdk/error_handler/py.typed | 0 .../exponential_histogram/__init__.py | 0 .../src/opentelemetry/sdk/metrics/py.typed | 0 .../src/opentelemetry/sdk/resources/py.typed | 0 .../src/opentelemetry/sdk/trace/py.typed | 0 .../src/opentelemetry/sdk/util/py.typed | 0 .../src/opentelemetry/sdk/version/py.typed | 0 opentelemetry-semantic-conventions/py.typed | 0 .../semconv/attributes/__init__.py | 0 .../src/opentelemetry/semconv/metrics/py.typed | 0 .../src/opentelemetry/semconv}/py.typed | 0 .../opentelemetry/semconv/resource/py.typed | 0 .../src/opentelemetry/semconv/trace/py.typed | 0 pyproject.toml | 9 +++++++++ pyright-requirements.txt | 1 + tox.ini | 16 ++++++++++++++++ 33 files changed, 46 insertions(+) delete mode 100644 exporter/opentelemetry-exporter-otlp-proto-http/py.typed delete mode 100644 exporter/opentelemetry-exporter-otlp/py.typed delete mode 100644 exporter/opentelemetry-exporter-prometheus/py.typed rename exporter/{opentelemetry-exporter-jaeger-proto-grpc => opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus}/py.typed (100%) delete mode 100644 exporter/opentelemetry-exporter-zipkin-json/py.typed delete mode 100644 exporter/opentelemetry-exporter-zipkin-proto-http/py.typed delete mode 100644 exporter/opentelemetry-exporter-zipkin/py.typed delete mode 100644 opentelemetry-api/py.typed rename {exporter/opentelemetry-exporter-jaeger-thrift => opentelemetry-api/src/opentelemetry/_events}/py.typed (100%) delete mode 100644 opentelemetry-proto/py.typed rename {exporter/opentelemetry-exporter-jaeger => opentelemetry-proto/src/opentelemetry/proto}/py.typed (100%) delete mode 100644 opentelemetry-sdk/py.typed delete mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/_configuration/py.typed delete mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/_logs/py.typed delete mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/environment_variables/py.typed delete mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/error_handler/py.typed rename exporter/opentelemetry-exporter-opencensus/py.typed => opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/exponential_histogram/__init__.py (100%) delete mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/metrics/py.typed delete mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/resources/py.typed delete mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/trace/py.typed delete mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/util/py.typed delete mode 100644 opentelemetry-sdk/src/opentelemetry/sdk/version/py.typed delete mode 100644 opentelemetry-semantic-conventions/py.typed rename exporter/opentelemetry-exporter-otlp-proto-common/py.typed => opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/__init__.py (100%) delete mode 100644 opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics/py.typed rename {exporter/opentelemetry-exporter-otlp-proto-grpc => opentelemetry-semantic-conventions/src/opentelemetry/semconv}/py.typed (100%) delete mode 100644 opentelemetry-semantic-conventions/src/opentelemetry/semconv/resource/py.typed delete mode 100644 opentelemetry-semantic-conventions/src/opentelemetry/semconv/trace/py.typed create mode 100644 pyright-requirements.txt diff --git a/.github/workflows/misc_0.yml b/.github/workflows/misc_0.yml index 7de8653a12b..fbb06fd4743 100644 --- a/.github/workflows/misc_0.yml +++ b/.github/workflows/misc_0.yml @@ -88,6 +88,24 @@ jobs: - name: Run tests run: tox -e mypyinstalled + pyright: + name: pyright + runs-on: ubuntu-latest + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install tox + run: pip install tox + + - name: Run tests + run: tox -e pyright + docs: name: docs runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 86739f645f3..9848078bbde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +- Removed superfluous py.typed markers and added them where they were missing + ([#4172](https://github.com/open-telemetry/opentelemetry-python/pull/4172)) - Include metric info in encoding exceptions ([#4154](https://github.com/open-telemetry/opentelemetry-python/pull/4154)) - sdk: Add support for log formatting diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/py.typed b/exporter/opentelemetry-exporter-otlp-proto-http/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/exporter/opentelemetry-exporter-otlp/py.typed b/exporter/opentelemetry-exporter-otlp/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/exporter/opentelemetry-exporter-prometheus/py.typed b/exporter/opentelemetry-exporter-prometheus/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/exporter/opentelemetry-exporter-jaeger-proto-grpc/py.typed b/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/py.typed similarity index 100% rename from exporter/opentelemetry-exporter-jaeger-proto-grpc/py.typed rename to exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/py.typed diff --git a/exporter/opentelemetry-exporter-zipkin-json/py.typed b/exporter/opentelemetry-exporter-zipkin-json/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/exporter/opentelemetry-exporter-zipkin-proto-http/py.typed b/exporter/opentelemetry-exporter-zipkin-proto-http/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/exporter/opentelemetry-exporter-zipkin/py.typed b/exporter/opentelemetry-exporter-zipkin/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/opentelemetry-api/py.typed b/opentelemetry-api/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/exporter/opentelemetry-exporter-jaeger-thrift/py.typed b/opentelemetry-api/src/opentelemetry/_events/py.typed similarity index 100% rename from exporter/opentelemetry-exporter-jaeger-thrift/py.typed rename to opentelemetry-api/src/opentelemetry/_events/py.typed diff --git a/opentelemetry-proto/py.typed b/opentelemetry-proto/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/exporter/opentelemetry-exporter-jaeger/py.typed b/opentelemetry-proto/src/opentelemetry/proto/py.typed similarity index 100% rename from exporter/opentelemetry-exporter-jaeger/py.typed rename to opentelemetry-proto/src/opentelemetry/proto/py.typed diff --git a/opentelemetry-sdk/py.typed b/opentelemetry-sdk/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_configuration/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/_configuration/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/error_handler/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/error_handler/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/exporter/opentelemetry-exporter-opencensus/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/exponential_histogram/__init__.py similarity index 100% rename from exporter/opentelemetry-exporter-opencensus/py.typed rename to opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/exponential_histogram/__init__.py diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/resources/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/resources/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/trace/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/util/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/util/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/version/py.typed b/opentelemetry-sdk/src/opentelemetry/sdk/version/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/opentelemetry-semantic-conventions/py.typed b/opentelemetry-semantic-conventions/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/py.typed b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/__init__.py similarity index 100% rename from exporter/opentelemetry-exporter-otlp-proto-common/py.typed rename to opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/__init__.py diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics/py.typed b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/exporter/opentelemetry-exporter-otlp-proto-grpc/py.typed b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/py.typed similarity index 100% rename from exporter/opentelemetry-exporter-otlp-proto-grpc/py.typed rename to opentelemetry-semantic-conventions/src/opentelemetry/semconv/py.typed diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/resource/py.typed b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/resource/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/trace/py.typed b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/trace/py.typed deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/pyproject.toml b/pyproject.toml index 01ae2999afc..873076c802c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,3 +18,12 @@ exclude = ''' [tool.pytest.ini_options] addopts = "-rs -v" log_cli = true + +[tool.pyright] +typeCheckingMode = "off" +reportMissingTypeStubs = "error" +include = [ + "opentelemetry-api/src", + "opentelemetry-sdk/src", + "opentelemetry-semantic-conventions/src", +] diff --git a/pyright-requirements.txt b/pyright-requirements.txt new file mode 100644 index 00000000000..bc67a370c05 --- /dev/null +++ b/pyright-requirements.txt @@ -0,0 +1 @@ +pyright==1.1.381 diff --git a/tox.ini b/tox.ini index 23f5947c4bd..973158af1f1 100644 --- a/tox.ini +++ b/tox.ini @@ -105,6 +105,7 @@ envlist = spellcheck tracecontext mypy,mypyinstalled + pyright docs docker-tests-proto{3,4} public-symbols-check @@ -445,3 +446,18 @@ commands_pre = commands = sh -c "find {toxinidir} -name \*.sh | xargs shellcheck --severity=warning" + +[testenv:pyright] +basepython: python3 + +allowlist_externals = pyright + +commands_pre = + pip install -r {toxinidir}/pyright-requirements.txt \ + -e {toxinidir}/opentelemetry-api \ + -e {toxinidir}/opentelemetry-semantic-conventions \ + -e {toxinidir}/opentelemetry-sdk + +commands = + pyright --version + pyright