coconut-develop 3.1.1.post0.dev1__tar.gz → 3.1.1.post0.dev2__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.1.post0.dev2/PKG-INFO +141 -0
  2. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/compiler/compiler.py +49 -23
  3. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/constants.py +6 -1
  4. coconut-develop-3.1.1.post0.dev2/coconut/icoconut/coconut/kernel.json +11 -0
  5. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/root.py +1 -1
  6. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/agnostic/primary_1.coco +2 -2
  7. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/agnostic/tutorial.coco +4 -2
  8. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/target_2/py2_test.coco +1 -1
  9. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/extras.coco +10 -0
  10. coconut-develop-3.1.1.post0.dev1/PKG-INFO +0 -141
  11. coconut-develop-3.1.1.post0.dev1/coconut/icoconut/coconut/kernel.json +0 -11
  12. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/CONTRIBUTING.md +0 -0
  13. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/DOCS.md +0 -0
  14. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/FAQ.md +0 -0
  15. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/HELP.md +0 -0
  16. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/LICENSE.txt +0 -0
  17. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/MANIFEST.in +0 -0
  18. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/README.rst +0 -0
  19. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/__coconut__/__init__.py +0 -0
  20. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/__coconut__/__init__.pyi +0 -0
  21. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/__coconut__/py.typed +0 -0
  22. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/_coconut/__init__.py +0 -0
  23. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/_coconut/__init__.pyi +0 -0
  24. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/_coconut/py.typed +0 -0
  25. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/__coconut__.py +0 -0
  26. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/__coconut__.pyi +0 -0
  27. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/__init__.py +0 -0
  28. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/__init__.pyi +0 -0
  29. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/__main__.py +0 -0
  30. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/_pyparsing.py +0 -0
  31. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/api.py +0 -0
  32. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/api.pyi +0 -0
  33. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/command/__init__.py +0 -0
  34. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/command/__init__.pyi +0 -0
  35. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/command/cli.py +0 -0
  36. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/command/command.py +0 -0
  37. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/command/command.pyi +0 -0
  38. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/command/mypy.py +0 -0
  39. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/command/resources/zcoconut.pth +0 -0
  40. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/command/util.py +0 -0
  41. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/command/watch.py +0 -0
  42. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/compiler/__init__.py +0 -0
  43. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/compiler/grammar.py +0 -0
  44. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/compiler/header.py +0 -0
  45. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/compiler/matching.py +0 -0
  46. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/compiler/templates/header.py_template +0 -0
  47. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/compiler/util.py +0 -0
  48. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/convenience.py +0 -0
  49. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/convenience.pyi +0 -0
  50. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/exceptions.py +0 -0
  51. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/highlighter.py +0 -0
  52. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/icoconut/__init__.py +0 -0
  53. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/icoconut/__main__.py +0 -0
  54. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/icoconut/coconut_py/kernel.json +0 -0
  55. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/icoconut/coconut_py2/kernel.json +0 -0
  56. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/icoconut/coconut_py3/kernel.json +0 -0
  57. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/icoconut/embed.py +0 -0
  58. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/icoconut/root.py +0 -0
  59. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/integrations.py +0 -0
  60. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/main.py +0 -0
  61. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/py.typed +0 -0
  62. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/requirements.py +0 -0
  63. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/terminal.py +0 -0
  64. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/__init__.py +0 -0
  65. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/__main__.py +0 -0
  66. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/constants_test.py +0 -0
  67. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/main_test.py +0 -0
  68. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/agnostic/__init__.coco +0 -0
  69. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/agnostic/__main__.coco +0 -0
  70. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/agnostic/main.coco +0 -0
  71. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/agnostic/primary_2.coco +0 -0
  72. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/agnostic/specific.coco +0 -0
  73. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/agnostic/suite.coco +0 -0
  74. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/agnostic/util.coco +0 -0
  75. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/non_strict/non_strict_test.coco +0 -0
  76. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/target_3/py3_test.coco +0 -0
  77. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/target_311/py311_test.coco +0 -0
  78. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/target_35/py35_test.coco +0 -0
  79. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/target_36/py36_test.coco +0 -0
  80. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/target_38/py38_test.coco +0 -0
  81. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/cocotest/target_sys/target_sys_test.coco +0 -0
  82. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/importable.coco +0 -0
  83. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/runnable.coco +0 -0
  84. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/tests/src/runner.coco +0 -0
  85. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut/util.py +0 -0
  86. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/coconut_develop.egg-info/SOURCES.txt +0 -0
  87. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/conf.py +0 -0
  88. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/pyproject.toml +0 -0
  89. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/setup.cfg +0 -0
  90. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/setup.py +0 -0
  91. {coconut-develop-3.1.1.post0.dev1 → coconut-develop-3.1.1.post0.dev2}/xontrib/coconut.py +0 -0
