koatl 0.3.17__tar.gz → 0.3.19__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {koatl-0.3.17 → koatl-0.3.19}/Cargo.lock +1 -1
- {koatl-0.3.17 → koatl-0.3.19}/PKG-INFO +1 -1
- {koatl-0.3.17 → koatl-0.3.19}/koatl/Cargo.toml +1 -1
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/iter.tl +15 -5
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/placeholder.tl +5 -1
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/test_iterable.tl +16 -14
- {koatl-0.3.17 → koatl-0.3.19}/koatl-core/src/ast.rs +2 -1
- {koatl-0.3.17 → koatl-0.3.19}/koatl-core/src/inference.rs +1 -1
- {koatl-0.3.17 → koatl-0.3.19}/koatl-core/src/lift_cst.rs +2 -4
- {koatl-0.3.17 → koatl-0.3.19}/koatl-core/src/resolve_scopes.rs +7 -4
- {koatl-0.3.17 → koatl-0.3.19}/koatl-core/src/transform.rs +8 -18
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/iter.tl +15 -5
- {koatl-0.3.17 → koatl-0.3.19}/Cargo.toml +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/README.md +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/.github/workflows/CI.yml +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/.gitignore +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/LICENSE +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/README.md +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/__init__.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/__main__.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/cli.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/notebook/__init__.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/notebook/magic.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/prelude/__init__.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/runtime/__init__.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/runtime/meta_finder.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/runtime/record.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/runtime/vattr.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/__init__.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/control/__init__.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/control/async.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/control/base.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/control/do.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/control/env.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/control/memo.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/control/result.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/data/__init__.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/data/list.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/data/record.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/ext.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/io.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/json.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/lazy_module.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/pickle.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/re.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/python/koatl/std/trait.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/requirements.txt +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/src/emit_py.rs +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/src/lib.rs +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/conftest.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/arguments.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/containers.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/data.txt +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/decorators.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/destructure-for-and-fn.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/destructure.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/escape_ident.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/fstr.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/functions.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/generator.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/if_expr.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/imports.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/imports2.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/loops.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/match.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/nary-list.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/precedence.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/scopes.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/semantic_whitespace.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/short_circuit.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/base/with.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/prelude/async.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/prelude/aug_assign.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/prelude/coal.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/prelude/env.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/prelude/iterables.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/prelude/list.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/prelude/memo.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/prelude/record.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/prelude/result.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/prelude/slice.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/prelude/try.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/prelude/virtual.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/test_modules/module0.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/test_modules/module1.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/e2e/test_modules/module2.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/fail-parse/arguments_mixed_defaults.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/fail-parse/arguments_multiple_kwargs.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/fail-parse/arguments_multiple_kwonly_markers.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/fail-parse/arguments_multiple_posonly_markers.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/fail-parse/arguments_multiple_varargs.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/fail-parse/arguments_posonly_after_kwonly.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/fail-parse/arguments_vararg_and_kwonly_marker.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/fail-parse/unmatched_closing_delimiter.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/parse/arith.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/parse/assign.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/parse/block-comments.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/parse/deco.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/parse/func.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/parse/matches.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/parse/mutual-recursion.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/parse/numbers.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/parse/operators.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/test_e2e.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/test_parse.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/test_parse_fail.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/test_re.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl/tests/util/__init__.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl-core/Cargo.toml +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl-core/src/ast_builder.rs +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl-core/src/lib.rs +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl-core/src/main.rs +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl-core/src/py/ast.rs +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl-core/src/py/ast_builder.rs +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl-core/src/py/emit.rs +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl-core/src/py/mod.rs +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl-core/src/types.rs +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl-core/src/util.rs +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl-parser/Cargo.toml +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl-parser/src/cst.rs +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl-parser/src/lexer.rs +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl-parser/src/lib.rs +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl-parser/src/parser.rs +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/koatl-parser/src/simple_fmt.rs +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/pyproject.toml +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/__init__.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/__main__.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/cli.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/notebook/__init__.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/notebook/magic.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/prelude/__init__.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/runtime/__init__.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/runtime/meta_finder.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/runtime/record.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/runtime/vattr.py +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/__init__.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/control/__init__.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/control/async.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/control/base.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/control/do.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/control/env.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/control/memo.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/control/result.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/data/__init__.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/data/list.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/data/record.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/ext.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/io.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/json.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/lazy_module.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/pickle.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/re.tl +0 -0
- {koatl-0.3.17 → koatl-0.3.19}/python/koatl/std/trait.py +0 -0
|
@@ -84,16 +84,20 @@ export Iterable = class(Traversable, Trait):
|
|
|
84
84
|
|
|
85
85
|
impl()
|
|
86
86
|
|
|
87
|
-
flat_map = (self, f) =>
|
|
87
|
+
flat_map = (self, f=None) =>
|
|
88
|
+
if f === None:
|
|
89
|
+
itertools.chain.from_iterable(self.iter)
|
|
90
|
+
else:
|
|
91
|
+
itertools.chain.from_iterable(self.iter.map(f))
|
|
88
92
|
|
|
89
|
-
|
|
93
|
+
reversed = self => reversed(list(self.iter))
|
|
90
94
|
|
|
91
|
-
|
|
95
|
+
sorted = (self, key=None, reverse=False) =>
|
|
92
96
|
sorted(self.iter, key=key, reverse=reverse)
|
|
93
97
|
|
|
94
98
|
copy = self => itertools.tee(self.iter)
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
tally = (self, f=None) =>
|
|
97
101
|
let acc = 0
|
|
98
102
|
if f === None:
|
|
99
103
|
for _ in self:
|
|
@@ -187,7 +191,7 @@ export Iterable = class(Traversable, Trait):
|
|
|
187
191
|
impl()
|
|
188
192
|
|
|
189
193
|
join = (self, sep="") =>
|
|
190
|
-
sep.join(self.map(str))
|
|
194
|
+
sep.join(self.iter.map(str))
|
|
191
195
|
|
|
192
196
|
sum = self =>
|
|
193
197
|
let acc = 0
|
|
@@ -260,6 +264,12 @@ export Iterable = class(Traversable, Trait):
|
|
|
260
264
|
list = self =>
|
|
261
265
|
list(self.iter)
|
|
262
266
|
|
|
267
|
+
set = self =>
|
|
268
|
+
set(self.iter)
|
|
269
|
+
|
|
270
|
+
tuple = self =>
|
|
271
|
+
tuple(self.iter)
|
|
272
|
+
|
|
263
273
|
dict = self =>
|
|
264
274
|
dict(self.iter)
|
|
265
275
|
|
|
@@ -57,11 +57,14 @@ test_all = () =>
|
|
|
57
57
|
assert_eq([].all(x => x > 0), True)
|
|
58
58
|
assert_eq([True, True, True].all(x => x), True)
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
#
|
|
62
|
-
assert_eq([1, 2, 3, 4, 5].iter.
|
|
63
|
-
assert_eq([
|
|
64
|
-
assert_eq(
|
|
60
|
+
test_tally = () =>
|
|
61
|
+
# tally() works on Iterable trait via .iter
|
|
62
|
+
assert_eq([1, 2, 3, 4, 5].iter.tally(), 5)
|
|
63
|
+
assert_eq([].iter.tally(), 0)
|
|
64
|
+
assert_eq((..10).tally(), 10)
|
|
65
|
+
assert_eq([1, 2, 3, 4, 5].iter.tally(x => x > 2), 3)
|
|
66
|
+
assert_eq([1, 2, 3, 4, 5].iter.tally(x => x %% 2 == 0), 2)
|
|
67
|
+
assert_eq([1, 2, 3].iter.tally(x => x > 10), 0)
|
|
65
68
|
|
|
66
69
|
test_take = () =>
|
|
67
70
|
assert_eq([1, 2, 3, 4, 5].take(3).list(), [1, 2, 3])
|
|
@@ -104,16 +107,15 @@ test_cycle = () =>
|
|
|
104
107
|
assert_eq([1, 2, 3].cycle().take(7).list(), [1, 2, 3, 1, 2, 3, 1])
|
|
105
108
|
assert_eq([5].cycle().take(3).list(), [5, 5, 5])
|
|
106
109
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
assert_eq(list([1
|
|
110
|
-
assert_eq(list([
|
|
111
|
-
assert_eq(list([].iter.reverse()), [])
|
|
110
|
+
test_reversed = () =>
|
|
111
|
+
assert_eq(list([1, 2, 3, 4, 5].reversed()), [5, 4, 3, 2, 1])
|
|
112
|
+
assert_eq(list([1].reversed()), [1])
|
|
113
|
+
assert_eq(list([].reversed()), [])
|
|
112
114
|
|
|
113
|
-
|
|
114
|
-
assert_eq([3, 1, 4, 1, 5].iter.
|
|
115
|
-
assert_eq(["c", "a", "b"].iter.
|
|
116
|
-
assert_eq([].iter.
|
|
115
|
+
test_sorted = () =>
|
|
116
|
+
assert_eq([3, 1, 4, 1, 5].iter.sorted().list(), [1, 1, 3, 4, 5])
|
|
117
|
+
assert_eq(["c", "a", "b"].iter.sorted().list(), ["a", "b", "c"])
|
|
118
|
+
assert_eq([].iter.sorted().list(), [])
|
|
117
119
|
|
|
118
120
|
test_join = () =>
|
|
119
121
|
assert_eq(["a", "b", "c"].join(", "), "a, b, c")
|
|
@@ -186,15 +186,16 @@ pub enum Expr<'a, TTree: Tree> {
|
|
|
186
186
|
Call(TTree::Expr, Vec<CallItem<'a, TTree>>),
|
|
187
187
|
Subscript(TTree::Expr, Vec<ListItem<TTree>>),
|
|
188
188
|
RawAttribute(TTree::Expr, SIdent<'a>),
|
|
189
|
+
ScopedAttribute(TTree::Expr, TTree::Expr),
|
|
189
190
|
Attribute(TTree::Expr, SIdent<'a>),
|
|
190
191
|
MaybeAttribute(TTree::Expr, SIdent<'a>),
|
|
191
192
|
|
|
192
193
|
MappedCall(TTree::Expr, Vec<CallItem<'a, TTree>>),
|
|
193
194
|
MappedSubscript(TTree::Expr, Vec<ListItem<TTree>>),
|
|
194
195
|
MappedRawAttribute(TTree::Expr, SIdent<'a>),
|
|
196
|
+
MappedScopedAttribute(TTree::Expr, TTree::Expr),
|
|
195
197
|
MappedAttribute(TTree::Expr, SIdent<'a>),
|
|
196
198
|
MappedMaybeAttribute(TTree::Expr, SIdent<'a>),
|
|
197
|
-
CallNullable(TTree::Expr, TTree::Expr),
|
|
198
199
|
|
|
199
200
|
Try(TTree::Expr, Vec<MatchCase<TTree>>, Option<TTree::Expr>),
|
|
200
201
|
Checked(TTree::Expr, Option<TTree::Pattern>),
|
|
@@ -235,7 +235,7 @@ impl<'src, 'ast> SExprExt<'src, 'ast> for Indirect<SExpr<'src>> {
|
|
|
235
235
|
expr.traverse(ctx);
|
|
236
236
|
Type::Any
|
|
237
237
|
}
|
|
238
|
-
Expr::
|
|
238
|
+
Expr::ScopedAttribute(expr, func) | Expr::MappedScopedAttribute(expr, func) => {
|
|
239
239
|
expr.traverse(ctx);
|
|
240
240
|
func.traverse(ctx);
|
|
241
241
|
Type::Any
|
|
@@ -379,11 +379,9 @@ impl<'src, 'tok> Lift<Indirect<ast::SExpr<'src>>> for cst::SExpr<'src, 'tok> {
|
|
|
379
379
|
..
|
|
380
380
|
} => {
|
|
381
381
|
if question.is_some() {
|
|
382
|
-
ast::Expr::
|
|
382
|
+
ast::Expr::MappedScopedAttribute(expr.lift(), rhs.lift())
|
|
383
383
|
} else {
|
|
384
|
-
|
|
385
|
-
let arg = ast::CallItem::Arg(expr.lift());
|
|
386
|
-
ast::Expr::Call(func, vec![arg])
|
|
384
|
+
ast::Expr::ScopedAttribute(expr.lift(), rhs.lift())
|
|
387
385
|
}
|
|
388
386
|
}
|
|
389
387
|
cst::Expr::Decorated {
|
|
@@ -1442,14 +1442,14 @@ impl<'src> SExprExt<'src> for Indirect<SExpr<'src>> {
|
|
|
1442
1442
|
|
|
1443
1443
|
return traversed;
|
|
1444
1444
|
}
|
|
1445
|
-
Expr::
|
|
1446
|
-
Expr::
|
|
1445
|
+
Expr::ScopedAttribute(expr, value) => {
|
|
1446
|
+
Expr::ScopedAttribute(expr.traverse(state), value.traverse_guarded(state))
|
|
1447
1447
|
}
|
|
1448
|
-
Expr::
|
|
1448
|
+
Expr::MappedScopedAttribute(expr, value) => {
|
|
1449
1449
|
let (rhs, fn_ctx) =
|
|
1450
1450
|
with_phantom_fninfo(state, span, |state| value.traverse_guarded(state));
|
|
1451
1451
|
|
|
1452
|
-
let traversed = Expr::
|
|
1452
|
+
let traversed = Expr::MappedScopedAttribute(expr.traverse(state), rhs)
|
|
1453
1453
|
.spanned(span)
|
|
1454
1454
|
.indirect();
|
|
1455
1455
|
|
|
@@ -1459,6 +1459,9 @@ impl<'src> SExprExt<'src> for Indirect<SExpr<'src>> {
|
|
|
1459
1459
|
|
|
1460
1460
|
return traversed;
|
|
1461
1461
|
}
|
|
1462
|
+
Expr::Call(a, items) => {
|
|
1463
|
+
Expr::Call(a.traverse(state), traverse_call_items(state, items))
|
|
1464
|
+
}
|
|
1462
1465
|
Expr::MappedCall(a, call_items) => {
|
|
1463
1466
|
let (rhs, fn_ctx) = with_phantom_fninfo(state, span, |state| {
|
|
1464
1467
|
traverse_call_items(state, call_items)
|
|
@@ -1425,11 +1425,13 @@ fn transform_postfix_expr<'src, 'ast>(
|
|
|
1425
1425
|
Expr::RawAttribute(obj, _) => (false, obj),
|
|
1426
1426
|
Expr::Subscript(obj, _) => (false, obj),
|
|
1427
1427
|
Expr::Call(obj, _) => (false, obj),
|
|
1428
|
+
Expr::ScopedAttribute(obj, _) => (false, obj),
|
|
1428
1429
|
Expr::Attribute(obj, _) => (false, obj),
|
|
1429
1430
|
Expr::MaybeAttribute(obj, _) => (false, obj),
|
|
1430
1431
|
Expr::MappedRawAttribute(obj, _) => (true, obj),
|
|
1431
1432
|
Expr::MappedSubscript(obj, _) => (true, obj),
|
|
1432
1433
|
Expr::MappedCall(obj, _) => (true, obj),
|
|
1434
|
+
Expr::MappedScopedAttribute(obj, _) => (true, obj),
|
|
1433
1435
|
Expr::MappedAttribute(obj, _) => (true, obj),
|
|
1434
1436
|
Expr::MappedMaybeAttribute(obj, _) => (true, obj),
|
|
1435
1437
|
_ => {
|
|
@@ -1460,6 +1462,10 @@ fn transform_postfix_expr<'src, 'ast>(
|
|
|
1460
1462
|
let t = inner_pre.bind(transform_subscript_items(ctx, &list, &expr.span)?);
|
|
1461
1463
|
a.subscript(lhs, t, access_ctx)
|
|
1462
1464
|
}
|
|
1465
|
+
Expr::ScopedAttribute(_, rhs) | Expr::MappedScopedAttribute(_, rhs) => {
|
|
1466
|
+
let t = inner_pre.bind(rhs.transform(ctx)?);
|
|
1467
|
+
a.call(t, vec![PyCallItem::Arg(lhs)])
|
|
1468
|
+
}
|
|
1463
1469
|
Expr::RawAttribute(_, attr) | Expr::MappedRawAttribute(_, attr) => {
|
|
1464
1470
|
a.attribute(lhs, attr.value.escape(), access_ctx)
|
|
1465
1471
|
}
|
|
@@ -2025,30 +2031,14 @@ impl<'src, 'ast> SExprExt<'src, 'ast> for SExpr<'src> {
|
|
|
2025
2031
|
| Expr::MappedCall(..)
|
|
2026
2032
|
| Expr::Subscript(..)
|
|
2027
2033
|
| Expr::MappedSubscript(..)
|
|
2034
|
+
| Expr::ScopedAttribute(..)
|
|
2035
|
+
| Expr::MappedScopedAttribute(..)
|
|
2028
2036
|
| Expr::Attribute(..)
|
|
2029
2037
|
| Expr::MappedAttribute(..)
|
|
2030
2038
|
| Expr::MaybeAttribute(..)
|
|
2031
2039
|
| Expr::MappedMaybeAttribute(..) => {
|
|
2032
2040
|
pre.bind(transform_postfix_expr(ctx, self, access_ctx)?)
|
|
2033
2041
|
}
|
|
2034
|
-
Expr::CallNullable(obj, func) => {
|
|
2035
|
-
let a = PyAstBuilder::new(span);
|
|
2036
|
-
let obj_transformed = pre.bind(obj.transform(ctx)?);
|
|
2037
|
-
let func_transformed = pre.bind(func.transform(ctx)?);
|
|
2038
|
-
|
|
2039
|
-
let maparg = ctx.create_aux_var("maparg", span.start);
|
|
2040
|
-
|
|
2041
|
-
a.call(
|
|
2042
|
-
a.tl_builtin("op_map"),
|
|
2043
|
-
vec![
|
|
2044
|
-
a.call_arg(obj_transformed),
|
|
2045
|
-
a.call_arg(a.lambda(
|
|
2046
|
-
PyArgList::simple_args(vec![(maparg.clone().into(), None)]),
|
|
2047
|
-
a.call(func_transformed, vec![a.call_arg(a.load_ident(maparg))]),
|
|
2048
|
-
)),
|
|
2049
|
-
],
|
|
2050
|
-
)
|
|
2051
|
-
}
|
|
2052
2042
|
Expr::With(pattern, value, body) => {
|
|
2053
2043
|
let temp_var = ctx.create_aux_var("with", span.start);
|
|
2054
2044
|
let value = pre.bind(value.transform(ctx)?);
|
|
@@ -84,16 +84,20 @@ export Iterable = class(Traversable, Trait):
|
|
|
84
84
|
|
|
85
85
|
impl()
|
|
86
86
|
|
|
87
|
-
flat_map = (self, f) =>
|
|
87
|
+
flat_map = (self, f=None) =>
|
|
88
|
+
if f === None:
|
|
89
|
+
itertools.chain.from_iterable(self.iter)
|
|
90
|
+
else:
|
|
91
|
+
itertools.chain.from_iterable(self.iter.map(f))
|
|
88
92
|
|
|
89
|
-
|
|
93
|
+
reversed = self => reversed(list(self.iter))
|
|
90
94
|
|
|
91
|
-
|
|
95
|
+
sorted = (self, key=None, reverse=False) =>
|
|
92
96
|
sorted(self.iter, key=key, reverse=reverse)
|
|
93
97
|
|
|
94
98
|
copy = self => itertools.tee(self.iter)
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
tally = (self, f=None) =>
|
|
97
101
|
let acc = 0
|
|
98
102
|
if f === None:
|
|
99
103
|
for _ in self:
|
|
@@ -187,7 +191,7 @@ export Iterable = class(Traversable, Trait):
|
|
|
187
191
|
impl()
|
|
188
192
|
|
|
189
193
|
join = (self, sep="") =>
|
|
190
|
-
sep.join(self.map(str))
|
|
194
|
+
sep.join(self.iter.map(str))
|
|
191
195
|
|
|
192
196
|
sum = self =>
|
|
193
197
|
let acc = 0
|
|
@@ -260,6 +264,12 @@ export Iterable = class(Traversable, Trait):
|
|
|
260
264
|
list = self =>
|
|
261
265
|
list(self.iter)
|
|
262
266
|
|
|
267
|
+
set = self =>
|
|
268
|
+
set(self.iter)
|
|
269
|
+
|
|
270
|
+
tuple = self =>
|
|
271
|
+
tuple(self.iter)
|
|
272
|
+
|
|
263
273
|
dict = self =>
|
|
264
274
|
dict(self.iter)
|
|
265
275
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|