coconut-develop 3.2.0.post0.dev4__tar.gz → 3.2.0.post0.dev5__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 (92) hide show
  1. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/DOCS.md +28 -32
  2. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/PKG-INFO +1 -1
  3. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/compiler/compiler.py +16 -11
  4. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/root.py +1 -1
  5. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/extras.coco +23 -17
  6. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/.claude/CLAUDE.md +0 -0
  7. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/.claude/settings.local.json +0 -0
  8. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/CONTRIBUTING.md +0 -0
  9. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/FAQ.md +0 -0
  10. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/HELP.md +0 -0
  11. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/LICENSE.txt +0 -0
  12. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/MANIFEST.in +0 -0
  13. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/README.rst +0 -0
  14. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/__coconut__/__init__.py +0 -0
  15. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/__coconut__/__init__.pyi +0 -0
  16. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/__coconut__/py.typed +0 -0
  17. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/_coconut/__init__.py +0 -0
  18. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/_coconut/__init__.pyi +0 -0
  19. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/_coconut/py.typed +0 -0
  20. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/__coconut__.py +0 -0
  21. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/__coconut__.pyi +0 -0
  22. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/__init__.py +0 -0
  23. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/__init__.pyi +0 -0
  24. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/__main__.py +0 -0
  25. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/_pyparsing.py +0 -0
  26. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/api.py +0 -0
  27. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/api.pyi +0 -0
  28. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/command/__init__.py +0 -0
  29. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/command/__init__.pyi +0 -0
  30. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/command/cli.py +0 -0
  31. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/command/command.py +0 -0
  32. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/command/command.pyi +0 -0
  33. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/command/mypy.py +0 -0
  34. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/command/resources/zcoconut.pth +0 -0
  35. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/command/util.py +0 -0
  36. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/command/watch.py +0 -0
  37. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/compiler/__init__.py +0 -0
  38. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/compiler/grammar.py +0 -0
  39. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/compiler/header.py +0 -0
  40. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/compiler/matching.py +0 -0
  41. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/compiler/templates/header.py_template +0 -0
  42. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/compiler/util.py +0 -0
  43. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/constants.py +0 -0
  44. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/convenience.py +0 -0
  45. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/convenience.pyi +0 -0
  46. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/exceptions.py +0 -0
  47. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/highlighter.py +0 -0
  48. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/icoconut/__init__.py +0 -0
  49. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/icoconut/__main__.py +0 -0
  50. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/icoconut/coconut/kernel.json +0 -0
  51. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/icoconut/coconut_py/kernel.json +0 -0
  52. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/icoconut/coconut_py2/kernel.json +0 -0
  53. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/icoconut/coconut_py3/kernel.json +0 -0
  54. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/icoconut/embed.py +0 -0
  55. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/icoconut/root.py +0 -0
  56. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/integrations.py +0 -0
  57. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/main.py +0 -0
  58. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/py.typed +0 -0
  59. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/requirements.py +0 -0
  60. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/terminal.py +0 -0
  61. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/__init__.py +0 -0
  62. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/__main__.py +0 -0
  63. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/constants_test.py +0 -0
  64. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/main_test.py +0 -0
  65. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/agnostic/__init__.coco +0 -0
  66. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/agnostic/__main__.coco +0 -0
  67. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/agnostic/main.coco +0 -0
  68. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/agnostic/primary_1.coco +0 -0
  69. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/agnostic/primary_2.coco +0 -0
  70. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/agnostic/specific.coco +0 -0
  71. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/agnostic/suite.coco +0 -0
  72. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/agnostic/tutorial.coco +0 -0
  73. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/agnostic/util.coco +0 -0
  74. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/non_strict/non_strict_test.coco +0 -0
  75. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/target_2/py2_test.coco +0 -0
  76. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/target_3/py3_test.coco +0 -0
  77. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/target_311/py311_test.coco +0 -0
  78. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/target_314/py314_test.coco +0 -0
  79. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/target_35/py35_test.coco +0 -0
  80. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/target_36/py36_test.coco +0 -0
  81. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/target_38/py38_test.coco +0 -0
  82. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/cocotest/target_sys/target_sys_test.coco +0 -0
  83. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/importable.coco +0 -0
  84. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/runnable.coco +0 -0
  85. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/tests/src/runner.coco +0 -0
  86. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut/util.py +0 -0
  87. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/coconut_develop.egg-info/SOURCES.txt +0 -0
  88. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/conf.py +0 -0
  89. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/pyproject.toml +0 -0
  90. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/setup.cfg +0 -0
  91. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/setup.py +0 -0
  92. {coconut_develop-3.2.0.post0.dev4 → coconut_develop-3.2.0.post0.dev5}/xontrib/coconut.py +0 -0
