Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works
Code Observatory / function
parse_python
codeintel.parsers.python_parser.parse_python
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 symbolsLoading
| Symbol | File | Resolved by |
|---|---|---|
| ParseResult | base.py | through an import |
| Symbol | base.py | through an import |
| _docstring | python_parser.py | same file |
| _Extractor | python_parser.py | same file |
| module_path_for | python_parser.py | same file |
| Symbol | File | Resolved by |
|---|---|---|
| parse_file | __init__.py | through an import |
| Symbol | File | Resolved by |
|---|---|---|
| python_parser | python_parser.py | same file |
codeintel.parsers.python_parser.parse_pythonbackend/app/codeintel/parsers/python_parser.py, lines 195–225Open source
def parse_python(path: str, source: str) -> ParseResult | None: """Parse a Python file. Returns None on a syntax error (caller falls back).""" try: tree = ast.parse(source, filename=path, type_comments=False) except (SyntaxError, ValueError): return None module_path = module_path_for(path) line_count = max(1, source.count("\n") + (0 if source.endswith("\n") else 1)) module = Symbol( name=module_path.rsplit(".", 1)[-1] or path, qualified_name=module_path, kind="module", start_line=1, end_line=line_count, signature=f"module {module_path or path}", docstring=_docstring(tree), ) extractor = _Extractor(module, module_path, path.endswith("__init__.py")) for stmt in tree.body: extractor.visit(stmt) # De-duplicate imports, preserving order. imports = list(dict.fromkeys(extractor.imports)) return ParseResult( language="python", parser="python-ast", symbols=extractor.symbols, imports=imports, import_map=extractor.import_map, )What the index recorded
- Signature
def parse_python(path: str, source: str) -> ParseResult | None:- File
backend/app/codeintel/parsers/python_parser.py- Lines
- 195–225
- Parser
- python-ast
- Git blob
63495bcda67d5742151d40ab76540e513f44e088- Call sites
- 13 named, 5 resolved, 8 left unlinked
