From a740800a4429c49d9aefe4941786670ba8c617a5 Mon Sep 17 00:00:00 2001 From: Asher Foa <1268088+asherf@users.noreply.github.com> Date: Thu, 28 Jul 2022 16:17:54 -0400 Subject: [PATCH 1/4] Add more otel packages to default module mapping + fix to always use tuples also added test to prevent mistakes like the ones I made in https://github.com/pantsbuild/pants/pull/16330 --- .../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..63d96c1ef17 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", [ From 4e4ff83d72f855a53ce98b7c9bc9618c909d221a Mon Sep 17 00:00:00 2001 From: Asher Foa <1268088+asherf@users.noreply.github.com> Date: Thu, 28 Jul 2022 17:11:32 -0400 Subject: [PATCH 2/4] fix bug caught by new test --- .../python/dependency_inference/default_module_mapping.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 63d96c1ef17..d33f4d92437 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",), From 2577c7e2ff6da7251cbb2b7205ede6bb53eb0ddc Mon Sep 17 00:00:00 2001 From: Asher Foa <1268088+asherf@users.noreply.github.com> Date: Thu, 28 Jul 2022 17:12:16 -0400 Subject: [PATCH 3/4] fix bug caught by new test --- .../python/dependency_inference/default_module_mapping.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d33f4d92437..802a78d0c40 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 @@ -131,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 = { From 824c2eebf47d9ae2d5ebc557d9594e950ac494b3 Mon Sep 17 00:00:00 2001 From: Asher Foa <1268088+asherf@users.noreply.github.com> Date: Thu, 28 Jul 2022 17:13:16 -0400 Subject: [PATCH 4/4] more bugs --- .../dependency_inference/default_module_mapping.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 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 802a78d0c40..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 @@ -90,12 +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-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",),