@@ -122,9 +122,9 @@ depth: 1
122
122
 
123
123
  ```
124
124
  coconut [-h] [--and source [dest ...]] [-v] [-t version] [-i] [-p] [-a] [-l]
125
- [--no-line-numbers] [-k] [-w] [-r] [-n] [-d] [-q] [-s] [--no-tco] [--no-wrap-types]
126
- [-c code] [-j processes] [-f] [--minify] [--jupyter ...] [--mypy ...] [--pyright]
127
- [--argv ...] [--tutorial] [--docs] [--style name] [--vi-mode]
125
+ [--no-line-numbers] [-k] [-w] [-r] [-n] [-d] [-q] [-s] [--pure] [--no-tco]
126
+ [--no-wrap-types] [-c code] [-j processes] [-f] [--minify] [--jupyter ...]
127
+ [--mypy ...] [--pyright] [--argv ...] [--tutorial] [--docs] [--style name] [--vi-mode]
128
128
  [--recursion-limit limit] [--stack-size kbs] [--fail-fast] [--no-cache]
129
129
  [--site-install] [--site-uninstall] [--verbose] [--trace] [--profile]
130
130
  [source] [dest]
@@ -145,8 +145,7 @@ dest destination directory for compiled files (defaults to
145
145
  --and source [dest ...]
146
146
  add an additional source/dest pair to compile (dest is optional)
147
147
  -v, -V, --version print Coconut and Python version information
148
- -t version, --target version
149
- specify target Python version (defaults to universal)
148
+ -t, --target version specify target Python version (defaults to universal)
150
149
  -i, --interact force the interpreter to start (otherwise starts if no other command is
151
150
  given) (implies --run)
152
151
  -p, --package compile source as part of a package (defaults to only if source is a
@@ -166,48 +165,45 @@ dest destination directory for compiled files (defaults to
166
165
  -n, --no-write, --nowrite
167
166
  disable writing compiled Python
168
167
  -d, --display print compiled Python
169
- -q, --quiet suppress all informational output (combine with --display to write
170
- runnable code to stdout)
168
+ -q, --quiet suppress all informational output (combine with --display to write runnable
169
+ code to stdout)
171
170
  -s, --strict enforce code cleanliness standards
171
+ --pure enforce functional programming norms
172
172
  --no-tco, --notco disable tail call optimization
173
173
  --no-wrap-types, --nowraptypes
174
174
  disable wrapping type annotations in strings and turn off 'from __future__
175
175
  import annotations' behavior
176
- -c code, --code code run Coconut passed in as a string (can also be piped into stdin)
177
- -j processes, --jobs processes
178
- number of additional processes to use (defaults to 'sys') (0 is no
179
- additional processes; 'sys' uses machine default)
180
- -f, --force force re-compilation even when source code and compilation parameters
181
- haven't changed
176
+ -c, --code code run Coconut passed in as a string (can also be piped into stdin)
177
+ -j, --jobs processes number of additional processes to use (defaults to 'sys') (0 is no additional
178
+ processes; 'sys' uses machine default)
179
+ -f, --force force re-compilation even when source code and compilation parameters haven't
180
+ changed
182
181
  --minify reduce size of compiled Python
183
- --jupyter ..., --ipython ...
182
+ --jupyter, --ipython ...
184
183
  run Jupyter/IPython with Coconut as the kernel (remaining args passed to
185
184
  Jupyter)
186
185
  --mypy ... run MyPy on compiled Python (remaining args passed to MyPy) (implies
187
186
  --package --line-numbers)
188
187
  --pyright run Pyright on compiled Python (implies --package)
189
- --argv ..., --args ...
190
- set sys.argv to source plus remaining args for use in the Coconut script
188
+ --argv, --args ... set sys.argv to source plus remaining args for use in the Coconut script
191
189
  being run
192
190
  --tutorial open Coconut's tutorial in the default web browser
193
191
  --docs, --documentation
194
192
  open Coconut's documentation in the default web browser
195
- --style name set Pygments syntax highlighting style (or 'list' to list styles)
196
- (defaults to COCONUT_STYLE environment variable if it exists, otherwise
197
- 'default')
198
- --vi-mode, --vimode enable vi mode in the interpreter (currently set to False) (can be
199
- modified by setting COCONUT_VI_MODE environment variable)
200
- --recursion-limit limit, --recursionlimit limit
201
- set maximum recursion depth in compiler (defaults to 1920) (when
202
- increasing --recursion-limit, you may also need to increase --stack-size;
203
- setting them to approximately equal values is recommended)
204
- --stack-size kbs, --stacksize kbs
205
- run the compiler in a separate thread with the given stack size in
206
- kilobytes
207
- --fail-fast causes the compiler to fail immediately upon encountering a compilation
208
- error rather than attempting to continue compiling other files
209
- --no-cache disables use of Coconut's incremental parsing cache (caches previous
210
- parses to improve recompilation performance for slightly modified files)
193
+ --style name set Pygments syntax highlighting style (or 'list' to list styles) (defaults
194
+ to COCONUT_STYLE environment variable if it exists, otherwise 'default')
195
+ --vi-mode, --vimode enable vi mode in the interpreter (currently set to False) (can be modified
196
+ by setting COCONUT_VI_MODE environment variable)
197
+ --recursion-limit, --recursionlimit limit
198
+ set maximum recursion depth in compiler (defaults to 1920) (when increasing
199
+ --recursion-limit, you may also need to increase --stack-size; setting them
200
+ to approximately equal values is recommended)
201
+ --stack-size, --stacksize kbs
202
+ run the compiler in a separate thread with the given stack size in kilobytes
203
+ --fail-fast causes the compiler to fail immediately upon encountering a compilation error
204
+ rather than attempting to continue compiling other files
205
+ --no-cache disables use of Coconut's incremental parsing cache (caches previous parses
206
+ to improve recompilation performance for slightly modified files)
211
207
  --site-install, --siteinstall
212
208
  set up coconut.api to be imported on Python start
213
209
  --site-uninstall, --siteuninstall
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: coconut-develop
3
- Version: 3.2.0.post0.dev4
3
+ Version: 3.2.0.post0.dev5
4
4
  Summary: Simple, elegant, Pythonic functional programming.
5
5
  Home-page: http://coconut-lang.org
6
6
  Author: Evan Hubinger
@@ -589,12 +589,18 @@ class Compiler(Grammar, pickleable_obj):
589
589
  temp_var_counts = None
590
590
  operators = None
591
591
 
592
+ def get_empty_scope(self):
593
+ """Get an empty scope for the parsing_context."""
594
+ return {
595
+ "final_vars": {},
596
+ "pure_vars": {},
597
+ }
598
+
592
599
  def init_parsing_context(self):
593
600
  """Initialize parsing context."""
594
601
  self.parsing_context = defaultdict(list)
595
602
  # initialize module-level scopes
596
- self.parsing_context["final_vars"].append({})
597
- self.parsing_context["pure_vars"].append({})
603
+ self.parsing_context["scope"].append(self.get_empty_scope())
598
604
  return self.parsing_context
599
605
 
600
606
  def reset(self, keep_state=False, filename=None):
@@ -5293,8 +5299,7 @@ class {protocol_var}({tokens}, _coconut.typing.Protocol): pass
5293
5299
  # handles support for class type variables
5294
5300
  with self.type_alias_stmt_manage():
5295
5301
  with self.add_to_parsing_context({
5296
- "final_vars": {},
5297
- "pure_vars": {},
5302
+ "scope": self.get_empty_scope(),
5298
5303
  }):
5299
5304
  yield
5300
5305
  finally:
@@ -5310,8 +5315,7 @@ class {protocol_var}({tokens}, _coconut.typing.Protocol): pass
5310
5315
  # handles support for function type variables
5311
5316
  with self.type_alias_stmt_manage():
5312
5317
  with self.add_to_parsing_context({
5313
- "final_vars": {},
5314
- "pure_vars": {},
5318
+ "scope": self.get_empty_scope(),
5315
5319
  }):
5316
5320
  yield
5317
5321
  finally:
@@ -5411,9 +5415,11 @@ class {protocol_var}({tokens}, _coconut.typing.Protocol): pass
5411
5415
  is_new = loc not in self.name_info[name]["referenced"]
5412
5416
  self.name_info[name]["referenced"].add(loc)
5413
5417
 
5418
+ scope = self.current_parsing_context("scope")
5419
+ self.internal_assert(scope is not None, original, loc, "no scope context")
5420
+
5414
5421
  # final variable checking (setting final_vars happens at the end)
5415
- final_vars = self.current_parsing_context("final_vars")
5416
- self.internal_assert(final_vars is not None, original, loc, "no final_vars context")
5422
+ final_vars = scope["final_vars"]
5417
5423
  if (
5418
5424
  assign
5419
5425
  and not escaped
@@ -5441,8 +5447,7 @@ class {protocol_var}({tokens}, _coconut.typing.Protocol): pass
5441
5447
 
5442
5448
  # pure variable checking (setting pure_vars happens at the end)
5443
5449
  if self.pure:
5444
- pure_vars = self.current_parsing_context("pure_vars")
5445
- self.internal_assert(pure_vars is not None, original, loc, "no pure_vars context")
5450
+ pure_vars = scope["pure_vars"]
5446
5451
  if (
5447
5452
  assign
5448
5453
  and not escaped
@@ -5514,7 +5519,7 @@ class {protocol_var}({tokens}, _coconut.typing.Protocol): pass
5514
5519
  # only mark as final after all checks pass
5515
5520
  if is_final:
5516
5521
  final_vars[name] = loc
5517
- if self.pure:
5522
+ if self.pure and assign and not escaped and not expr_setname:
5518
5523
  pure_vars[name] = loc
5519
5524
 
5520
5525
  if name == "exec":
@@ -26,7 +26,7 @@ import sys as _coconut_sys
26
26
  VERSION = "3.2.0"
27
27
  VERSION_NAME = None
28
28
  # False for release, int >= 1 for develop
29
- DEVELOP = 4
29
+ DEVELOP = 5
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"
@@ -566,12 +566,33 @@ class A:
566
566
  setup(line_numbers=False, strict=True, target="sys")
567
567
  assert_raises(-> parse("await f x"), CoconutParseError)
568
568
 
569
+ # pure tests
569
570
  setup(line_numbers=False, strict=True, pure=True, target="sys")
571
+ assert parse("""
572
+ class A:
573
+ def mk_int(x) = int(x)
574
+ """.strip())
570
575
  assert_raises(-> parse("""
571
576
  def f():
572
577
  global x
573
578
  """.strip()), CoconutStyleError, err_has="pure")
574
579
  assert_raises(-> parse("""
580
+ x = 1
581
+ x = 2
582
+ """.strip()), CoconutStyleError, err_has="pure")
583
+ assert_raises(-> parse("""
584
+ def f():
585
+ y = 1
586
+ y = 2
587
+ """.strip()), CoconutStyleError, err_has="pure")
588
+ # escape syntax should allow reassignment
589
+ parse(r"""
590
+ x = 1
591
+ \x = 2
592
+ """.strip())
593
+ # nonlocal requires target="3" since it's Python 3 only
594
+ setup(line_numbers=False, strict=True, pure=True, target="3")
595
+ assert_raises(-> parse("""
575
596
  def f():
576
597
  x = 1
577
598
  def g():
@@ -596,6 +617,8 @@ class Foo(object): # NOQA
596
617
  def f():
597
618
  global x # NOQA
598
619
  """.strip())
620
+ # nonlocal requires target="3" since it's Python 3 only
621
+ setup(line_numbers=False, strict=True, pure=True, target="3")
599
622
  parse("""
600
623
  def f():
601
624
  x = 1
@@ -603,23 +626,6 @@ def f():
603
626
  nonlocal x # NOQA
604
627
  """.strip())
605
628
 
606
- # test final variables in pure mode
607
- setup(line_numbers=False, strict=True, pure=True, target="sys")
608
- assert_raises(-> parse("""
609
- x = 1
610
- x = 2
611
- """.strip()), CoconutStyleError, err_has="pure")
612
- assert_raises(-> parse("""
613
- def f():
614
- y = 1
615
- y = 2
616
- """.strip()), CoconutStyleError, err_has="pure")
617
- # escape syntax should allow reassignment
618
- parse(r"""
619
- x = 1
620
- \x = 2
621
- """.strip())
622
-
623
629
  setup(line_numbers=False, target="2.7")
624
630
  assert parse("from io import BytesIO", mode="lenient") == "from io import BytesIO"
625
631
  assert_raises(-> parse("def f(*, x=None) = x"), CoconutTargetError, err_has="\n ^")