@@ -529,24 +529,23 @@ def test_module_import_side_effect():
529
529
530
530
531
531
def test_public_modules_in_ddtrace_contrib ():
532
- # Ensures that public modules are not accidentally added to the integration API
532
+ # Ensures that public modules are not accidentally added to ddtrace.contrib
533
533
contrib_dir = Path (DDTRACE_PATH ) / "ddtrace" / "contrib"
534
534
535
535
public_modules = set ()
536
536
for directory , _ , file_names in os .walk (contrib_dir ):
537
537
relative_dir = Path (directory ).relative_to (contrib_dir )
538
- if "internal" in relative_dir .parts or any ([x .startswith ("_" ) for x in relative_dir .parts ]):
538
+ if "internal" in relative_dir .parts :
539
+ # ignore modules in ddtrace/contrib/internal
539
540
continue
540
541
541
- # Open files in ddtrace/contrib/ and check if the content matches the template
542
542
for file_name in file_names :
543
- # Skip internal and __init__ modules, as they are not supposed to have the deprecation template
544
- if file_name .endswith (".py" ) and not (file_name .startswith ("_" ) or file_name == "__init__.py" ):
545
- # Get the relative path of the file from ddtrace/contrib to the deprecated file (ex: pymongo/patch)
546
- relative_dir_with_file = relative_dir / file_name [:- 3 ] # Remove the .py extension
547
- # Convert the relative path to python module format (ex: [pymongo, patch] -> pymongo.patch)
548
- sub_modules = "." .join (relative_dir_with_file .parts )
549
- public_modules .add (f"ddtrace.contrib.{ sub_modules } " )
543
+ # Ignore private modules (python files prefixed with "_")
544
+ if file_name .endswith (".py" ) and not file_name .startswith ("_" ):
545
+ # Covert filename to a module name (ex: dd-trace-py/ddtrace/contrib/flask.py -> ddtrace.contrib.flask)
546
+ relative_dir_with_file = relative_dir / file_name [:- 3 ]
547
+ module_name = "ddtrace.contrib." + "." .join (relative_dir_with_file .parts )
548
+ public_modules .add (module_name )
550
549
551
550
# The following modules contain attributes that are exposed to ddtrace users. All other modules in ddtrace.contrib
552
551
# are internal.
0 commit comments