From 443601702d87ed4aa7d2a2ad0a4a2e03f4606ff8 Mon Sep 17 00:00:00 2001 From: Asher Foa Date: Fri, 29 Jul 2022 10:01:32 -0400 Subject: [PATCH] Add more otel packages to default module mapping + fix to always use tuples (#16345) As a follow up for https://github.com/pantsbuild/pants/pull/16337 also added test to prevent mistakes like the ones I made in https://github.com/pantsbuild/pants/pull/16330 [ci skip-rust] [ci skip-build-wheels] --- .../dependency_inference/default_module_mapping.py | 10 ++++++++-- .../python/dependency_inference/module_mapper_test.py | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/python/pants/backend/python/dependency_inference/default_module_mapping.py b/src/python/pants/backend/python/dependency_inference/default_module_mapping.py index a103c3e553d..3a7bbac3e12 100644 --- a/src/python/pants/backend/python/dependency_inference/default_module_mapping.py +++ b/src/python/pants/backend/python/dependency_inference/default_module_mapping.py @@ -55,7 +55,7 @@ "django-safedelete": ("safedelete",), "django-simple-history": ("simple_history",), "djangorestframework": ("rest_framework",), - "django-csp": ["csp"], + "django-csp": ("csp",), "enum34": ("enum",), "factory-boy": ("factory",), "fluent-logger": ("fluent",), @@ -90,6 +90,12 @@ "opentelemetry-instrumentation-grpc": ("opentelemetry.instrumentation.grpc",), "opentelemetry-instrumentation-pymongo": ("opentelemetry.instrumentation.pymongo",), "opentelemetry-instrumentation-requests": ("opentelemetry.instrumentation.requests",), + "opentelemetry-instrumentation-botocore": ("opentelemetry.instrumentation.botocore",), + "opentelemetry-instrumentation-django": ("opentelemetry.instrumentation.django",), + "opentelemetry-instrumentation-httpx": ("opentelemetry.instrumentation.httpx",), + "opentelemetry-instrumentation-elasticsearch": ("opentelemetry.instrumentation.elasticsearch",), + "opentelemetry-instrumentation-psycopg2": ("opentelemetry.instrumentation.psycopg2",), + "opentelemetry-instrumentation-jinja2": ("opentelemetry.instrumentation.jinja2",), "opentelemetry-sdk": ("opentelemetry.sdk",), "opentelemetry-test-utils": ("opentelemetry.test",), "paho-mqtt": ("paho",), @@ -125,7 +131,7 @@ "scikit-learn": ("sklearn",), "setuptools": ("easy_install", "pkg_resources", "setuptools"), "streamlit-aggrid": ("st_aggrid",), - "opensearch-py": ["opensearchpy"], + "opensearch-py": ("opensearchpy",), } DEFAULT_TYPE_STUB_MODULE_MAPPING = { diff --git a/src/python/pants/backend/python/dependency_inference/module_mapper_test.py b/src/python/pants/backend/python/dependency_inference/module_mapper_test.py index eb3a05f295e..b36ac8379ec 100644 --- a/src/python/pants/backend/python/dependency_inference/module_mapper_test.py +++ b/src/python/pants/backend/python/dependency_inference/module_mapper_test.py @@ -52,6 +52,12 @@ def test_default_module_mapping_is_normalized() -> None: ), "Please update `DEFAULT_TYPE_STUB_MODULE_MAPPING` to use canonical project names" +def test_default_module_mapping_uses_tuples() -> None: + for modules in DEFAULT_MODULE_MAPPING.values(): + assert isinstance(modules, tuple) + assert len(modules) > 0 + + @pytest.mark.parametrize( "stripped_path,expected", [