@@ -0,0 +1,141 @@
1
+ Metadata-Version: 2.1
2
+ Name: coconut-develop
3
+ Version: 3.1.1.post0.dev2
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,CoconutWarning,__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: pyright
132
+ Provides-Extra: xonsh
133
+ Provides-Extra: numpy
134
+ Provides-Extra: jupyter
135
+ Provides-Extra: jupyterlab
136
+ Provides-Extra: jupytext
137
+ Provides-Extra: all
138
+ Provides-Extra: ipython
139
+ Provides-Extra: docs
140
+ Provides-Extra: tests
141
+ Provides-Extra: dev
@@ -246,12 +246,17 @@ else:
246
246
  )
247
247
 
248
248
 
249
- def imported_names(imports):
250
- """Yields all the names imported by imports = [[imp1], [imp2, as], ...]."""
249
+ def get_imported_names(imports):
250
+ """Returns all the names imported by imports = [[imp1], [imp2, as], ...] and whether there is a star import."""
251
+ saw_names = []
252
+ saw_star = False
251
253
  for imp in imports:
252
254
  imp_name = imp[-1].split(".", 1)[0]
253
- if imp_name != "*":
254
- yield imp_name
255
+ if imp_name == "*":
256
+ saw_star = True
257
+ else:
258
+ saw_names.append(imp_name)
259
+ return saw_names, saw_star
255
260
 
256
261
 
257
262
  def special_starred_import_handle(imp_all=False):
@@ -529,7 +534,8 @@ class Compiler(Grammar, pickleable_obj):
529
534
  # but always overwrite temp_vars_by_key since they store locs that will be invalidated
530
535
  self.temp_vars_by_key = {}
531
536
  self.parsing_context = defaultdict(list)
532
- self.unused_imports = defaultdict(list)
537
+ self.name_info = defaultdict(lambda: {"imported": [], "referenced": [], "assigned": []})
538
+ self.star_import = False
533
539
  self.kept_lines = []
534
540
  self.num_lines = 0
535
541
  self.disable_name_check = False
@@ -942,6 +948,11 @@ class Compiler(Grammar, pickleable_obj):
942
948
  if self.strict:
943
949
  raise self.make_err(CoconutStyleError, *args, **kwargs)
944
950
 
951
+ def strict_warn(self, *args, **kwargs):
952
+ internal_assert("extra" not in kwargs, "cannot pass extra=... to strict_warn")
953
+ if self.strict:
954
+ self.syntax_warning(*args, extra="remove --strict to dismiss", **kwargs)
955
+
945
956
  def syntax_warning(self, message, original, loc, **kwargs):
