Skip to content

Commit 8cf5c9c

Browse files
Minimal frilouz integration
Use frilouz to support Python input with syntax errors. This is mostly aimed at editor integration to support fast on-the-fly analysis of code being typed.
1 parent 0a6dbea commit 8cf5c9c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

memestra/memestra.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from memestra.caching import Cache, CacheKeyFactory, RecursiveCacheKeyFactory
1010
from memestra.caching import Format
1111
from memestra.utils import resolve_module
12+
import frilouz
1213

1314
_defs = ast.AsyncFunctionDef, ast.ClassDef, ast.FunctionDef
1415

@@ -130,7 +131,7 @@ def load_deprecated_from_module(self, module_name, level=None):
130131

131132
with open(module_path) as fd:
132133
try:
133-
module = ast.parse(fd.read())
134+
module, syntax_errors = frilouz.parse(ast.parse, fd.read())
134135
except UnicodeDecodeError:
135136
return []
136137
duc = SilentDefUseChains()
@@ -417,7 +418,7 @@ def memestra(file_descriptor, decorator, reason_keyword,
417418
assert not isinstance(decorator, str) and \
418419
len(decorator) > 1, "decorator is at least (module, attribute)"
419420

420-
module = ast.parse(file_descriptor.read())
421+
module, syntax_errors = frilouz.parse(ast.parse, file_descriptor.read())
421422
# Collect deprecated functions
422423
resolver = ImportResolver(decorator, reason_keyword, search_paths,
423424
recursive, cache_dir=cache_dir)

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ beniget
33
nbformat
44
nbconvert
55
pyyaml
6+
frilouz

0 commit comments

Comments
 (0)