MCPcopy
hub / github.com/python/mypy / _module_symbol_table

Function _module_symbol_table

mypy/stubtest.py:331–345  ·  view source on GitHub ↗

Retrieve the symbol table for the module (or None on failure). 1) Use inspect to retrieve the source code of the module 2) Use symtable to parse the source (and use what symtable knows for its purposes)

(runtime: types.ModuleType)

Source from the content-addressed store, hash-verified

329
330@functools.lru_cache
331def _module_symbol_table(runtime: types.ModuleType) -> symtable.SymbolTable | None:
332 """Retrieve the symbol table for the module (or None on failure).
333
334 1) Use inspect to retrieve the source code of the module
335 2) Use symtable to parse the source (and use what symtable knows for its purposes)
336 """
337 try:
338 source = inspect.getsource(runtime)
339 except (OSError, TypeError, SyntaxError):
340 return None
341
342 try:
343 return symtable.symtable(source, runtime.__name__, "exec")
344 except SyntaxError:
345 return None
346
347
348@verify.register(nodes.MypyFile)

Callers 1

_belongs_to_runtimeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…