ยปCore Development>Code coverage>Lib/lib2to3/fixes/fix_zip.py

Python code coverage for Lib/lib2to3/fixes/fix_zip.py

#countcontent
1n/a"""
2n/aFixer that changes zip(seq0, seq1, ...) into list(zip(seq0, seq1, ...)
3n/aunless there exists a 'from future_builtins import zip' statement in the
4n/atop-level namespace.
5n/a
6n/aWe avoid the transformation if the zip() call is directly contained in
7n/aiter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or for V in <>:.
8n/a"""
9n/a
10n/a# Local imports
11n/afrom .. import fixer_base
12n/afrom ..fixer_util import Name, Call, in_special_context
13n/a
14n/aclass FixZip(fixer_base.ConditionalFix):
15n/a
16n/a BM_compatible = True
17n/a PATTERN = """
18n/a power< 'zip' args=trailer< '(' [any] ')' >
19n/a >
20n/a """
21n/a
22n/a skip_on = "future_builtins.zip"
23n/a
24n/a def transform(self, node, results):
25n/a if self.should_skip(node):
26n/a return
27n/a
28n/a if in_special_context(node):
29n/a return None
30n/a
31n/a new = node.clone()
32n/a new.prefix = ""
33n/a new = Call(Name("list"), [new])
34n/a new.prefix = node.prefix
35n/a return new