Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit be923fb

Browse files
authored
Removal of the RedBaron repository from experimental/search/symbol_search module (#146)
* experimental/symbol_search changes. * Revert "experimental/symbol_search changes." This reverts commit 5919aff. * Revert "Revert "experimental/symbol_search changes."" This reverts commit fdb7d06.
1 parent d15d51c commit be923fb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

automata/experimental/search/symbol_search.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from ast import unparse as pyast_unparse
12
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union, cast
23

34
import numpy as np
@@ -111,11 +112,13 @@ def process_query(
111112
def _find_pattern_in_modules(self, pattern: str) -> Dict[str, List[int]]:
112113
"""Finds exact line matches for a given pattern string in all modules."""
113114
matches = {}
114-
for module_path, module in cast(
115-
Iterable[Tuple[str, Optional[RedBaron]]], py_module_loader.items()
116-
):
115+
for module_path, module in py_module_loader.items():
116+
print("Checking module = ", module)
117117
if module:
118-
lines = module.dumps().splitlines()
118+
if isinstance(module, RedBaron):
119+
lines = module.dumps().splitlines()
120+
else:
121+
lines = pyast_unparse(module).splitlines()
119122
line_numbers = [i + 1 for i, line in enumerate(lines) if pattern in line.strip()]
120123
if line_numbers:
121124
matches[module_path] = line_numbers

0 commit comments

Comments
 (0)