MCPcopy Create free account
hub / github.com/microsoft/debugpy / check_modules

Function check_modules

src/debugpy/_vendored/__init__.py:89–106  ·  view source on GitHub ↗

Verify that only vendored modules have been imported.

(project, match, root=None)

Source from the content-addressed store, hash-verified

87
88
89def check_modules(project, match, root=None):
90 """Verify that only vendored modules have been imported."""
91 if root is None:
92 root = project_root(project)
93 extensions = []
94 unvendored = {}
95 for modname, mod in list(sys.modules.items()):
96 if not match(modname, mod):
97 continue
98 try:
99 filename = getattr(mod, "__file__", None)
100 except: # In theory it's possible that any error is raised when accessing __file__
101 filename = None
102 if not filename: # extension module
103 extensions.append(modname)
104 elif not filename.startswith(root):
105 unvendored[modname] = filename
106 return unvendored, extensions
107
108
109@contextlib.contextmanager

Callers 1

force_pydevd.pyFile · 0.85

Calls 4

project_rootFunction · 0.85
matchFunction · 0.85
itemsMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…