coconut-develop 3.0.0a0.dev12__tar.gz → 3.0.0a0.dev14__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.
Files changed (83) hide show
  1. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/PKG-INFO +8 -8
  2. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/__coconut__/__init__.pyi +36 -36
  3. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/compiler/compiler.py +12 -8
  4. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/compiler/header.py +2 -1
  5. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/compiler/templates/header.py_template +3 -3
  6. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/icoconut/coconut/kernel.json +3 -3
  7. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/root.py +20 -19
  8. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/cocotest/agnostic/primary.coco +3 -0
  9. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/cocotest/agnostic/suite.coco +1 -0
  10. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/cocotest/agnostic/util.coco +10 -1
  11. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/extras.coco +2 -2
  12. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/CONTRIBUTING.md +0 -0
  13. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/DOCS.md +0 -0
  14. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/FAQ.md +0 -0
  15. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/HELP.md +0 -0
  16. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/LICENSE.txt +0 -0
  17. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/MANIFEST.in +0 -0
  18. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/README.rst +0 -0
  19. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/__coconut__/__init__.py +0 -0
  20. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/__coconut__/py.typed +0 -0
  21. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/_coconut/__init__.py +0 -0
  22. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/_coconut/__init__.pyi +0 -0
  23. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/_coconut/py.typed +0 -0
  24. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/__coconut__.py +0 -0
  25. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/__coconut__.pyi +0 -0
  26. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/__init__.py +0 -0
  27. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/__init__.pyi +0 -0
  28. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/__main__.py +0 -0
  29. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/_pyparsing.py +0 -0
  30. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/command/__init__.py +0 -0
  31. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/command/__init__.pyi +0 -0
  32. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/command/cli.py +0 -0
  33. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/command/command.py +0 -0
  34. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/command/command.pyi +0 -0
  35. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/command/mypy.py +0 -0
  36. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/command/resources/zcoconut.pth +0 -0
  37. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/command/util.py +0 -0
  38. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/command/watch.py +0 -0
  39. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/compiler/__init__.py +0 -0
  40. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/compiler/grammar.py +0 -0
  41. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/compiler/matching.py +0 -0
  42. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/compiler/util.py +0 -0
  43. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/constants.py +0 -0
  44. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/convenience.py +0 -0
  45. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/convenience.pyi +0 -0
  46. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/exceptions.py +0 -0
  47. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/highlighter.py +0 -0
  48. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/icoconut/__init__.py +0 -0
  49. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/icoconut/__main__.py +0 -0
  50. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/icoconut/coconut_py/kernel.json +0 -0
  51. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/icoconut/coconut_py2/kernel.json +0 -0
  52. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/icoconut/coconut_py3/kernel.json +0 -0
  53. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/icoconut/embed.py +0 -0
  54. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/icoconut/root.py +0 -0
  55. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/integrations.py +0 -0
  56. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/main.py +0 -0
  57. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/py.typed +0 -0
  58. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/requirements.py +0 -0
  59. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/terminal.py +0 -0
  60. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/__init__.py +0 -0
  61. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/__main__.py +0 -0
  62. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/constants_test.py +0 -0
  63. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/main_test.py +0 -0
  64. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/cocotest/agnostic/__init__.coco +0 -0
  65. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/cocotest/agnostic/main.coco +0 -0
  66. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/cocotest/agnostic/specific.coco +0 -0
  67. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/cocotest/agnostic/tutorial.coco +0 -0
  68. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/cocotest/non_strict/non_strict_test.coco +0 -0
  69. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/cocotest/target_2/py2_test.coco +0 -0
  70. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/cocotest/target_3/py3_test.coco +0 -0
  71. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/cocotest/target_35/py35_test.coco +0 -0
  72. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/cocotest/target_36/py36_test.coco +0 -0
  73. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/cocotest/target_38/py38_test.coco +0 -0
  74. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/cocotest/target_sys/target_sys_test.coco +0 -0
  75. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/runnable.coco +0 -0
  76. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/tests/src/runner.coco +0 -0
  77. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut/util.py +0 -0
  78. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/coconut_develop.egg-info/SOURCES.txt +0 -0
  79. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/conf.py +0 -0
  80. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/pyproject.toml +0 -0
  81. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/setup.cfg +0 -0
  82. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/setup.py +0 -0
  83. {coconut-develop-3.0.0a0.dev12 → coconut-develop-3.0.0a0.dev14}/xontrib/coconut.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: coconut-develop
3
- Version: 3.0.0a0.dev12
3
+ Version: 3.0.0a0.dev14
4
4
  Summary: Simple, elegant, Pythonic functional programming.
5
5
  Home-page: http://coconut-lang.org
6
6
  Author: Evan Hubinger
@@ -125,14 +125,14 @@ Classifier: Framework :: IPython
125
125
  Classifier: Framework :: Jupyter
126
126
  Classifier: Typing :: Typed
127
127
  Provides-Extra: kernel
128
- Provides-Extra: watch
129
- Provides-Extra: jobs
130
- Provides-Extra: mypy
131
- Provides-Extra: backports
132
- Provides-Extra: xonsh
133
- Provides-Extra: jupyter
134
128
  Provides-Extra: all
135
- Provides-Extra: ipython
129
+ Provides-Extra: mypy
130
+ Provides-Extra: jobs
136
131
  Provides-Extra: docs
132
+ Provides-Extra: xonsh
133
+ Provides-Extra: watch
137
134
  Provides-Extra: tests
135
+ Provides-Extra: backports
138
136
  Provides-Extra: dev
137
+ Provides-Extra: ipython
138
+ Provides-Extra: jupyter
@@ -1108,16 +1108,16 @@ class _coconut_lifted_1(_t.Generic[_T, _W]):
1108
1108
  # self,
1109
1109
  # _g: _t.Callable[[_X], _T],
1110
1110
  # ) -> _t.Callable[[_X], _W]: ...
1111
- @_t.overload
1112
- def __call__(
1113
- self,
1114
- _g: _t.Callable[[_X, _Y], _T],
1115
- ) -> _t.Callable[[_X, _Y], _W]: ...
1116
- @_t.overload
1117
- def __call__(
1118
- self,
1119
- _g: _t.Callable[[_X, _Y, _Z], _T],
1120
- ) -> _t.Callable[[_X, _Y, _Z], _W]: ...
1111
+ # @_t.overload
1112
+ # def __call__(
1113
+ # self,
1114
+ # _g: _t.Callable[[_X, _Y], _T],
1115
+ # ) -> _t.Callable[[_X, _Y], _W]: ...
1116
+ # @_t.overload
1117
+ # def __call__(
1118
+ # self,
1119
+ # _g: _t.Callable[[_X, _Y, _Z], _T],
1120
+ # ) -> _t.Callable[[_X, _Y, _Z], _W]: ...
1121
1121
  @_t.overload
1122
1122
  def __call__(
1123
1123
  self,
@@ -1142,18 +1142,18 @@ class _coconut_lifted_2(_t.Generic[_T, _U, _W]):
1142
1142
  # _g: _t.Callable[[_X], _T],
1143
1143
  # _h: _t.Callable[[_X], _U],
1144
1144
  # ) -> _t.Callable[[_X], _W]: ...
1145
- @_t.overload
1146
- def __call__(
1147
- self,
1148
- _g: _t.Callable[[_X, _Y], _T],
1149
- _h: _t.Callable[[_X, _Y], _U],
1150
- ) -> _t.Callable[[_X, _Y], _W]: ...
1151
- @_t.overload
1152
- def __call__(
1153
- self,
1154
- _g: _t.Callable[[_X, _Y, _Z], _T],
1155
- _h: _t.Callable[[_X, _Y, _Z], _U],
1156
- ) -> _t.Callable[[_X, _Y, _Z], _W]: ...
1145
+ # @_t.overload
1146
+ # def __call__(
1147
+ # self,
1148
+ # _g: _t.Callable[[_X, _Y], _T],
1149
+ # _h: _t.Callable[[_X, _Y], _U],
1150
+ # ) -> _t.Callable[[_X, _Y], _W]: ...
1151
+ # @_t.overload
1152
+ # def __call__(
1153
+ # self,
1154
+ # _g: _t.Callable[[_X, _Y, _Z], _T],
1155
+ # _h: _t.Callable[[_X, _Y, _Z], _U],
1156
+ # ) -> _t.Callable[[_X, _Y, _Z], _W]: ...
1157
1157
  @_t.overload
1158
1158
  def __call__(
1159
1159
  self,
@@ -1182,20 +1182,20 @@ class _coconut_lifted_3(_t.Generic[_T, _U, _V, _W]):
1182
1182
  # _h: _t.Callable[[_X], _U],
1183
1183
  # _i: _t.Callable[[_X], _V],
1184
1184
  # ) -> _t.Callable[[_X], _W]: ...
1185
- @_t.overload
1186
- def __call__(
1187
- self,
1188
- _g: _t.Callable[[_X, _Y], _T],
1189
- _h: _t.Callable[[_X, _Y], _U],
1190
- _i: _t.Callable[[_X, _Y], _V],
1191
- ) -> _t.Callable[[_X, _Y], _W]: ...
1192
- @_t.overload
1193
- def __call__(
1194
- self,
1195
- _g: _t.Callable[[_X, _Y, _Z], _T],
1196
- _h: _t.Callable[[_X, _Y, _Z], _U],
1197
- _i: _t.Callable[[_X, _Y, _Z], _V],
1198
- ) -> _t.Callable[[_X, _Y, _Z], _W]: ...
1185
+ # @_t.overload
1186
+ # def __call__(
1187
+ # self,
1188
+ # _g: _t.Callable[[_X, _Y], _T],
1189
+ # _h: _t.Callable[[_X, _Y], _U],
1190
+ # _i: _t.Callable[[_X, _Y], _V],
1191
+ # ) -> _t.Callable[[_X, _Y], _W]: ...
1192
+ # @_t.overload
1193
+ # def __call__(
1194
+ # self,
1195
+ # _g: _t.Callable[[_X, _Y, _Z], _T],
1196
+ # _h: _t.Callable[[_X, _Y, _Z], _U],
1197
+ # _i: _t.Callable[[_X, _Y, _Z], _V],
1198
+ # ) -> _t.Callable[[_X, _Y, _Z], _W]: ...
1199
1199
  @_t.overload
1200
1200
  def __call__(
1201
1201
  self,
@@ -3685,22 +3685,26 @@ __annotations__["{name}"] = {annotation}
3685
3685
  """Handle non-comprehension list literals."""
3686
3686
  return self.testlist_star_expr_handle(original, loc, tokens, is_list=True)
3687
3687
 
3688
+ def make_dict(self, tok_grp):
3689
+ """Construct a dictionary literal out of the given group."""
3690
+ if self.target_info >= (3, 7):
3691
+ return "{" + join_dict_group(tok_grp) + "}"
3692
+ else:
3693
+ return "_coconut.dict((" + join_dict_group(tok_grp, as_tuples=True) + "))"
3694
+
3688
3695
  def dict_literal_handle(self, tokens):
3689
3696
  """Handle {**d1, **d2}."""
3690
3697
  if not tokens:
3691
- return "{}" if self.target.startswith("3") else "_coconut.dict()"
3698
+ return "{}" if self.target_info >= (3, 7) else "_coconut.dict()"
3692
3699
 
3693
3700
  groups, has_star, _ = split_star_expr_tokens(tokens, is_dict=True)
3694
3701
 
3695
3702
  if not has_star:
3696
3703
  internal_assert(len(groups) == 1, "dict_literal group splitting failed on", tokens)
3697
- if self.target.startswith("3"):
3698
- return "{" + join_dict_group(groups[0]) + "}"
3699
- else:
3700
- return "_coconut.dict((" + join_dict_group(groups[0], as_tuples=True) + "))"
3704
+ return self.make_dict(groups[0])
3701
3705
 
3702
- # naturally supported on 3.5+
3703
- elif self.target_info >= (3, 5):
3706
+ # supported on 3.5, but only guaranteed to be ordered on 3.7
3707
+ elif self.target_info >= (3, 7):
3704
3708
  to_literal = []
3705
3709
  for g in groups:
3706
3710
  if isinstance(g, list):
@@ -3714,7 +3718,7 @@ __annotations__["{name}"] = {annotation}
3714
3718
  to_merge = []
3715
3719
  for g in groups:
3716
3720
  if isinstance(g, list):
3717
- to_merge.append("{" + join_dict_group(g) + "}")
3721
+ to_merge.append(self.make_dict(g))
3718
3722
  else:
3719
3723
  to_merge.append(g)
3720
3724
  return "_coconut_dict_merge(" + ", ".join(to_merge) + ")"
@@ -208,7 +208,8 @@ def process_header_args(which, use_hash, target, no_tco, strict, no_wrap):
208
208
 
209
209
  format_dict = dict(
210
210
  COMMENT=COMMENT,
211
- empty_dict="{}" if target_startswith == "3" else "_coconut.dict()",
211
+ empty_dict="{}" if target_info >= (3, 7) else "_coconut.dict()",
212
+ empty_py_dict="{}" if target_info >= (3, 7) else "_coconut_py_dict()",
212
213
  lbrace="{",
213
214
  rbrace="}",
214
215
  is_data_var=is_data_var,
@@ -58,7 +58,7 @@ def _coconut_handle_cls_kwargs(**kwargs):
58
58
  return coconut_handle_cls_kwargs_wrapper
59
59
  def _coconut_handle_cls_stargs(*args):
60
60
  temp_names = ["_coconut_base_cls_%s" % (i,) for i in _coconut.range(_coconut.len(args))]
61
- ns = _coconut.dict(_coconut.zip(temp_names, args))
61
+ ns = _coconut_py_dict(_coconut.zip(temp_names, args))
62
62
  _coconut_exec("class _coconut_cls_stargs_base(" + ", ".join(temp_names) + "): pass", ns)
63
63
  return ns["_coconut_cls_stargs_base"]
64
64
  class _coconut_baseclass{object}:
@@ -1259,7 +1259,7 @@ def _coconut_get_function_match_error():
1259
1259
  class _coconut_base_pattern_func(_coconut_baseclass):{COMMENT.no_slots_to_allow_func_attrs}
1260
1260
  _coconut_is_match = True
1261
1261
  def __init__(self, *funcs):
1262
- self.FunctionMatchError = _coconut.type(_coconut_py_str("MatchError"), ({_coconut_}MatchError,), {empty_dict})
1262
+ self.FunctionMatchError = _coconut.type(_coconut_py_str("MatchError"), ({_coconut_}MatchError,), {empty_py_dict})
1263
1263
  self.patterns = []
1264
1264
  self.__doc__ = None
1265
1265
  self.__name__ = None
@@ -1707,7 +1707,7 @@ class _coconut_lifted(_coconut_baseclass):
1707
1707
  def __reduce__(self):
1708
1708
  return (self.__class__, (self.func,) + self.func_args, {lbrace}"func_kwargs": self.func_kwargs{rbrace})
1709
1709
  def __call__(self, *args, **kwargs):
1710
- return self.func(*(g(*args, **kwargs) for g in self.func_args), **_coconut.dict((k, h(*args, **kwargs)) for k, h in self.func_kwargs.items()))
1710
+ return self.func(*(g(*args, **kwargs) for g in self.func_args), **_coconut_py_dict((k, h(*args, **kwargs)) for k, h in self.func_kwargs.items()))
1711
1711
  def __repr__(self):
1712
1712
  return "lift(%r)(%s%s)" % (self.func, ", ".join(_coconut.repr(g) for g in self.func_args), ", ".join(k + "=" + _coconut.repr(h) for k, h in self.func_kwargs.items()))
1713
1713
  class lift(_coconut_baseclass):
@@ -1,11 +1,11 @@
1
1
  {
2
+ "display_name": "Coconut",
3
+ "language": "coconut",
2
4
  "argv": [
3
5
  "python",
4
6
  "-m",
5
7
  "coconut.icoconut",
6
8
  "-f",
7
9
  "{connection_file}"
8
- ],
9
- "display_name": "Coconut",
10
- "language": "coconut"
10
+ ]
11
11
  }
@@ -26,7 +26,7 @@ import sys as _coconut_sys
26
26
  VERSION = "3.0.0"
27
27
  VERSION_NAME = None
28
28
  # False for release, int >= 1 for develop
29
- DEVELOP = 12
29
+ DEVELOP = 14
30
30
  ALPHA = True # for pre releases rather than post releases
31
31
 
32
32
  # -----------------------------------------------------------------------------------------------------------------------
@@ -57,7 +57,19 @@ PY2 = _coconut_sys.version_info < (3,)
57
57
  PY26 = _coconut_sys.version_info < (2, 7)
58
58
  PY37 = _coconut_sys.version_info >= (3, 7)
59
59
 
60
- _non_py37_extras = r'''def _coconut_default_breakpointhook(*args, **kwargs):
60
+ _non_py37_extras = r'''from collections import OrderedDict as _coconut_OrderedDict
61
+ class dict(_coconut_OrderedDict):
62
+ __slots__ = ()
63
+ __doc__ = getattr(_coconut_OrderedDict, "__doc__", "<see help(py_dict)>")
64
+ class __metaclass__(type):
65
+ def __instancecheck__(cls, inst):
66
+ return _coconut.isinstance(inst, _coconut_py_dict)
67
+ def __subclasscheck__(cls, subcls):
68
+ return _coconut.issubclass(subcls, _coconut_py_dict)
69
+ __eq__ = _coconut_py_dict.__eq__
70
+ def __repr__(self):
71
+ return "{" + ", ".join("{k!r}: {v!r}".format(k=k, v=v) for k, v in self.items()) + "}"
72
+ def _coconut_default_breakpointhook(*args, **kwargs):
61
73
  hookname = _coconut.os.getenv("PYTHONBREAKPOINT")
62
74
  if hookname != "0":
63
75
  if not hookname:
@@ -82,7 +94,7 @@ def breakpoint(*args, **kwargs):
82
94
  # if a new assignment is added below, a new builtins import should be added alongside it
83
95
  _base_py3_header = r'''from builtins import chr, dict, hex, input, int, map, object, oct, open, print, range, str, super, zip, filter, reversed, enumerate, repr
84
96
  py_chr, py_dict, py_hex, py_input, py_int, py_map, py_object, py_oct, py_open, py_print, py_range, py_str, py_super, py_zip, py_filter, py_reversed, py_enumerate, py_repr = chr, dict, hex, input, int, map, object, oct, open, print, range, str, super, zip, filter, reversed, enumerate, repr
85
- _coconut_py_str, _coconut_py_super = str, super
97
+ _coconut_py_str, _coconut_py_super, _coconut_py_dict = str, super, dict
86
98
  from functools import wraps as _coconut_wraps
87
99
  exec("_coconut_exec = exec")
88
100
  '''
@@ -100,7 +112,7 @@ PY27_HEADER = r'''from __builtin__ import chr, dict, hex, input, int, map, objec
100
112
  py_chr, py_dict, py_hex, py_input, py_int, py_map, py_object, py_oct, py_open, py_print, py_range, py_str, py_super, py_zip, py_filter, py_reversed, py_enumerate, py_raw_input, py_xrange, py_repr = chr, dict, hex, input, int, map, object, oct, open, print, range, str, super, zip, filter, reversed, enumerate, raw_input, xrange, repr
101
113
  _coconut_py_raw_input, _coconut_py_xrange, _coconut_py_int, _coconut_py_long, _coconut_py_print, _coconut_py_str, _coconut_py_super, _coconut_py_unicode, _coconut_py_repr, _coconut_py_dict = raw_input, xrange, int, long, print, str, super, unicode, repr, dict
102
114
  from functools import wraps as _coconut_wraps
103
- from collections import Sequence as _coconut_Sequence, OrderedDict as _coconut_OrderedDict
115
+ from collections import Sequence as _coconut_Sequence
104
116
  from future_builtins import *
105
117
  chr, str = unichr, unicode
106
118
  from io import open
@@ -124,20 +136,6 @@ class int(_coconut_py_int):
124
136
  return _coconut.isinstance(inst, (_coconut_py_int, _coconut_py_long))
125
137
  def __subclasscheck__(cls, subcls):
126
138
  return _coconut.issubclass(subcls, (_coconut_py_int, _coconut_py_long))
127
- class dict(_coconut_OrderedDict):
128
- __slots__ = ()
129
- __doc__ = getattr(_coconut_OrderedDict, "__doc__", "<see help(py_dict)>")
130
- class __metaclass__(type):
131
- def __instancecheck__(cls, inst):
132
- return _coconut.isinstance(inst, _coconut_py_dict)
133
- def __subclasscheck__(cls, subcls):
134
- return _coconut.issubclass(subcls, _coconut_py_dict)
135
- __eq__ = _coconut_py_dict.__eq__
136
- __repr__ = _coconut_py_dict.__repr__
137
- __str__ = _coconut_py_dict.__str__
138
- keys = _coconut_OrderedDict.viewkeys
139
- values = _coconut_OrderedDict.viewvalues
140
- items = _coconut_OrderedDict.viewitems
141
139
  class range(object):
142
140
  __slots__ = ("_xrange",)
143
141
  __doc__ = getattr(_coconut_py_xrange, "__doc__", "<see help(py_xrange)>")
@@ -250,7 +248,10 @@ def _coconut_exec(obj, globals=None, locals=None):
250
248
  if globals is None:
251
249
  globals = _coconut_sys._getframe(1).f_globals
252
250
  exec(obj, globals, locals)
253
- ''' + _non_py37_extras
251
+ ''' + _non_py37_extras + '''dict.keys = _coconut_OrderedDict.viewkeys
252
+ dict.values = _coconut_OrderedDict.viewvalues
253
+ dict.items = _coconut_OrderedDict.viewitems
254
+ '''
254
255
 
255
256
  PY2_HEADER = PY27_HEADER + '''if _coconut_sys.version_info < (2, 7):
256
257
  import functools as _coconut_functools, copy_reg as _coconut_copy_reg
@@ -1562,14 +1562,17 @@ def primary_test() -> bool:
1562
1562
  a_dict[1] = 1
1563
1563
  a_dict[3] = 2
1564
1564
  a_dict[2] = 3
1565
+ assert a_dict |> str == "{1: 1, 3: 2, 2: 3}" == a_dict |> repr, a_dict
1565
1566
  assert a_dict.keys() |> tuple == (1, 3, 2)
1566
1567
  assert not a_dict.keys() `isinstance` list
1567
1568
  assert not a_dict.values() `isinstance` list
1568
1569
  assert not a_dict.items() `isinstance` list
1570
+ assert len(a_dict.keys()) == len(a_dict.values()) == len(a_dict.items()) == 3
1569
1571
  assert {1: 1, 3: 2, 2: 3}.keys() |> tuple == (1, 3, 2)
1570
1572
  assert {**[(1, 1), (3, 2), (2, 3)]}.keys() |> tuple == (1, 3, 2)
1571
1573
  assert a_dict == {1: 1, 2: 3, 3: 2}
1572
1574
  assert {1: 1} |> str == "{1: 1}" == {1: 1} |> repr
1573
1575
  assert py_dict `issubclass` dict
1574
1576
  assert py_dict() `isinstance` dict
1577
+ assert {5:0, 3:0, **{2:0, 6:0}, 8:0}.keys() |> tuple == (5, 3, 2, 6, 8)
1575
1578
  return True
@@ -1016,6 +1016,7 @@ forward 2""") == 900
1016
1016
  assert sum_evens(7, 3) == 0 == sum_evens(4, 4)
1017
1017
  assert num_it() |> list == [5]
1018
1018
  assert left_right_diff([10,4,8,3]) |> list == [15, 1, 11, 22]
1019
+ assert num_until_neg_sum([2,-1,0,1,-3,3,-3]) == 6
1019
1020
 
1020
1021
  # must come at end
1021
1022
  assert fibs_calls[0] == 1
@@ -1543,7 +1543,7 @@ data End(offset `isinstance` int = 0 if offset <= 0): # type: ignore
1543
1543
  end = End()
1544
1544
 
1545
1545
 
1546
- # advent of code
1546
+ # coding challenges
1547
1547
  proc_moves = (
1548
1548
  .strip()
1549
1549
  ..> .splitlines()
@@ -1679,6 +1679,15 @@ left_right_diff = (
1679
1679
  ..> map$(abs)
1680
1680
  ) # type: ignore
1681
1681
 
1682
+ num_until_neg_sum = (
1683
+ sorted
1684
+ ..> reversed
1685
+ ..> scan$(+)
1686
+ ..> filter$(.>0)
1687
+ ..> list
1688
+ ..> len
1689
+ )
1690
+
1682
1691
 
1683
1692
  # Search patterns
1684
1693
  def first_twin(_ + [p, (.-2) -> p] + _) = (p, p+2)
@@ -228,7 +228,7 @@ def gam_eps_rate(bitarr) = (
228
228
  ~~~~~^""" in err_str or """
229
229
  |> map$(int(?, 2))
230
230
 
231
- ~~~~~~~~~~~~~~~~~^""" in err_str
231
+ ~~~~~~~~~~~~~~~~~^""" in err_str, err_str
232
232
  else:
233
233
  assert False
234
234
 
@@ -422,7 +422,7 @@ def test_numpy() -> bool:
422
422
  assert list(enumeration) == [((0, 0), 1), ((0, 1), 2), ((1, 0), 3), ((1, 1), 4)]
423
423
  for ind, x in multi_enumerate(np.array([1, 2])):
424
424
  assert ind `isinstance` tuple, (type(ind), ind)
425
- assert x `isinstance` np.int32, (type(x), x)
425
+ assert x `isinstance` (np.int32, np.int64), (type(x), x)
426
426
  assert all_equal(np.array([]))
427
427
  assert all_equal(np.array([1]))
428
428
  assert all_equal(np.array([1, 1]))