Skip to content

Commit e8dd479

Browse files
authored
Release v3.0.4 (#806)
2 parents dbec988 + d2191ee commit e8dd479

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+6116
-3612
lines changed

.github/workflows/run-tests.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,26 @@ jobs:
77
matrix:
88
python-version:
99
- '2.7'
10-
- '3.4'
1110
- '3.5'
1211
- '3.6'
1312
- '3.7'
1413
- '3.8'
1514
- '3.9'
1615
- '3.10'
1716
- '3.11'
17+
- '3.12'
1818
- 'pypy-2.7'
1919
- 'pypy-3.6'
2020
- 'pypy-3.7'
2121
- 'pypy-3.8'
2222
- 'pypy-3.9'
23+
- 'pypy-3.10'
2324
fail-fast: false
2425
name: Python ${{ matrix.python-version }}
2526
steps:
2627
- uses: actions/checkout@v3
2728
- name: Setup python
28-
uses: MatteoH2O1999/setup-python@v1.3.1
29+
uses: MatteoH2O1999/setup-python@v2
2930
with:
3031
python-version: ${{ matrix.python-version }}
3132
cache: pip

.gitignore

+7-1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ pyprover/
138138
bbopt/
139139
coconut-prelude/
140140
index.rst
141-
vprof.json
142141
/coconut/icoconut/coconut/
143142
__coconut_cache__/
143+
144+
# Profiling
145+
vprof.json
146+
profile.svg
147+
profile.speedscope
148+
runtime_profile.svg
149+
runtime_profile.speedscope

.pre-commit-config.yaml

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
repos:
2+
- repo: https://github.com/pre-commit/mirrors-autopep8
3+
rev: v2.0.4
4+
hooks:
5+
- id: autopep8
6+
args:
7+
- --in-place
8+
- --aggressive
9+
- --aggressive
10+
- --experimental
11+
- --ignore=W503,E501,E722,E402,E721
212
- repo: https://github.com/pre-commit/pre-commit-hooks.git
3-
rev: v4.4.0
13+
rev: v4.5.0
414
hooks:
515
- id: check-added-large-files
616
- id: fix-byte-order-marker
@@ -24,18 +34,8 @@ repos:
2434
args:
2535
- --autofix
2636
- repo: https://github.com/pycqa/flake8
27-
rev: 6.0.0
37+
rev: 6.1.0
2838
hooks:
2939
- id: flake8
3040
args:
3141
- --ignore=W503,E501,E265,E402,F405,E305,E126
32-
- repo: https://github.com/pre-commit/mirrors-autopep8
33-
rev: v2.0.2
34-
hooks:
35-
- id: autopep8
36-
args:
37-
- --in-place
38-
- --aggressive
39-
- --aggressive
40-
- --experimental
41-
- --ignore=W503,E501,E722,E402

.readthedocs.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,3 @@ python:
3232
path: .
3333
extra_requirements:
3434
- docs
35-
system_packages: true

DOCS.md

+419-204
Large diffs are not rendered by default.

FAQ.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ Information on every Coconut release is chronicled on the [GitHub releases page]
3434

3535
Yes! Coconut compiles the [newest](https://www.python.org/dev/peps/pep-0526/), [fanciest](https://www.python.org/dev/peps/pep-0484/) type annotation syntax into version-independent type comments which can then by checked using Coconut's built-in [MyPy Integration](./DOCS.md#mypy-integration).
3636

37-
### Help! I tried to write a recursive iterator and my Python segfaulted!
37+
### Help! I tried to write a recursive generator and my Python segfaulted!
3838

39-
No problem—just use Coconut's [`recursive_iterator`](./DOCS.md#recursive-iterator) decorator and you should be fine. This is a [known Python issue](http://bugs.python.org/issue14010) but `recursive_iterator` will fix it for you.
39+
No problem—just use Coconut's [`recursive_generator`](./DOCS.md#recursive_generator) decorator and you should be fine. This is a [known Python issue](http://bugs.python.org/issue14010) but `recursive_generator` will fix it for you.
4040

4141
### How do I split an expression across multiple lines in Coconut?
4242

Makefile

+121-42
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,37 @@ dev-py3: clean setup-py3
2525

2626
.PHONY: setup
2727
setup:
28-
python -m ensurepip
28+
-python -m ensurepip
2929
python -m pip install --upgrade setuptools wheel pip pytest_remotedata cython
3030

3131
.PHONY: setup-py2
3232
setup-py2:
33-
python2 -m ensurepip
33+
-python2 -m ensurepip
3434
python2 -m pip install --upgrade "setuptools<58" wheel pip pytest_remotedata cython
3535

3636
.PHONY: setup-py3
3737
setup-py3:
38-
python3 -m ensurepip
38+
-python3 -m ensurepip
3939
python3 -m pip install --upgrade setuptools wheel pip pytest_remotedata cython
4040

4141
.PHONY: setup-pypy
4242
setup-pypy:
43-
pypy -m ensurepip
43+
-pypy -m ensurepip
4444
pypy -m pip install --upgrade "setuptools<58" wheel pip pytest_remotedata
4545

4646
.PHONY: setup-pypy3
4747
setup-pypy3:
48-
pypy3 -m ensurepip
48+
-pypy3 -m ensurepip
4949
pypy3 -m pip install --upgrade setuptools wheel pip pytest_remotedata
5050

5151
.PHONY: install
5252
install: setup
5353
python -m pip install -e .[tests]
5454

55+
.PHONY: install-purepy
56+
install-purepy: setup
57+
python -m pip install --no-deps --upgrade -e . "pyparsing<3"
58+
5559
.PHONY: install-py2
5660
install-py2: setup-py2
5761
python2 -m pip install -e .[tests]
@@ -127,39 +131,54 @@ test-pypy3: clean
127131
pypy3 ./coconut/tests/dest/runner.py
128132
pypy3 ./coconut/tests/dest/extras.py
129133

134+
# same as test-univ but reverses any ofs
135+
.PHONY: test-any-of
136+
test-any-of: export COCONUT_ADAPTIVE_ANY_OF=TRUE
137+
test-any-of: export COCONUT_REVERSE_ANY_OF=TRUE
138+
test-any-of: test-univ
139+
130140
# same as test-univ but also runs mypy
131141
.PHONY: test-mypy-univ
132142
test-mypy-univ: export COCONUT_USE_COLOR=TRUE
133143
test-mypy-univ: clean
134-
python ./coconut/tests --strict --force --keep-lines --mypy --follow-imports silent --ignore-missing-imports --allow-redefinition
144+
python ./coconut/tests --strict --keep-lines --force --mypy --follow-imports silent --ignore-missing-imports --allow-redefinition
135145
python ./coconut/tests/dest/runner.py
136146
python ./coconut/tests/dest/extras.py
137147

138148
# same as test-mypy-univ but uses --target sys
139149
.PHONY: test-mypy
140150
test-mypy: export COCONUT_USE_COLOR=TRUE
141151
test-mypy: clean
142-
python ./coconut/tests --strict --force --target sys --keep-lines --mypy --follow-imports silent --ignore-missing-imports --allow-redefinition
152+
python ./coconut/tests --strict --keep-lines --force --target sys --mypy --follow-imports silent --ignore-missing-imports --allow-redefinition
143153
python ./coconut/tests/dest/runner.py
144154
python ./coconut/tests/dest/extras.py
145155

146156
# same as test-mypy but doesn't use --force
147157
.PHONY: test-mypy-tests
148158
test-mypy-tests: export COCONUT_USE_COLOR=TRUE
149159
test-mypy-tests: clean-no-tests
150-
python ./coconut/tests --strict --target sys --keep-lines --mypy --follow-imports silent --ignore-missing-imports --allow-redefinition
160+
python ./coconut/tests --strict --keep-lines --target sys --mypy --follow-imports silent --ignore-missing-imports --allow-redefinition
151161
python ./coconut/tests/dest/runner.py
152162
python ./coconut/tests/dest/extras.py
153163

154164
# same as test-univ but includes verbose output for better debugging
165+
# regex for getting non-timing lines: ^(?!\s*(Time|Packrat|Loaded|Saving|Adaptive|Errorless|Grammar|Failed|Incremental|Pruned)\s)[^\n]*\n*
155166
.PHONY: test-verbose
156167
test-verbose: export COCONUT_USE_COLOR=TRUE
157168
test-verbose: clean
158169
python ./coconut/tests --strict --keep-lines --force --verbose
159170
python ./coconut/tests/dest/runner.py
160171
python ./coconut/tests/dest/extras.py
161172

162-
# same as test-univ but includes verbose output for better debugging and is fully synchronous
173+
# same as test-verbose but doesn't use the incremental cache
174+
.PHONY: test-verbose-no-cache
175+
test-verbose-no-cache: export COCONUT_USE_COLOR=TRUE
176+
test-verbose-no-cache: clean
177+
python ./coconut/tests --strict --keep-lines --force --verbose --no-cache
178+
python ./coconut/tests/dest/runner.py
179+
python ./coconut/tests/dest/extras.py
180+
181+
# same as test-verbose but is fully synchronous
163182
.PHONY: test-verbose-sync
164183
test-verbose-sync: export COCONUT_USE_COLOR=TRUE
165184
test-verbose-sync: clean
@@ -171,15 +190,15 @@ test-verbose-sync: clean
171190
.PHONY: test-mypy-verbose
172191
test-mypy-verbose: export COCONUT_USE_COLOR=TRUE
173192
test-mypy-verbose: clean
174-
python ./coconut/tests --strict --force --target sys --verbose --keep-lines --mypy --follow-imports silent --ignore-missing-imports --allow-redefinition
193+
python ./coconut/tests --strict --keep-lines --force --target sys --verbose --mypy --follow-imports silent --ignore-missing-imports --allow-redefinition
175194
python ./coconut/tests/dest/runner.py
176195
python ./coconut/tests/dest/extras.py
177196

178197
# same as test-mypy but uses --check-untyped-defs
179198
.PHONY: test-mypy-all
180199
test-mypy-all: export COCONUT_USE_COLOR=TRUE
181200
test-mypy-all: clean
182-
python ./coconut/tests --strict --force --target sys --keep-lines --mypy --follow-imports silent --ignore-missing-imports --allow-redefinition --check-untyped-defs
201+
python ./coconut/tests --strict --keep-lines --force --target sys --mypy --follow-imports silent --ignore-missing-imports --allow-redefinition --check-untyped-defs
183202
python ./coconut/tests/dest/runner.py
184203
python ./coconut/tests/dest/extras.py
185204

@@ -192,9 +211,14 @@ test-easter-eggs: clean
192211
python ./coconut/tests/dest/extras.py
193212

194213
# same as test-univ but uses python pyparsing
195-
.PHONY: test-pyparsing
196-
test-pyparsing: export COCONUT_PURE_PYTHON=TRUE
197-
test-pyparsing: test-univ
214+
.PHONY: test-purepy
215+
test-purepy: export COCONUT_PURE_PYTHON=TRUE
216+
test-purepy: test-univ
217+
218+
# same as test-univ but disables the computation graph
219+
.PHONY: test-no-computation-graph
220+
test-no-computation-graph: export COCONUT_USE_COMPUTATION_GRAPH=FALSE
221+
test-no-computation-graph: test-univ
198222

199223
# same as test-univ but uses --minify
200224
.PHONY: test-minify
@@ -217,30 +241,60 @@ test-no-wrap: clean
217241
test-watch: export COCONUT_USE_COLOR=TRUE
218242
test-watch: clean
219243
python ./coconut/tests --strict --keep-lines --force
220-
coconut ./coconut/tests/src/cocotest/agnostic ./coconut/tests/dest/cocotest --watch --strict --keep-lines --stack-size 4096 --recursion-limit 4096
244+
make just-watch
221245
python ./coconut/tests/dest/runner.py
222246
python ./coconut/tests/dest/extras.py
223247

224-
# mini test that just compiles agnostic tests with fully synchronous output
248+
# just watches tests
249+
.PHONY: just-watch
250+
just-watch: export COCONUT_USE_COLOR=TRUE
251+
just-watch:
252+
coconut ./coconut/tests/src/cocotest/agnostic ./coconut/tests/dest/cocotest --watch --strict --keep-lines --stack-size 4096 --recursion-limit 4096
253+
254+
# same as just-watch but uses verbose output and is fully sychronous and doesn't use the cache
255+
.PHONY: just-watch-verbose
256+
just-watch-verbose: export COCONUT_USE_COLOR=TRUE
257+
just-watch-verbose:
258+
coconut ./coconut/tests/src/cocotest/agnostic ./coconut/tests/dest/cocotest --watch --strict --keep-lines --stack-size 4096 --recursion-limit 4096 --verbose --jobs 0 --no-cache
259+
260+
# mini test that just compiles agnostic tests
225261
.PHONY: test-mini
262+
test-mini: export COCONUT_USE_COLOR=TRUE
226263
test-mini:
227-
coconut ./coconut/tests/src/cocotest/agnostic ./coconut/tests/dest/cocotest --force --jobs 0 --stack-size 4096 --recursion-limit 4096
264+
coconut ./coconut/tests/src/cocotest/agnostic ./coconut/tests/dest/cocotest --force --stack-size 4096 --recursion-limit 4096
265+
266+
# same as test-mini but with verbose output
267+
.PHONY: test-mini-verbose
268+
test-mini-verbose: export COCONUT_USE_COLOR=TRUE
269+
test-mini-verbose:
270+
coconut ./coconut/tests/src/cocotest/agnostic ./coconut/tests/dest/cocotest --force --verbose --stack-size 4096 --recursion-limit 4096
271+
272+
# same as test-mini-verbose but doesn't overwrite the cache
273+
.PHONY: test-mini-cache
274+
test-mini-cache: export COCONUT_ALLOW_SAVE_TO_CACHE=FALSE
275+
test-mini-cache: test-mini-verbose
276+
277+
# same as test-mini-verbose but with fully synchronous output and fast failing
278+
.PHONY: test-mini-sync
279+
test-mini-sync: export COCONUT_USE_COLOR=TRUE
280+
test-mini-sync:
281+
coconut ./coconut/tests/src/cocotest/agnostic ./coconut/tests/dest/cocotest --force --verbose --jobs 0 --fail-fast --stack-size 4096 --recursion-limit 4096
228282

229283
# same as test-univ but debugs crashes
230284
.PHONY: test-univ-debug
231285
test-univ-debug: export COCONUT_TEST_DEBUG_PYTHON=TRUE
232286
test-univ-debug: test-univ
233287

234-
# same as test-mini but debugs crashes
288+
# same as test-mini but debugs crashes, is fully synchronous, and doesn't use verbose output
235289
.PHONY: test-mini-debug
236290
test-mini-debug: export COCONUT_USE_COLOR=TRUE
237291
test-mini-debug:
238292
python -X dev -m coconut ./coconut/tests/src/cocotest/agnostic ./coconut/tests/dest/cocotest --strict --keep-lines --force --jobs 0 --stack-size 4096 --recursion-limit 4096
239293

240294
# same as test-mini-debug but uses vanilla pyparsing
241-
.PHONY: test-mini-debug-pyparsing
242-
test-mini-debug-pyparsing: export COCONUT_PURE_PYTHON=TRUE
243-
test-mini-debug-pyparsing: test-mini-debug
295+
.PHONY: test-mini-debug-purepy
296+
test-mini-debug-purepy: export COCONUT_PURE_PYTHON=TRUE
297+
test-mini-debug-purepy: test-mini-debug
244298

245299
.PHONY: debug-test-crash
246300
debug-test-crash:
@@ -266,16 +320,16 @@ clean-no-tests:
266320
.PHONY: clean
267321
clean: clean-no-tests
268322
rm -rf ./coconut/tests/dest
323+
-find . -name "__coconut_cache__" -type d -prune -exec rm -rf '{}' +
324+
-powershell -Command "get-childitem -Include __coconut_cache__ -Recurse -force | Remove-Item -Force -Recurse"
269325

270326
.PHONY: wipe
271327
wipe: clean
272328
rm -rf ./coconut/tests/dest vprof.json profile.log *.egg-info
273-
-find . -name "__pycache__" -delete
274-
-C:/GnuWin32/bin/find.exe . -name "__pycache__" -delete
275-
-find . -name "__coconut_cache__" -delete
276-
-C:/GnuWin32/bin/find.exe . -name "__coconut_cache__" -delete
329+
-find . -name "__pycache__" -type d -prune -exec rm -rf '{}' +
330+
-powershell -Command "get-childitem -Include __pycache__ -Recurse -force | Remove-Item -Force -Recurse"
277331
-find . -name "*.pyc" -delete
278-
-C:/GnuWin32/bin/find.exe . -name "*.pyc" -delete
332+
-powershell -Command "get-childitem -Include *.pyc -Recurse -force | Remove-Item -Force -Recurse"
279333
-python -m coconut --site-uninstall
280334
-python3 -m coconut --site-uninstall
281335
-python2 -m coconut --site-uninstall
@@ -302,20 +356,45 @@ upload: wipe dev just-upload
302356
check-reqs:
303357
python ./coconut/requirements.py
304358

305-
.PHONY: profile-parser
306-
profile-parser: export COCONUT_USE_COLOR=TRUE
307-
profile-parser: export COCONUT_PURE_PYTHON=TRUE
308-
profile-parser:
309-
coconut ./coconut/tests/src/cocotest/agnostic ./coconut/tests/dest/cocotest --force --profile --verbose --stack-size 4096 --recursion-limit 4096 2>&1 | tee ./profile.log
310-
311-
.PHONY: profile-time
312-
profile-time:
313-
vprof -c h "./coconut ./coconut/tests/src/cocotest/agnostic ./coconut/tests/dest/cocotest --force --stack-size 4096 --recursion-limit 4096" --output-file ./vprof.json
314-
315-
.PHONY: profile-memory
316-
profile-memory:
317-
vprof -c m "./coconut ./coconut/tests/src/cocotest/agnostic ./coconut/tests/dest/cocotest --force --stack-size 4096 --recursion-limit 4096" --output-file ./vprof.json
318-
319-
.PHONY: view-profile
320-
view-profile:
359+
.PHONY: profile
360+
profile: export COCONUT_USE_COLOR=TRUE
361+
profile:
362+
coconut ./coconut/tests/src/cocotest/agnostic/util.coco ./coconut/tests/dest/cocotest --force --jobs 0 --profile --verbose --stack-size 4096 --recursion-limit 4096 2>&1 | tee ./profile.log
363+
364+
.PHONY: open-speedscope
365+
open-speedscope:
366+
npm install -g speedscope
367+
speedscope ./profile.speedscope
368+
369+
.PHONY: pyspy
370+
pyspy:
371+
py-spy record -o profile.speedscope --format speedscope --subprocesses --rate 75 -- python -m coconut ./coconut/tests/src/cocotest/agnostic ./coconut/tests/dest/cocotest --force
372+
make open-speedscope
373+
374+
.PHONY: pyspy-purepy
375+
pyspy-purepy: export COCONUT_PURE_PYTHON=TRUE
376+
pyspy-purepy: pyspy
377+
378+
.PHONY: pyspy-native
379+
pyspy-native:
380+
py-spy record -o profile.speedscope --format speedscope --native --rate 75 -- python -m coconut ./coconut/tests/src/cocotest/agnostic ./coconut/tests/dest/cocotest --force --jobs 0
381+
make open-speedscope
382+
383+
.PHONY: pyspy-runtime
384+
pyspy-runtime:
385+
py-spy record -o runtime_profile.speedscope --format speedscope -- python ./coconut/tests/dest/runner.py
386+
speedscope ./runtime_profile.speedscope
387+
388+
.PHONY: vprof-time
389+
vprof-time:
390+
vprof -c h "./coconut ./coconut/tests/src/cocotest/agnostic ./coconut/tests/dest/cocotest --force --jobs 0 --stack-size 4096 --recursion-limit 4096" --output-file ./vprof.json
391+
make view-vprof
392+
393+
.PHONY: vprof-memory
394+
vprof-memory:
395+
vprof -c m "./coconut ./coconut/tests/src/cocotest/agnostic ./coconut/tests/dest/cocotest --force --jobs 0 --stack-size 4096 --recursion-limit 4096" --output-file ./vprof.json
396+
make view-vprof
397+
398+
.PHONY: view-vprof
399+
view-vprof:
321400
vprof --input-file ./vprof.json

0 commit comments

Comments
 (0)