Read about our upcoming Code of Conduct on this issue

Commit a027f0c1 authored by Pierre Augier's avatar Pierre Augier
Browse files

Fix incompatibility between extast and beniget

parent 27451389bb9d
from pathlib import Path
import gast as ast
import beniget
from transonic.analyses import beniget
from transonic.analyses.util import (
......
......@@ -16,7 +16,7 @@
from pprint import pformat
import gast as ast
import beniget
from transonic.analyses import beniget
from transonic.log import logger
from transonic.config import backend_default
......
import gast as ast
from beniget import Ancestors, DefUseChains as DUC, UseDefChains
from beniget.beniget import Def
__all__ = ["Ancestors", "DefUseChains", "UseDefChains"]
class DefUseChains(DUC):
def visit_List(self, node):
if isinstance(node.ctx, ast.Load):
dnode = self.chains.setdefault(node, Def(node))
for elt in node.elts:
if isinstance(elt, CommentLine):
continue
self.visit(elt).add_user(dnode)
return dnode
# unfortunately, destructured node are marked as Load,
# only the parent List/Tuple is marked as Store
elif isinstance(node.ctx, ast.Store):
return self.visit_Destructured(node)
visit_Tuple = visit_List
# this import has to be after the definition of DefUseChains
from transonic.analyses.extast import CommentLine # noqa: E402
......@@ -4,7 +4,6 @@
"""
import gast as ast
import beniget
from transonic.analyses import extast
from transonic.analyses.util import gather_rawcode_comments
......
......@@ -3,8 +3,8 @@
"""
import gast as ast
import beniget
from transonic.analyses import beniget
from transonic.analyses import extast
......
......@@ -4,12 +4,12 @@
"""
from io import StringIO
from copy import deepcopy
import gast as ast
import astunparse
from copy import deepcopy
import beniget
from transonic.analyses import beniget
class CommentLine(ast.AST):
......
......@@ -6,10 +6,10 @@ import re
from pathlib import Path
from textwrap import dedent
import beniget
import gast as ast
import astunparse
from transonic.analyses import beniget
from transonic.analyses import extast
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment