coconut-develop 3.1.0.post0.dev4__tar.gz → 3.1.0.post0.dev6__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 (91) hide show
  1. coconut-develop-3.1.0.post0.dev6/PKG-INFO +140 -0
  2. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/compiler/compiler.py +58 -17
  3. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/compiler/grammar.py +2 -1
  4. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/compiler/templates/header.py_template +1 -1
  5. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/compiler/util.py +5 -3
  6. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/constants.py +1 -1
  7. coconut-develop-3.1.0.post0.dev6/coconut/icoconut/coconut/kernel.json +11 -0
  8. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/root.py +1 -1
  9. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/main_test.py +5 -5
  10. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/agnostic/suite.coco +7 -4
  11. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/agnostic/util.coco +30 -9
  12. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/target_sys/target_sys_test.coco +9 -5
  13. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/extras.coco +1 -2
  14. coconut-develop-3.1.0.post0.dev4/PKG-INFO +0 -387
  15. coconut-develop-3.1.0.post0.dev4/coconut/icoconut/coconut/kernel.json +0 -11
  16. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/CONTRIBUTING.md +0 -0
  17. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/DOCS.md +0 -0
  18. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/FAQ.md +0 -0
  19. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/HELP.md +0 -0
  20. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/LICENSE.txt +0 -0
  21. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/MANIFEST.in +0 -0
  22. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/README.rst +0 -0
  23. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/__coconut__/__init__.py +0 -0
  24. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/__coconut__/__init__.pyi +0 -0
  25. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/__coconut__/py.typed +0 -0
  26. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/_coconut/__init__.py +0 -0
  27. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/_coconut/__init__.pyi +0 -0
  28. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/_coconut/py.typed +0 -0
  29. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/__coconut__.py +0 -0
  30. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/__coconut__.pyi +0 -0
  31. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/__init__.py +0 -0
  32. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/__init__.pyi +0 -0
  33. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/__main__.py +0 -0
  34. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/_pyparsing.py +0 -0
  35. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/api.py +0 -0
  36. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/api.pyi +0 -0
  37. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/command/__init__.py +0 -0
  38. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/command/__init__.pyi +0 -0
  39. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/command/cli.py +0 -0
  40. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/command/command.py +0 -0
  41. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/command/command.pyi +0 -0
  42. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/command/mypy.py +0 -0
  43. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/command/resources/zcoconut.pth +0 -0
  44. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/command/util.py +0 -0
  45. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/command/watch.py +0 -0
  46. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/compiler/__init__.py +0 -0
  47. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/compiler/header.py +0 -0
  48. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/compiler/matching.py +0 -0
  49. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/convenience.py +0 -0
  50. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/convenience.pyi +0 -0
  51. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/exceptions.py +0 -0
  52. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/highlighter.py +0 -0
  53. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/icoconut/__init__.py +0 -0
  54. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/icoconut/__main__.py +0 -0
  55. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/icoconut/coconut_py/kernel.json +0 -0
  56. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/icoconut/coconut_py2/kernel.json +0 -0
  57. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/icoconut/coconut_py3/kernel.json +0 -0
  58. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/icoconut/embed.py +0 -0
  59. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/icoconut/root.py +0 -0
  60. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/integrations.py +0 -0
  61. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/main.py +0 -0
  62. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/py.typed +0 -0
  63. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/requirements.py +0 -0
  64. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/terminal.py +0 -0
  65. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/__init__.py +0 -0
  66. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/__main__.py +0 -0
  67. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/constants_test.py +0 -0
  68. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/agnostic/__init__.coco +0 -0
  69. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/agnostic/__main__.coco +0 -0
  70. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/agnostic/main.coco +0 -0
  71. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/agnostic/primary_1.coco +0 -0
  72. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/agnostic/primary_2.coco +0 -0
  73. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/agnostic/specific.coco +0 -0
  74. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/agnostic/tutorial.coco +0 -0
  75. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/non_strict/non_strict_test.coco +0 -0
  76. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/target_2/py2_test.coco +0 -0
  77. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/target_3/py3_test.coco +0 -0
  78. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/target_311/py311_test.coco +0 -0
  79. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/target_35/py35_test.coco +0 -0
  80. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/target_36/py36_test.coco +0 -0
  81. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/cocotest/target_38/py38_test.coco +0 -0
  82. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/importable.coco +0 -0
  83. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/runnable.coco +0 -0
  84. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/tests/src/runner.coco +0 -0
  85. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut/util.py +0 -0
  86. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/coconut_develop.egg-info/SOURCES.txt +0 -0
  87. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/conf.py +0 -0
  88. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/pyproject.toml +0 -0
  89. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/setup.cfg +0 -0
  90. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/setup.py +0 -0
  91. {coconut-develop-3.1.0.post0.dev4 → coconut-develop-3.1.0.post0.dev6}/xontrib/coconut.py +0 -0
@@ -0,0 +1,140 @@
1
+ Metadata-Version: 2.1
2
+ Name: coconut-develop
3
+ Version: 3.1.0.post0.dev6
4
+ Summary: Simple, elegant, Pythonic functional programming.
5
+ Home-page: http://coconut-lang.org
6
+ Author: Evan Hubinger
7
+ Author-email: evanjhub@gmail.com
8
+ License: Apache 2.0
9
+ Description: |logo| Coconut
10
+ ==============
11
+
12
+ ..
13
+ <insert toctree here>
14
+
15
+ .. |logo| image:: https://github.com/evhub/coconut/raw/gh-pages/favicon-32x32.png
16
+
17
+ .. image:: https://opencollective.com/coconut/backers/badge.svg
18
+ :alt: Backers on Open Collective
19
+ :target: #backers
20
+ .. image:: https://opencollective.com/coconut/sponsors/badge.svg
21
+ :alt: Sponsors on Open Collective
22
+ :target: #sponsors
23
+ .. image:: https://badges.gitter.im/evhub/coconut.svg
24
+ :alt: Join the chat at https://gitter.im/evhub/coconut
25
+ :target: https://gitter.im/evhub/coconut?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
26
+
27
+ Coconut (`coconut-lang.org`__) is a variant of Python_ that **adds on top of Python syntax** new features for simple, elegant, Pythonic **functional programming**.
28
+
29
+ __ Coconut_
30
+ .. _Coconut: http://coconut-lang.org/
31
+
32
+ Coconut is developed on GitHub_ and hosted on PyPI_. Installing Coconut is as easy as opening a command prompt and entering::
33
+
34
+ pip install coconut
35
+
36
+ To help you get started, check out these links for more information about Coconut:
37
+
38
+ - Tutorial_: If you're new to Coconut, a good place to start is Coconut's **tutorial**.
39
+ - Documentation_: If you're looking for info about a specific feature, check out Coconut's **documentation**.
40
+ - `Online Interpreter`_: If you want to try Coconut in your browser, check out Coconut's **online interpreter**.
41
+ - FAQ_: If you have general questions about Coconut—like who Coconut is built for and whether or not you should use it—Coconut's frequently asked questions are often the best place to start.
42
+ - `Create a New Issue <https://github.com/evhub/coconut/issues/new>`_: If you're having a problem with Coconut, creating a new issue detailing the problem will allow it to be addressed as soon as possible.
43
+ - Gitter_: For any questions, concerns, or comments about anything Coconut-related, ask around at Coconut's Gitter, a GitHub-integrated chat room for Coconut developers.
44
+ - Releases_: Want to know what's been added in recent Coconut versions? Check out the release log for all the new features and fixes.
45
+
46
+ .. _Python: https://www.python.org/
47
+ .. _PyPI: https://pypi.python.org/pypi/coconut
48
+ .. _Tutorial: http://coconut.readthedocs.io/en/latest/HELP.html
49
+ .. _Documentation: http://coconut.readthedocs.io/en/latest/DOCS.html
50
+ .. _`Online Interpreter`: https://cs121-team-panda.github.io/coconut-interpreter
51
+ .. _FAQ: http://coconut.readthedocs.io/en/latest/FAQ.html
52
+ .. _GitHub: https://github.com/evhub/coconut
53
+ .. _Gitter: https://gitter.im/evhub/coconut
54
+ .. _Releases: https://github.com/evhub/coconut/releases
55
+
56
+ Credits
57
+ +++++++
58
+
59
+ Contributors
60
+ ------------
61
+
62
+ This project exists thanks to all the people who contribute! `Become a contributor`__.
63
+
64
+ .. image:: https://opencollective.com/coconut/contributors.svg?width=890&button=false
65
+ :target: https://github.com/evhub/coconut/graphs/contributors
66
+
67
+ __ Contributor_
68
+ .. _Contributor: http://coconut.readthedocs.io/en/develop/CONTRIBUTING.html
69
+
70
+ Backers
71
+ -------
72
+
73
+ Thank you to all our backers! `Become a backer`__.
74
+
75
+ .. image:: https://opencollective.com/coconut/backers.svg?width=890
76
+ :target: https://opencollective.com/coconut#backers
77
+
78
+ __ Backer_
79
+ .. _Backer: https://opencollective.com/coconut#backer
80
+
81
+ Sponsors
82
+ --------
83
+
84
+ Support Coconut by becoming a sponsor. Your logo will show up here with a link to your website. `Become a sponsor`__.
85
+
86
+ .. image:: https://opencollective.com/XX/sponsor/0/avatar.svg
87
+ :target: https://opencollective.com/coconut/sponsor/0/website
88
+
89
+ __ Sponsor_
90
+ .. _Sponsor: https://opencollective.com/coconut#sponsor
91
+
92
+ Keywords: functional,programming,language,compiler,pattern,pattern-matching,algebraic,data type,data types,lambda,lambdas,lazy,evaluation,lazy list,lazy lists,tail,recursion,call,recursive,recursive_iterator,infix,function,composition,compose,partial,application,currying,curry,pipeline,pipe,unicode,operator,operators,frozenset,literal,syntax,destructuring,assignment,fold,datamaker,prepattern,iterator,generator,none,coalesce,coalescing,statement,lru_cache,memoization,backport,typing,embed,PEP 622,overrides,islice,itertools,functools,TYPE_CHECKING,Expected,breakpoint,help,reduce,takewhile,dropwhile,tee,count,makedata,consume,process_map,thread_map,addpattern,recursive_generator,fmap,starmap,reiterable,scan,groupsof,memoize,zip_longest,override,flatten,ident,call,safe_call,flip,const,lift,lift_apart,all_equal,collectby,mapreduce,multi_enumerate,cartesian_product,multiset,cycle,windowsof,and_then,and_then_await,async_map,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,py_breakpoint,py_min,py_max,_namedtuple_of,reveal_type,reveal_locals,MatchError,__fmap__,__iter_getitem__,data,match,case,cases,where,addpattern,then,operator,type,copyclosure,λ
93
+ Platform: UNKNOWN
94
+ Classifier: Development Status :: 5 - Production/Stable
95
+ Classifier: License :: OSI Approved :: Apache Software License
96
+ Classifier: Intended Audience :: Developers
97
+ Classifier: Topic :: Software Development
98
+ Classifier: Topic :: Software Development :: Code Generators
99
+ Classifier: Topic :: Software Development :: Compilers
100
+ Classifier: Topic :: Software Development :: Interpreters
101
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
102
+ Classifier: Topic :: Utilities
103
+ Classifier: Environment :: Console
104
+ Classifier: Operating System :: OS Independent
105
+ Classifier: Programming Language :: Python
106
+ Classifier: Programming Language :: Python :: 2
107
+ Classifier: Programming Language :: Python :: 2.6
108
+ Classifier: Programming Language :: Python :: 2.7
109
+ Classifier: Programming Language :: Python :: 3
110
+ Classifier: Programming Language :: Python :: 3.2
111
+ Classifier: Programming Language :: Python :: 3.3
112
+ Classifier: Programming Language :: Python :: 3.4
113
+ Classifier: Programming Language :: Python :: 3.5
114
+ Classifier: Programming Language :: Python :: 3.6
115
+ Classifier: Programming Language :: Python :: 3.7
116
+ Classifier: Programming Language :: Python :: 3.8
117
+ Classifier: Programming Language :: Python :: 3.9
118
+ Classifier: Programming Language :: Python :: 3.10
119
+ Classifier: Programming Language :: Python :: 3.11
120
+ Classifier: Programming Language :: Python :: 3.12
121
+ Classifier: Programming Language :: Other
122
+ Classifier: Programming Language :: Other Scripting Engines
123
+ Classifier: Programming Language :: Python :: Implementation :: CPython
124
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
125
+ Classifier: Framework :: IPython
126
+ Classifier: Framework :: Jupyter
127
+ Classifier: Typing :: Typed
128
+ Provides-Extra: kernel
129
+ Provides-Extra: watch
130
+ Provides-Extra: mypy
131
+ Provides-Extra: xonsh
132
+ Provides-Extra: numpy
133
+ Provides-Extra: jupyter
134
+ Provides-Extra: jupyterlab
135
+ Provides-Extra: jupytext
136
+ Provides-Extra: all
137
+ Provides-Extra: ipython
138
+ Provides-Extra: docs
139
+ Provides-Extra: tests
140
+ Provides-Extra: dev
@@ -2513,7 +2513,7 @@ def {mock_var}({mock_paramdef}):
2513
2513
 
2514
2514
  # assemble tre'd function
2515
2515
  comment, rest = split_leading_comments(func_code)
2516
- indent, base, dedent = split_leading_trailing_indent(rest, 1)
2516
+ indent, base, dedent = split_leading_trailing_indent(rest, max_indents=1)
2517
2517
  base, base_dedent = split_trailing_indent(base)
2518
2518
  docstring, base = self.split_docstring(base)
2519
2519
 
@@ -2673,15 +2673,19 @@ else:
2673
2673
  post_def_lines = []
2674
2674
  funcdef_lines = list(literal_lines(funcdef, True))
2675
2675
  for i, line in enumerate(funcdef_lines):
2676
- if self.def_regex.match(line):
2676
+ line_indent, line_base = split_leading_indent(line)
2677
+ if self.def_regex.match(line_base):
2677
2678
  pre_def_lines = funcdef_lines[:i]
2678
2679
  post_def_lines = funcdef_lines[i:]
2679
2680
  break
2680
2681
  internal_assert(post_def_lines, "no def statement found in funcdef", funcdef)
2681
2682
 
2682
2683
  out.append(bef_ind)
2683
- out.extend(pre_def_lines)
2684
- out.append(self.proc_funcdef(original, loc, decorators, "".join(post_def_lines), is_async, in_method, is_stmt_lambda))
2684
+ out += pre_def_lines
2685
+ func_indent, func_code, func_dedent = split_leading_trailing_indent("".join(post_def_lines), symmetric=True)
2686
+ out.append(func_indent)
2687
+ out.append(self.proc_funcdef(original, loc, decorators, func_code, is_async, in_method, is_stmt_lambda))
2688
+ out.append(func_dedent)
2685
2689
  out.append(aft_ind)
2686
2690
 
2687
2691
  # look for add_code_before regexes
@@ -3176,7 +3180,16 @@ while True:
3176
3180
  """Process class definitions."""
3177
3181
  decorators, name, paramdefs, classlist_toks, body = tokens
3178
3182
 
3179
- out = "".join(paramdefs) + decorators + "class " + name
3183
+ out = ""
3184
+
3185
+ # paramdefs are type params on >= 3.12 and type var assignments on < 3.12
3186
+ if paramdefs:
3187
+ if self.target_info >= (3, 12):
3188
+ name += "[" + ", ".join(paramdefs) + "]"
3189
+ else:
3190
+ out += "".join(paramdefs)
3191
+
3192
+ out += decorators + "class " + name
3180
3193
 
3181
3194
  # handle classlist
3182
3195
  base_classes = []
@@ -3206,7 +3219,7 @@ while True:
3206
3219
 
3207
3220
  base_classes.append(join_args(pos_args, star_args, kwd_args, dubstar_args))
3208
3221
 
3209
- if paramdefs:
3222
+ if paramdefs and self.target_info < (3, 12):
3210
3223
  base_classes.append(self.get_generic_for_typevars())
3211
3224
 
3212
3225
  if not classlist_toks and not self.target.startswith("3"):
@@ -3438,9 +3451,16 @@ def __new__(_coconut_cls, {all_args}):
3438
3451
  IMPORTANT: Any changes to assemble_data must be reflected in the
3439
3452
  definition of Expected in header.py_template.
3440
3453
  """
3454
+ print(paramdefs)
3441
3455
  # create class
3442
- out = [
3443
- "".join(paramdefs),
3456
+ out = []
3457
+ if paramdefs:
3458
+ # paramdefs are type params on >= 3.12 and type var assignments on < 3.12
3459
+ if self.target_info >= (3, 12):
3460
+ name += "[" + ", ".join(paramdefs) + "]"
3461
+ else:
3462
+ out += ["".join(paramdefs)]
3463
+ out += [
3444
3464
  decorators,
3445
3465
  "class ",
3446
3466
  name,
@@ -3449,7 +3469,7 @@ def __new__(_coconut_cls, {all_args}):
3449
3469
  ]
3450
3470
  if inherit is not None:
3451
3471
  out += [", ", inherit]
3452
- if paramdefs:
3472
+ if paramdefs and self.target_info < (3, 12):
3453
3473
  out += [", ", self.get_generic_for_typevars()]
3454
3474
  if not self.target.startswith("3"):
3455
3475
  out.append(", _coconut.object")
@@ -3554,7 +3574,7 @@ def __hash__(self):
3554
3574
  fake_mods = imp_as.split(".")
3555
3575
  for i in range(1, len(fake_mods)):
3556
3576
  mod_name = ".".join(fake_mods[:i])
3557
- out.extend((
3577
+ out += [
3558
3578
  "try:",
3559
3579
  openindent + mod_name,
3560
3580
  closeindent + "except:",
@@ -3562,7 +3582,7 @@ def __hash__(self):
3562
3582
  closeindent + "else:",
3563
3583
  openindent + "if not _coconut.isinstance(" + mod_name + ", _coconut.types.ModuleType):",
3564
3584
  openindent + mod_name + ' = _coconut.types.ModuleType(_coconut_py_str("' + mod_name + '"))' + closeindent * 2,
3565
- ))
3585
+ ]
3566
3586
  out.append(".".join(fake_mods) + " = " + import_as_var)
3567
3587
  else:
3568
3588
  out.append(import_stmt(imp_from, imp, imp_as))
@@ -4560,15 +4580,21 @@ class {protocol_var}({tokens}, _coconut.typing.Protocol): pass
4560
4580
  return name
4561
4581
  else:
4562
4582
  name, paramdefs = tokens
4563
- return self.add_code_before_marker_with_replacement(name, "".join(paramdefs), add_spaces=False)
4583
+ # paramdefs are type params on >= 3.12 and type var assignments on < 3.12
4584
+ if self.target_info >= (3, 12):
4585
+ return name + "[" + ", ".join(paramdefs) + "]"
4586
+ else:
4587
+ return self.add_code_before_marker_with_replacement(name, "".join(paramdefs), add_spaces=False)
4564
4588
 
4565
4589
  funcname_typeparams_handle.ignore_one_token = True
4566
4590
 
4567
4591
  def type_param_handle(self, original, loc, tokens):
4568
4592
  """Compile a type param into an assignment."""
4569
4593
  args = ""
4594
+ raw_bound = None
4570
4595
  bound_op = None
4571
4596
  bound_op_type = ""
4597
+ stars = ""
4572
4598
  if "TypeVar" in tokens:
4573
4599
  TypeVarFunc = "TypeVar"
4574
4600
  bound_op_type = "bound"
@@ -4576,18 +4602,24 @@ class {protocol_var}({tokens}, _coconut.typing.Protocol): pass
4576
4602
  name_loc, name = tokens
4577
4603
  else:
4578
4604
  name_loc, name, bound_op, bound = tokens
4605
+ # raw_bound is for >=3.12, so it is for_py_typedef, but args is for <3.12, so it isn't
4606
+ raw_bound = self.wrap_typedef(bound, for_py_typedef=True)
4579
4607
  args = ", bound=" + self.wrap_typedef(bound, for_py_typedef=False)
4580
4608
  elif "TypeVar constraint" in tokens:
4581
4609
  TypeVarFunc = "TypeVar"
4582
4610
  bound_op_type = "constraint"
4583
4611
  name_loc, name, bound_op, constraints = tokens
4612
+ # for_py_typedef is different in the two cases here as above
4613
+ raw_bound = ", ".join(self.wrap_typedef(c, for_py_typedef=True) for c in constraints)
4584
4614
  args = ", " + ", ".join(self.wrap_typedef(c, for_py_typedef=False) for c in constraints)
4585
4615
  elif "TypeVarTuple" in tokens:
4586
4616
  TypeVarFunc = "TypeVarTuple"
4587
4617
  name_loc, name = tokens
4618
+ stars = "*"
4588
4619
  elif "ParamSpec" in tokens:
4589
4620
  TypeVarFunc = "ParamSpec"
4590
4621
  name_loc, name = tokens
4622
+ stars = "**"
4591
4623
  else:
4592
4624
  raise CoconutInternalException("invalid type_param tokens", tokens)
4593
4625
 
@@ -4608,8 +4640,14 @@ class {protocol_var}({tokens}, _coconut.typing.Protocol): pass
4608
4640
  loc,
4609
4641
  )
4610
4642
 
4643
+ # on >= 3.12, return a type param
4644
+ if self.target_info >= (3, 12):
4645
+ return stars + name + (": " + raw_bound if raw_bound is not None else "")
4646
+
4647
+ # on < 3.12, return a type variable assignment
4648
+
4611
4649
  kwargs = ""
4612
- # uncomment these lines whenever mypy adds support for infer_variance in TypeVar
4650
+ # TODO: uncomment these lines whenever mypy adds support for infer_variance in TypeVar
4613
4651
  # (and remove the warning about it in the DOCS)
4614
4652
  # if TypeVarFunc == "TypeVar":
4615
4653
  # kwargs += ", infer_variance=True"
@@ -4640,6 +4678,7 @@ class {protocol_var}({tokens}, _coconut.typing.Protocol): pass
4640
4678
 
4641
4679
  def get_generic_for_typevars(self):
4642
4680
  """Get the Generic instances for the current typevars."""
4681
+ internal_assert(self.target_info < (3, 12), "get_generic_for_typevars should only be used on targets < 3.12")
4643
4682
  typevar_info = self.current_parsing_context("typevars")
4644
4683
  internal_assert(typevar_info is not None, "get_generic_for_typevars called with no typevars")
4645
4684
  generics = []
@@ -4673,16 +4712,18 @@ class {protocol_var}({tokens}, _coconut.typing.Protocol): pass
4673
4712
  paramdefs = ()
4674
4713
  else:
4675
4714
  name, paramdefs, typedef = tokens
4676
- out = "".join(paramdefs)
4715
+
4716
+ # paramdefs are type params on >= 3.12 and type var assignments on < 3.12
4677
4717
  if self.target_info >= (3, 12):
4678
- out += "type " + name + " = " + self.wrap_typedef(typedef, for_py_typedef=True)
4718
+ if paramdefs:
4719
+ name += "[" + ", ".join(paramdefs) + "]"
4720
+ return "type " + name + " = " + self.wrap_typedef(typedef, for_py_typedef=True)
4679
4721
  else:
4680
- out += self.typed_assign_stmt_handle([
4722
+ return "".join(paramdefs) + self.typed_assign_stmt_handle([
4681
4723
  name,
4682
4724
  "_coconut.typing.TypeAlias",
4683
4725
  self.wrap_typedef(typedef, for_py_typedef=False),
4684
4726
  ])
4685
- return out
4686
4727
 
4687
4728
  def where_item_handle(self, tokens):
4688
4729
  """Manage where items."""
@@ -2718,7 +2718,8 @@ class Grammar(object):
2718
2718
 
2719
2719
  whitespace_regex = compile_regex(r"\s")
2720
2720
 
2721
- def_regex = compile_regex(r"\b((async|addpattern|copyclosure)\s+)*def\b")
2721
+ def_regex = compile_regex(r"((async|addpattern|copyclosure)\s+)*def\b")
2722
+
2722
2723
  yield_regex = compile_regex(r"\byield(?!\s+_coconut\.asyncio\.From)\b")
2723
2724
  yield_from_regex = compile_regex(r"\byield\s+from\b")
2724
2725
 
@@ -61,7 +61,7 @@ class _coconut{object}:{COMMENT.EVERYTHING_HERE_MUST_BE_COPIED_TO_STUB_FILE}
61
61
  reiterables = abc.Sequence, abc.Mapping, abc.Set
62
62
  fmappables = list, tuple, dict, set, frozenset, bytes, bytearray
63
63
  abc.Sequence.register(collections.deque)
64
- Ellipsis, NotImplemented, NotImplementedError, Exception, AttributeError, ImportError, IndexError, KeyError, NameError, TypeError, ValueError, StopIteration, RuntimeError, all, any, bool, bytes, callable, chr, classmethod, complex, dict, enumerate, filter, float, frozenset, getattr, hasattr, hash, id, int, isinstance, issubclass, iter, len, list, locals, globals, map, min, max, next, object, ord, property, range, reversed, set, setattr, slice, str, sum, super, tuple, type, vars, zip, repr, print{comma_bytearray} = Ellipsis, NotImplemented, NotImplementedError, Exception, AttributeError, ImportError, IndexError, KeyError, NameError, TypeError, ValueError, StopIteration, RuntimeError, all, any, bool, bytes, callable, chr, classmethod, complex, dict, enumerate, filter, float, frozenset, getattr, hasattr, hash, id, int, isinstance, issubclass, iter, len, list, locals, globals, map, min, max, next, object, ord, property, range, reversed, set, setattr, slice, str, sum, {lstatic}super{rstatic}, tuple, type, vars, zip, {lstatic}repr{rstatic}, {lstatic}print{rstatic}{comma_bytearray}
64
+ Ellipsis, NotImplemented, NotImplementedError, Exception, AttributeError, ImportError, IndexError, KeyError, NameError, TypeError, ValueError, StopIteration, RuntimeError, all, any, bool, bytes, callable, chr, classmethod, complex, dict, enumerate, filter, float, frozenset, getattr, hasattr, hash, id, int, isinstance, issubclass, iter, len, list, locals, globals, map, min, max, next, object, ord, property, range, reversed, set, setattr, slice, str, sum, super, tuple, type, vars, zip, repr, print{comma_bytearray} = Ellipsis, NotImplemented, NotImplementedError, Exception, AttributeError, ImportError, IndexError, KeyError, NameError, TypeError, ValueError, StopIteration, RuntimeError, all, any, bool, bytes, callable, chr, classmethod, complex, dict, enumerate, filter, float, frozenset, getattr, hasattr, hash, id, int, isinstance, issubclass, iter, len, list, locals, globals, map, {lstatic}min{rstatic}, {lstatic}max{rstatic}, next, object, ord, property, range, reversed, set, setattr, slice, str, sum, {lstatic}super{rstatic}, tuple, type, vars, zip, {lstatic}repr{rstatic}, {lstatic}print{rstatic}{comma_bytearray}
65
65
  @_coconut.functools.wraps(_coconut.functools.partial)
66
66
  def _coconut_partial(_coconut_func, *args, **kwargs):
67
67
  partial_func = _coconut.functools.partial(_coconut_func, *args, **kwargs)
@@ -1804,10 +1804,12 @@ def split_trailing_indent(inputstr, max_indents=None, handle_comments=True):
1804
1804
  return inputstr, "".join(reversed(indents_from_end))
1805
1805
 
1806
1806
 
1807
- def split_leading_trailing_indent(line, max_indents=None):
1807
+ def split_leading_trailing_indent(line, symmetric=False, **kwargs):
1808
1808
  """Split leading and trailing indent."""
1809
- leading_indent, line = split_leading_indent(line, max_indents)
1810
- line, trailing_indent = split_trailing_indent(line, max_indents)
1809
+ leading_indent, line = split_leading_indent(line, **kwargs)
1810
+ if symmetric:
1811
+ kwargs["max_indents"] = leading_indent.count(openindent)
1812
+ line, trailing_indent = split_trailing_indent(line, **kwargs)
1811
1813
  return leading_indent, line, trailing_indent
1812
1814
 
1813
1815
 
@@ -93,7 +93,7 @@ MYPY = (
93
93
  PY38
94
94
  and not WINDOWS
95
95
  and not PYPY
96
- # disabled until MyPy supports PEP 695
96
+ # TODO: disabled until MyPy supports PEP 695
97
97
  and not PY312
98
98
  )
99
99
  XONSH = (
@@ -0,0 +1,11 @@
1
+ {
2
+ "argv": [
3
+ "python",
4
+ "-m",
5
+ "coconut.icoconut",
6
+ "-f",
7
+ "{connection_file}"
8
+ ],
9
+ "display_name": "Coconut",
10
+ "language": "coconut"
11
+ }
@@ -26,7 +26,7 @@ import sys as _coconut_sys
26
26
  VERSION = "3.1.0"
27
27
  VERSION_NAME = None
28
28
  # False for release, int >= 1 for develop
29
- DEVELOP = 4
29
+ DEVELOP = 6
30
30
  ALPHA = False # for pre releases rather than post releases
31
31
 
32
32
  assert DEVELOP is False or DEVELOP >= 1, "DEVELOP must be False or an int >= 1"
@@ -1092,11 +1092,11 @@ if TEST_ALL:
1092
1092
  if not PYPY and PY38 and not PY310:
1093
1093
  install_bbopt()
1094
1094
 
1095
- def test_pyprover(self):
1096
- with using_paths(pyprover):
1097
- comp_pyprover()
1098
- if PY38:
1099
- run_pyprover()
1095
+ # def test_pyprover(self):
1096
+ # with using_paths(pyprover):
1097
+ # comp_pyprover()
1098
+ # if PY38:
1099
+ # run_pyprover()
1100
1100
 
1101
1101
  def test_pyston(self):
1102
1102
  with using_paths(pyston):
@@ -630,8 +630,10 @@ def suite_test() -> bool:
630
630
  assert dt.lam() == dt
631
631
  assert dt.comp() == (dt,)
632
632
  assert dt.N()$[:2] |> list == [(dt, 0), (dt, 1)] == dt.N_()$[:2] |> list
633
- assert map(Ad().ef, range(5)) |> list == range(1, 6) |> list
634
- assert Ad().ef 1 == 2
633
+ assert map(HasDefs().a_def, range(5)) |> list == range(1, 6) |> list
634
+ assert HasDefs().a_def 1 == 2
635
+ assert HasDefs().case_def 1 == 0
636
+ assert HasDefs.__annotations__.keys() |> list == ["a_def", "case_def"]
635
637
  assert store.plus1 store.one == store.two
636
638
  assert ret_locals()["my_loc"] == 1
637
639
  assert ret_globals()["my_glob"] == 1
@@ -741,7 +743,8 @@ def suite_test() -> bool:
741
743
  (-> 3) -> _ `isinstance` int = "a" # type: ignore
742
744
  assert empty_it() |> list == [] == empty_it_of_int(1) |> list
743
745
  assert just_it(1) |> list == [1]
744
- assert just_it_of_int(1) |> list == [1] == just_it_of_int_(1) |> list
746
+ assert just_it_of_int1(1) |> list == [1] == just_it_of_int2(1) |> list
747
+ assert just_it_of_int3(1) |> list == [1] == just_it_of_int4(1) |> list
745
748
  assert must_be_int(4) == 4 == must_be_int_(4)
746
749
  assert typed_plus(1, 2) == 3
747
750
  (class inh_A() `isinstance` clsA) `isinstance` object = inh_A()
@@ -1038,7 +1041,7 @@ forward 2""") == 900
1038
1041
  assert (+) `on` (.*2) <*| (3, 5) == 16
1039
1042
  assert test_super_B().method({'somekey': 'string', 'someotherkey': 42})
1040
1043
  assert outer_func_normal() |> map$(call) |> list == [4] * 5
1041
- for outer_func in (outer_func_1, outer_func_2, outer_func_3, outer_func_4, outer_func_5):
1044
+ for outer_func in (outer_func_1, outer_func_2, outer_func_3, outer_func_4, outer_func_5, outer_func_6):
1042
1045
  assert outer_func() |> map$(call) |> list == range(5) |> list
1043
1046
  assert get_glob() == 0
1044
1047
  assert wrong_get_set_glob(10) == 0
@@ -632,7 +632,7 @@ def factorial5(value):
632
632
  else:
633
633
  return None
634
634
  raise TypeError()
635
- case def factorial6[Num <: int | float]: (Num, Num) -> Num
635
+ case def factorial6[Num: (int, float)]: (Num, Num) -> Num
636
636
  """Factorial function"""
637
637
  match (0, acc=1):
638
638
  return acc
@@ -641,7 +641,6 @@ case def factorial6[Num <: int | float]: (Num, Num) -> Num
641
641
  match (int(n), acc=...) if n < 0:
642
642
  return None
643
643
  case def factorial7[Num <: int | float]: (Num, Num) -> Num
644
- """Factorial function"""
645
644
  match(0, acc=1) = acc
646
645
  match(int(n), acc=1) if n > 0 = factorial7(n - 1, acc * n)
647
646
  match(int(n), acc=...) if n < 0 = None
@@ -1410,12 +1409,17 @@ class descriptor_test:
1410
1409
  [(self, i)] :: self.N_(i=i+1)
1411
1410
 
1412
1411
 
1413
- # Function named Ad.ef
1414
- class Ad:
1415
- ef: typing.Callable
1412
+ # Annotation checking
1413
+ class HasDefs:
1414
+ a_def: typing.Callable
1415
+
1416
+ @staticmethod
1417
+ case def case_def: int -> int
1418
+ match(0) = 1
1419
+ match(1) = 0
1416
1420
 
1417
- def Ad.ef(self, 0) = 1 # type: ignore
1418
- addpattern def Ad.ef(self, x) = x + 1 # type: ignore
1421
+ def HasDefs.a_def(self, 0) = 1 # type: ignore
1422
+ addpattern def HasDefs.a_def(self, x) = x + 1 # type: ignore
1419
1423
 
1420
1424
 
1421
1425
  # Storage class
@@ -1524,12 +1528,20 @@ yield def just_it(x): yield x
1524
1528
 
1525
1529
  yield def empty_it_of_int(int() as x): pass
1526
1530
 
1527
- yield match def just_it_of_int(int() as x):
1531
+ yield match def just_it_of_int1(int() as x):
1528
1532
  yield x
1529
1533
 
1530
- match yield def just_it_of_int_(int() as x):
1534
+ match yield def just_it_of_int2(int() as x):
1531
1535
  yield x
1532
1536
 
1537
+ yield case def just_it_of_int3:
1538
+ match(int() as x):
1539
+ yield x
1540
+
1541
+ case yield def just_it_of_int4:
1542
+ match(int() as x):
1543
+ yield x
1544
+
1533
1545
  yield def num_it() -> int$[]:
1534
1546
  yield 5
1535
1547
 
@@ -2059,3 +2071,12 @@ def outer_func_5() -> (() -> int)[]:
2059
2071
  copyclosure def inner_func() -> int = x
2060
2072
  funcs.append(inner_func)
2061
2073
  return funcs
2074
+
2075
+ def outer_func_6():
2076
+ funcs = []
2077
+ for x in range(5):
2078
+ copyclosure case def inner_func:
2079
+ match(y) = y
2080
+ match() = x
2081
+ funcs.append(inner_func)
2082
+ return funcs
@@ -48,12 +48,16 @@ def asyncio_test() -> bool:
48
48
 
49
49
  async def async_map_0(args):
50
50
  return thread_map(args[0], *args[1:])
51
- async def async_map_1(args) = thread_map(args[0], *args[1:])
52
- async def async_map_2([func] + iters) = thread_map(func, *iters)
53
- async match def async_map_3([func] + iters) = thread_map(func, *iters)
54
- match async def async_map_4([func] + iters) = thread_map(func, *iters)
51
+ async def async_map_1(args) = map(args[0], *args[1:])
52
+ async def async_map_2([func] + iters) = map(func, *iters)
53
+ async match def async_map_3([func] + iters) = map(func, *iters)
54
+ match async def async_map_4([func] + iters) = map(func, *iters)
55
+ async case def async_map_5:
56
+ match([func] + iters) = map(func, *iters)
57
+ case async def async_map_6:
58
+ match([func] + iters) = map(func, *iters)
55
59
  async def async_map_test() =
56
- for async_map_ in (async_map_0, async_map_1, async_map_2, async_map_3, async_map_4):
60
+ for async_map_ in (async_map_0, async_map_1, async_map_2, async_map_3, async_map_4, async_map_5, async_map_6):
57
61
  assert (await ((pow$(2), range(5)) |> async_map_)) |> tuple == (1, 2, 4, 8, 16)
58
62
  True
59
63
 
@@ -474,8 +474,7 @@ type Num = int | float""".strip())
474
474
  assert parse("type L[T] = list[T]").strip().endswith("""
475
475
  # Compiled Coconut: -----------------------------------------------------------
476
476
 
477
- _coconut_typevar_T_0 = _coconut.typing.TypeVar("_coconut_typevar_T_0")
478
- type L = list[_coconut_typevar_T_0]""".strip())
477
+ type L[T] = list[T]""".strip())
479
478
 
480
479
  setup(line_numbers=False, minify=True)
481
480
  assert parse("123 # derp", "lenient") == "123# derp"