946
957
  """Show a CoconutSyntaxWarning. Usage:
947
958
  self.syntax_warning(message, original, loc)
@@ -1319,21 +1330,30 @@ class Compiler(Grammar, pickleable_obj):
1319
1330
  elif inputstring is not None and not inner:
1320
1331
  logger.log("No streamlining done for input of length {length}.".format(length=input_len))
1321
1332
 
1333
+ def qa_error(self, msg, original, loc):
1334
+ """Strict error or warn an error that should be disabled by a NOQA comment."""
1335
+ ln = self.adjust(lineno(loc, original))
1336
+ comment = self.reformat(" ".join(self.comments[ln]), ignore_errors=True)
1337
+ if not self.noqa_regex.search(comment):
1338
+ self.strict_err_or_warn(
1339
+ msg + " (add '# NOQA' to suppress)",
1340
+ original,
1341
+ loc,
1342
+ endpoint=False,
1343
+ )
1344
+
1322
1345
  def run_final_checks(self, original, keep_state=False):
1323
1346
  """Run post-parsing checks to raise any necessary errors/warnings."""
1324
- # only check for unused imports if we're not keeping state accross parses
1347
+ # only check for unused imports/etc. if we're not keeping state accross parses
1325
1348
  if not keep_state:
1326
- for name, locs in self.unused_imports.items():
1327
- for loc in locs:
1328
- ln = self.adjust(lineno(loc, original))
1329
- comment = self.reformat(" ".join(self.comments[ln]), ignore_errors=True)
1330
- if not self.noqa_regex.search(comment):
1331
- self.strict_err_or_warn(
1332
- "found unused import " + repr(self.reformat(name, ignore_errors=True)) + " (add '# NOQA' to suppress)",
1333
- original,
1334
- loc,
1335
- endpoint=False,
1336
- )
1349
+ for name, info in self.name_info.items():
1350
+ if info["imported"] and not info["referenced"]:
1351
+ for loc in info["imported"]:
1352
+ self.qa_error("found unused import " + repr(self.reformat(name, ignore_errors=True)), original, loc)
1353
+ if not self.star_import: # only check for undefined names when there are no * imports
1354
+ if name not in all_builtins and info["referenced"] and not (info["assigned"] or info["imported"]):
1355
+ for loc in info["referenced"]:
1356
+ self.qa_error("found undefined name " + repr(self.reformat(name, ignore_errors=True)), original, loc)
1337
1357
 
1338
1358
  def parse_line_by_line(self, init_parser, line_parser, original):
1339
1359
  """Apply init_parser then line_parser repeatedly."""
@@ -3731,13 +3751,17 @@ if {store_var} is not _coconut_sentinel:
3731
3751
  else:
3732
3752
  raise CoconutInternalException("invalid import tokens", tokens)
3733
3753
  imports = list(imports)
3734
- if imp_from == "*" or imp_from is None and "*" in imports:
3754
+ imported_names, star_import = get_imported_names(imports)
3755
+ self.star_import = self.star_import or star_import
3756
+ if star_import:
3757
+ self.strict_warn("found * import; these disable Coconut's undefined name detection", original, loc)
3758
+ if imp_from == "*" or (imp_from is None and star_import):
3735
3759
  if not (len(imports) == 1 and imports[0] == "*"):
3736
3760
  raise self.make_err(CoconutSyntaxError, "only [from *] import * allowed, not from * import name", original, loc)
3737
3761
  self.syntax_warning("[from *] import * is a Coconut Easter egg and should not be used in production code", original, loc)
3738
3762
  return special_starred_import_handle(imp_all=bool(imp_from))
3739
- for imp_name in imported_names(imports):
3740
- self.unused_imports[imp_name].append(loc)
3763
+ for imp_name in imported_names:
3764
+ self.name_info[imp_name]["imported"].append(loc)
3741
3765
  return self.universal_import(loc, imports, imp_from=imp_from)
3742
3766
 
3743
3767
  def complex_raise_stmt_handle(self, loc, tokens):
@@ -4575,7 +4599,7 @@ async with {iter_item} as {temp_var}:
4575
4599
  return tokens[0]
4576
4600
  else:
4577
4601
  if not allow_silent_concat:
4578
- self.strict_err_or_warn("found Python-style implicit string concatenation (use explicit '+' instead)", original, loc)
4602
+ self.strict_err_or_warn("found implicit string concatenation (use explicit '+' instead)", original, loc)
4579
4603
  if any(s.endswith(")") for s in tokens): # has .format() calls
4580
4604
  # parens are necessary for string_atom_handle
4581
4605
  return "(" + " + ".join(tokens) + ")"
@@ -4989,8 +5013,10 @@ class {protocol_var}({tokens}, _coconut.typing.Protocol): pass
4989
5013
  )
4990
5014
  return typevars[name]
4991
5015
 
4992
- if not assign:
4993
- self.unused_imports.pop(name, None)
5016
+ if assign:
5017
+ self.name_info[name]["assigned"].append(loc)
5018
+ else:
5019
+ self.name_info[name]["referenced"].append(loc)
4994
5020
 
4995
5021
  if (
4996
5022
  assign
@@ -607,15 +607,20 @@ python_builtins = (
607
607
  "tuple", "type",
608
608
  "vars",
609
609
  "zip",
610
+ 'Ellipsis',
610
611
  "__import__",
611
612
  '__name__',
612
613
  '__file__',
613
614
  '__annotations__',
614
615
  '__debug__',
616
+ '__build_class__',
617
+ '__loader__',
618
+ '__package__',
619
+ '__spec__',
615
620
  )
616
621
 
617
622
  python_exceptions = (
618
- "BaseException", "BaseExceptionGroup", "GeneratorExit", "KeyboardInterrupt", "SystemExit", "Exception", "ArithmeticError", "FloatingPointError", "OverflowError", "ZeroDivisionError", "AssertionError", "AttributeError", "BufferError", "EOFError", "ExceptionGroup", "BaseExceptionGroup", "ImportError", "ModuleNotFoundError", "LookupError", "IndexError", "KeyError", "MemoryError", "NameError", "UnboundLocalError", "OSError", "BlockingIOError", "ChildProcessError", "ConnectionError", "BrokenPipeError", "ConnectionAbortedError", "ConnectionRefusedError", "ConnectionResetError", "FileExistsError", "FileNotFoundError", "InterruptedError", "IsADirectoryError", "NotADirectoryError", "PermissionError", "ProcessLookupError", "TimeoutError", "ReferenceError", "RuntimeError", "NotImplementedError", "RecursionError", "StopAsyncIteration", "StopIteration", "SyntaxError", "IndentationError", "TabError", "SystemError", "TypeError", "ValueError", "UnicodeError", "UnicodeDecodeError", "UnicodeEncodeError", "UnicodeTranslateError", "Warning", "BytesWarning", "DeprecationWarning", "EncodingWarning", "FutureWarning", "ImportWarning", "PendingDeprecationWarning", "ResourceWarning", "RuntimeWarning", "SyntaxWarning", "UnicodeWarning", "UserWarning",
623
+ 'ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BaseExceptionGroup', 'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning', 'ChildProcessError', 'ConnectionAbortedError', 'ConnectionError', 'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning', 'EOFError', 'EncodingWarning', 'EnvironmentError', 'Exception', 'ExceptionGroup', 'FileExistsError', 'FileNotFoundError', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError', 'IsADirectoryError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'ModuleNotFoundError', 'NameError', 'NotADirectoryError', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError', 'RecursionError', 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning', 'StopAsyncIteration', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TimeoutError', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError'
619
624
  )
620
625
 
621
626
  always_keep_parse_name_prefix = "HAS_"
@@ -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.1"
27
27
  VERSION_NAME = None
28
28
  # False for release, int >= 1 for develop
29
- DEVELOP = 1
29
+ DEVELOP = 2
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"
@@ -90,7 +90,7 @@ def primary_test_1() -> bool:
90
90
  \\assert data == 3
91
91
  \\def backslash_test():
92
92
  return (x) -> x
93
- assert \(1) == 1 == backslash_test()(1)
93
+ assert \(1) == 1 == backslash_test()(1) # NOQA
94
94
  assert True is (\(
95
95
  "hello"
96
96
  ) == "hello" == \(
@@ -100,7 +100,7 @@ def primary_test_1() -> bool:
100
100
  x,
101
101
  y):
102
102
  return x + y
103
- assert multiline_backslash_test(1, 2) == 3
103
+ assert multiline_backslash_test(1, 2) == 3 # noqa
104
104
  \\ assert True
105
105
  class one_line_class: pass
106
106
  assert isinstance(one_line_class(), one_line_class)
@@ -22,13 +22,15 @@ assert range(1, 5) |> product == 24
22
22
  first_five_words = .split() ..> .$[:5] ..> " ".join
23
23
  assert first_five_words("ab cd ef gh ij kl") == "ab cd ef gh ij"
24
24
 
25
- @recursive_iterator
25
+ # TODO: recursive_iterator -> recursive_generator
26
+ @recursive_iterator # noqa
26
27
  def fib() = (1, 1) :: map((+), fib(), fib()$[1:])
27
28
  assert fib()$[:5] |> list == [1, 1, 2, 3, 5]
28
29
 
30
+ # TODO: parallel_map -> process_map
29
31
  # can't use parallel_map here otherwise each process would have to rerun all
30
32
  # the tutorial tests since we don't guard them behind __name__ == "__main__"
31
- assert range(100) |> concurrent_map$(.**2) |> list |> .$[-1] == 9801
33
+ assert range(100) |> thread_map$(.**2) |> list |> .$[-1] == 9801
32
34
 
33
35
  def factorial(n, acc=1):
34
36
  match n:
@@ -4,5 +4,5 @@ def py2_test() -> bool:
4
4
  assert py_map((+)$(2), range(5)) == [2, 3, 4, 5, 6]
5
5
  assert py_range(5) == [0, 1, 2, 3, 4]
6
6
  assert not isinstance(long(1), py_int) # type: ignore
7
- assert py_str(3) == b"3" == unicode(b"3") # type: ignore
7
+ assert py_str(3) == b"3" == unicode(b"3") # noqa # type: ignore
8
8
  return True
@@ -414,6 +414,16 @@ import abc
414
414
  except CoconutStyleError as err:
415
415
  assert str(err) == """found unused import 'abc' (add '# NOQA' to suppress) (remove --strict to downgrade to a warning) (line 1)
