Back to the room

Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works

Code Observatory / function

module_path_for

codeintel.parsers.python_parser.module_path_for

PINNED SOURCE Source and edges from the index at this commit. An execution appears only where one was recorded.

PHAROS at 975a38dMIT license

Around this symbol

Search all symbols

Loading

Called by (2)
SymbolFileResolved by
_module_path__init__.pythrough an import
parse_pythonpython_parser.pysame file
Inside (1)
SymbolFileResolved by
python_parserpython_parser.pysame file
codeintel.parsers.python_parser.module_path_forbackend/app/codeintel/parsers/python_parser.py, lines 16–34Open source
def module_path_for(path: str) -> str:    """``pkg/sub/mod.py`` -> ``pkg.sub.mod``; ``pkg/__init__.py`` -> ``pkg``.    A leading ``src/`` (the PyPA "src layout") is not part of the import    path: ``src/flask/app.py`` is ``flask.app``, which is also what other    files import, so call/import resolution can match it.    """    parts = path.split("/")    if len(parts) > 2 and parts[0] == "src":        parts = parts[1:]    last = parts[-1]    for suffix in (".pyi", ".py"):        if last.endswith(suffix):            last = last[: -len(suffix)]            break    parts[-1] = last    if parts[-1] == "__init__":        parts = parts[:-1]    return ".".join(p for p in parts if p)

What the index recorded

Signature
def module_path_for(path: str) -> str:
File
backend/app/codeintel/parsers/python_parser.py
Lines
16–34
Parser
python-ast
Git blob
63495bcda67d5742151d40ab76540e513f44e088
Call sites
4 named, 0 resolved, 4 left unlinked
Outside this subset
1 more edges reach code outside the graph shown here

Read it on GitHub at this commit