416
416
  import abc"""
417
+ try:
418
+ parse("""
419
+ 1
420
+ 2 + x
421
+ 3
422
+ """.strip())
423
+ except CoconutStyleError as err:
424
+ assert str(err) == """found undefined name 'x' (add '# NOQA' to suppress) (remove --strict to downgrade to a warning) (line 2)
425
+ 2 + x
426
+ ^"""
417
427
  assert_raises(-> parse("""
418
428
  class A(object):
419
429
  1
@@ -1,141 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: coconut-develop
3
- Version: 3.1.1.post0.dev1
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
- 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,CoconutWarning,__fmap__,__iter_getitem__,data,match,case,cases,where,addpattern,then,operator,type,copyclosure,λ
10
- Classifier: Development Status :: 5 - Production/Stable
11
- Classifier: License :: OSI Approved :: Apache Software License
12
- Classifier: Intended Audience :: Developers
13
- Classifier: Topic :: Software Development
14
- Classifier: Topic :: Software Development :: Code Generators
15
- Classifier: Topic :: Software Development :: Compilers
16
- Classifier: Topic :: Software Development :: Interpreters
17
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
- Classifier: Topic :: Utilities
19
- Classifier: Environment :: Console
20
- Classifier: Operating System :: OS Independent
21
- Classifier: Programming Language :: Python
22
- Classifier: Programming Language :: Python :: 2
23
- Classifier: Programming Language :: Python :: 2.6
24
- Classifier: Programming Language :: Python :: 2.7
25
- Classifier: Programming Language :: Python :: 3
26
- Classifier: Programming Language :: Python :: 3.2
27
- Classifier: Programming Language :: Python :: 3.3
28
- Classifier: Programming Language :: Python :: 3.4
29
- Classifier: Programming Language :: Python :: 3.5
30
- Classifier: Programming Language :: Python :: 3.6
31
- Classifier: Programming Language :: Python :: 3.7
32
- Classifier: Programming Language :: Python :: 3.8
33
- Classifier: Programming Language :: Python :: 3.9
34
- Classifier: Programming Language :: Python :: 3.10
35
- Classifier: Programming Language :: Python :: 3.11
36
- Classifier: Programming Language :: Python :: 3.12
37
- Classifier: Programming Language :: Other
38
- Classifier: Programming Language :: Other Scripting Engines
39
- Classifier: Programming Language :: Python :: Implementation :: CPython
40
- Classifier: Programming Language :: Python :: Implementation :: PyPy
41
- Classifier: Framework :: IPython
42
- Classifier: Framework :: Jupyter
43
- Classifier: Typing :: Typed
44
- Provides-Extra: kernel
45
- Provides-Extra: watch
46
- Provides-Extra: mypy
47
- Provides-Extra: pyright
48
- Provides-Extra: xonsh
49
- Provides-Extra: numpy
50
- Provides-Extra: jupyter
51
- Provides-Extra: jupyterlab
52
- Provides-Extra: jupytext
53
- Provides-Extra: all
54
- Provides-Extra: ipython
55
- Provides-Extra: docs
56
- Provides-Extra: tests
57
- Provides-Extra: dev
58
- License-File: LICENSE.txt
59
-
60
- |logo| Coconut
61
- ==============
62
-
63
- ..
64
- <insert toctree here>
65
-
66
- .. |logo| image:: https://github.com/evhub/coconut/raw/gh-pages/favicon-32x32.png
67
-
68
- .. image:: https://opencollective.com/coconut/backers/badge.svg
69
- :alt: Backers on Open Collective
70
- :target: #backers
71
- .. image:: https://opencollective.com/coconut/sponsors/badge.svg
72
- :alt: Sponsors on Open Collective
73
- :target: #sponsors
74
- .. image:: https://badges.gitter.im/evhub/coconut.svg
75
- :alt: Join the chat at https://gitter.im/evhub/coconut
76
- :target: https://gitter.im/evhub/coconut?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
77
-
78
- Coconut (`coconut-lang.org`__) is a variant of Python_ that **adds on top of Python syntax** new features for simple, elegant, Pythonic **functional programming**.
79
-
80
- __ Coconut_
81
- .. _Coconut: http://coconut-lang.org/
82
-
83
- Coconut is developed on GitHub_ and hosted on PyPI_. Installing Coconut is as easy as opening a command prompt and entering::
84
-
85
- pip install coconut
86
-
87
- To help you get started, check out these links for more information about Coconut:
88
-
89
- - Tutorial_: If you're new to Coconut, a good place to start is Coconut's **tutorial**.
90
- - Documentation_: If you're looking for info about a specific feature, check out Coconut's **documentation**.
91
- - `Online Interpreter`_: If you want to try Coconut in your browser, check out Coconut's **online interpreter**.
92
- - 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.
93
- - `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.
94
- - 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.
95
- - Releases_: Want to know what's been added in recent Coconut versions? Check out the release log for all the new features and fixes.
96
-
97
- .. _Python: https://www.python.org/
98
- .. _PyPI: https://pypi.python.org/pypi/coconut
99
- .. _Tutorial: http://coconut.readthedocs.io/en/latest/HELP.html
100
- .. _Documentation: http://coconut.readthedocs.io/en/latest/DOCS.html
101
- .. _`Online Interpreter`: https://cs121-team-panda.github.io/coconut-interpreter
102
- .. _FAQ: http://coconut.readthedocs.io/en/latest/FAQ.html
103
- .. _GitHub: https://github.com/evhub/coconut
104
- .. _Gitter: https://gitter.im/evhub/coconut
105
- .. _Releases: https://github.com/evhub/coconut/releases
106
-
107
- Credits
108
- +++++++
109
-
110
- Contributors
111
- ------------
112
-
113
- This project exists thanks to all the people who contribute! `Become a contributor`__.
114
-
115
- .. image:: https://opencollective.com/coconut/contributors.svg?width=890&button=false
116
- :target: https://github.com/evhub/coconut/graphs/contributors
117
-
118
- __ Contributor_
119
- .. _Contributor: http://coconut.readthedocs.io/en/develop/CONTRIBUTING.html
120
-
121
- Backers
122
- -------
123
-
124
- Thank you to all our backers! `Become a backer`__.
125
-
126
- .. image:: https://opencollective.com/coconut/backers.svg?width=890
127
- :target: https://opencollective.com/coconut#backers
128
-
129
- __ Backer_
130
- .. _Backer: https://opencollective.com/coconut#backer
131
-
132
- Sponsors
133
- --------
134
-
135
- Support Coconut by becoming a sponsor. Your logo will show up here with a link to your website. `Become a sponsor`__.
136
-
137
- .. image:: https://opencollective.com/XX/sponsor/0/avatar.svg
138
- :target: https://opencollective.com/coconut/sponsor/0/website
139
-
140
- __ Sponsor_
141
- .. _Sponsor: https://opencollective.com/coconut#sponsor
@@ -1,11 +0,0 @@
1
- {
2
- "argv": [
3
- "python",
4
- "-m",
5
- "coconut.icoconut",
6
- "-f",
7
- "{connection_file}"
8
- ],
9
- "display_name": "Coconut",
10
- "language": "coconut"
11
- }