8000 Release v1.4.1 [Ernest Scribbler] by evhub · Pull Request #512 · evhub/coconut · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Release v1.4.1 [Ernest Scribbler] #512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 169 commits into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
bea8c60
Switch back to develop
evhub Aug 16, 2018
096efdf
Switch back to develop
evhub Aug 16, 2018
eed5be3
Merge branch 'develop' of https://github.com/evhub/coconut into develop
evhub Aug 17, 2018
a64abfe
Upgrade sphinx
evhub Aug 17, 2018
19cf0bc
Turn off develop
evhub Aug 17, 2018
41537c6
Switch back to develop
evhub Aug 16, 2018
9f8a754
Upgrade sphinx
evhub Aug 17, 2018
41770b4
Turn off develop
evhub Aug 17, 2018
d6fb08f
Merge branch 'develop' of https://github.com/evhub/coconut into develop
evhub Aug 17, 2018
8d84228
Turn on develop
evhub Aug 17, 2018
69b054a
Fix igetitem of filter
evhub Sep 14, 2018
5989c6d
Improving docs for indexing into iterables
Oct 12, 2018
469922a
Minor fixes to section on indexing iterables
Oct 12, 2018
c0e1810
Remove reference to mypy flag disabling tco
Oct 12, 2018
e1e0bce
Expanding docs for None-aware operators
Oct 13, 2018
e6f7e9e
# This is a combination of 2 commits.
Oct 13, 2018
1b8aeda
Expanding TCO/TRE docs.
Oct 16, 2018
3d74d37
Minor cleanup of TCO section
Oct 16, 2018
8887952
Add clarification on List vs Sequence in enhanced type annotation docs
Oct 18, 2018
c607dad
Add __hash__ on data types
m-burst Nov 9, 2018
e0cedaa
Raise CoconutSyntaxError for explicit returns in assignment functions
m-burst Nov 9, 2018
009fbbd
Fix CoconutKernel test when running with ipykernel>=5.0.0
m-burst Nov 9, 2018
64c9ede
Fix addpattern incorrectly catching all MatchErrors
m-burst Nov 12, 2018
5170336
Temporary fix for oob line num
evhub Nov 13, 2018
af3cb0d
Fix watcher recompilation
evhub Nov 20, 2018
fc2677b
Fix auto-deciding package
evhub Dec 4, 2018
722cd37
Fix req versioning
evhub Dec 7, 2018
53d0818
Add addpattern def
evhub Dec 23, 2018
d5529dc
fix mistake (swapped |> and |*>)
artemisart Jan 4, 2019
dc626f7
DOCS.md note on IntelliJ IDEA systax highlighting
studentiks Jan 7, 2019
a3b2ef6
Change reiterable __copy__ method to use tee instead of copy, as copy…
Gareth001 Jan 7, 2019
6bd7b6d
Added reiterable copy test
Gareth001 Jan 7, 2019
e72dd66
Clean up header
evhub Jan 9, 2019
5096708
Improve sentinel usage
evhub Jan 9, 2019
a3021f0
Improve indentation paradigm
evhub Jan 10, 2019
8b0f831
Improve legal indentation chars
evhub Jan 10, 2019
aac5c8a
Update to new pyparsing
evhub Feb 5, 2019
4990b52
Documentation improvements for implicit lambdas
Feb 16, 2019
378b17a
Fix incorrect escaping.
eindiran Feb 16, 2019
960d796
Add info on type annotations & statement lambdas
Feb 16, 2019
1744544
Merge branch 'develop' into implicit-lambda-docs
evhub Feb 16, 2019
c682d05
Merge pull request #485 from eindiran/implicit-lambda-docs
evhub Feb 16, 2019
83d70d1
Add missing defs to stub
evhub Feb 16, 2019
bf18257
Fix TYPE_CHECKING
evhub Feb 16, 2019
b86a56f
Fix mypy errors
evhub Feb 16, 2019
5c2758b
Backdate pytest
evhub Feb 16, 2019
a76782f
Update gitignore
evhub Feb 17, 2019
351451a
Fix importlib.reload importing
evhub Feb 18, 2019
7873f57
Bump develop version
evhub Feb 18, 2019
b959c9e
Fix py version testing
evhub Feb 24, 2019
29e2734
Improve header
evhub Feb 24, 2019
530ff08
Improve package compilation
evhub Feb 24, 2019
0a498af
Fix testing on diff py versions
evhub Feb 24, 2019
7eb47f4
Fix pickling on Python 2
evhub Feb 24, 2019
34a24d3
Fix hash generation
evhub Feb 24, 2019
0c4c1c7
Test py 3.7
evhub Feb 24, 2019
b3dce78
Fix py 2.6, 3.7 testing
evhub Feb 24, 2019
a134351
Fix py26 testing
evhub Feb 25, 2019
008060b
Fix package header
evhub Feb 26, 2019
61f42e0
Rename make check
evhub Feb 26, 2019
6f67f0e
Fix tests
evhub Feb 26, 2019
49bd10d
Fix prelude test
evhub Feb 26, 2019
dbe3ec0
Fix kernel test
evhub Feb 26, 2019
b1daa4c
Make format strings universal
evhub Mar 2, 2019
fc1706e
Fix fstring exprs
evhub Mar 2, 2019
d39d35f
Improve eval parser
evhub Mar 2, 2019
9ed2e9a
Support assignment exprs
evhub Mar 2, 2019
b47e4e0
Fix or pattern
evhub Mar 2, 2019
6d41166
Perform minor cleanups
evhub Mar 2, 2019
b66e5f5
Fix target docs
evhub Mar 3, 2019
138a890
Fix assignment exprs
evhub Mar 3, 2019
0ad9b48
Add numpy special case to fmap
evhub Mar 3, 2019
a268e23
Remove unnecessary checks
evhub Mar 3, 2019
c08aee3
Increase line number limit.
evhub Mar 3, 2019
d5491d2
Add kwargs pipes
evhub Mar 4, 2019
c434e06
Clean up docs
evhub Mar 4, 2019
511fd39
Add annotations future importing
evhub Mar 5, 2019
aebfeb7
Truncate pattern errors
evhub Mar 5, 2019
f9aaf7c
Fix tests
evhub Mar 6, 2019
402ec2a
Fix exit codes
evhub Mar 6, 2019
5407fa3
Fix pypy3 test
evhub Mar 6, 2019
6c1a16d
Add match data types
evhub Mar 7, 2019
85dd699
Stop strict versioning of prompt_toolkit
evhub Mar 8, 2019
4d592a4
Bump develop version
evhub Mar 8, 2019
74578f8
Fix prompt_toolkit versioning
evhub Mar 8, 2019
d98fdbd
Use env markers
evhub Mar 8, 2019
996d9f3
Update deps
evhub Mar 9, 2019
8523d6c
Strictly version mypy
evhub Mar 9, 2019
898dfab
Fix highlighting
evhub Mar 9, 2019
d3b6c82
Fix mypy errors
evhub Mar 10, 2019
8a69bc0
Fix stub
evhub Mar 10, 2019
c87db72
Improve verbose
evhub Mar 14, 2019
0a8ee84
Add --args alias
evhub Mar 16, 2019
52b8448
Add assert operator function
evhub Mar 20, 2019
bd192e4
Fix prompt toolkit versioning
evhub Mar 23, 2019
7c6c18a
Fix coconut-run
evhub Mar 24, 2019
320e8d5
Use cPyparsing by default
evhub Apr 15, 2019
410c196
Update to new pyparsing
evhub Apr 16, 2019
8b6ccfe
Reorder pyparsing patches
evhub Apr 16, 2019
7416f5b
Improve pyparsing version checking
evhub Apr 16, 2019
c49b29e
Add license to setup.py
evhub Apr 16, 2019
e0d6426
Improve cPyparsing support
evhub Apr 16, 2019
7703f74
Improve prompt_toolkit versioning
evhub Apr 16, 2019
c10a74c
Always test with latest pip
evhub Apr 16, 2019
8bf9313
Improve setuptools version handling
evhub Apr 16, 2019
f338252
Fix __str__ overriding
evhub Apr 16, 2019
a89f90c
Fix tab completion
evhub Apr 16, 2019
d9e61d8
Improve count
evhub Apr 17, 2019
6f60ece
Fix failing tests
evhub Apr 17, 2019
5483360
Fix tests
evhub Apr 17, 2019
8b4c1e9
Remove mypy retcode checking
evhub Apr 17, 2019
86af17a
Further improve retcode checking
evhub Apr 17, 2019
3255fc0
Fix asyncio mypy error
evhub Apr 24, 2019
9d1a495
Bump mypy version
evhub May 8, 2019
b42a019
Parse f-string expressions as Coconut
m-burst May 19, 2019
2e3dedc
Avoid copying compiler
evhub Jun 12, 2019
333722f
Attempt to fix addpattern, tco pickling
evhub Jun 13, 2019
17eca17
Fix addpattern, tco pickling
evhub Jun 13, 2019
894c1f5
Make recursive_iterator pickleable
evhub Jun 13, 2019
945a2f8
Bump develop version
evhub Jun 13, 2019
79f232c
Add Python 3.8 pos-only args
evhub Jun 14, 2019
d6c526e
Remove import * from headers
evhub Jun 14, 2019
0aaddeb
Fix IPython magics
evhub Jun 15, 2019
74c7a1e
Improve asyncio usage
evhub Jun 15, 2019
da671fe
Fix addpattern pickling
evhub Jun 15, 2019
74783e5
Fix addpattern tco pickling
evhub Jun 15, 2019
50c4f77
Fix IPython namespaces
evhub Jun 15, 2019
ab9aadf
Add pure python override
evhub Jun 18, 2019
dce7256
Fix pure python env var
evhub Jun 18, 2019
c7abf32
Improve COCONUT_PURE_PYTHON support
evhub Jun 18, 2019
bba906f
Fix tco of bound methods
evhub Jun 19, 2019
d6ce101
Fix addpattern/composition/recursive_iterator methods
evhub Jun 19, 2019
6a04df2
Fix broken tests
evhub Jun 19, 2019
d1b03f5
Fix more failing tests
evhub Jun 19, 2019
33d5307
Add FUNDING.yml
evhub Jun 20, 2019
0525b7d
Add coconut_eval
evhub Jun 30, 2019
6367509
Fix coconut_eval
evhub Jun 30, 2019
d0a0f21
Fix typo
evhub Jun 30, 2019
bd04ed4
Fix coconut_eval
evhub Jun 30, 2019
db05ddd
Fix test-verbose
evhub Jun 30, 2019
62bb7a8
Fix coconut_eval test
evhub Jun 30, 2019
7b1379a
Add Easter egg
evhub Jul 4, 2019
6efa792
Fix Easter egg
evhub Jul 4, 2019
b4df4a8
Further fix Easter egg
evhub Jul 9, 2019
c2df1b2
Improve indentation handling
evhub Jul 9, 2019
d024e5d
Disable easter egg test on travis
evhub Jul 9, 2019
8305ad8
Fix easter egg testing
evhub Jul 9, 2019
b5f893a
Fix failing tests
evhub Jul 10, 2019
12e81e7
Fix prelude test
evhub Jul 10, 2019
d3831c8
8000 Fix tests
evhub Jul 10, 2019
6798ffc
Fix typo
evhub Jul 10, 2019
7d2c24b
Fix prelude test
evhub Jul 11, 2019
57d2fe9
Further fix prelude test
evhub Jul 12, 2019
40d60ec
Bump dependencies
evhub Jul 18, 2019
ff455e2
Fix subscript tuples
evhub Jul 27, 2019
00b846b
Improve formatting
evhub Jul 27, 2019
e3812b8
Set version to 1.4.1
evhub Jul 27, 2019
f3a6703
Fix MyPy errors
evhub Jul 27, 2019
155f18e
Fix AppVeyor
evhub Jul 27, 2019
52cadbf
Remove 2.6 test
evhub Jul 27, 2019
f9d6655
Further fix AppVeyor
evhub Jul 27, 2019
d8efe91
Merge branch 'master' into develop
evhub Jul 27, 2019
c17bf08
Fix AppVeyor PATH
evhub Jul 27, 2019
97951f5
Merge branch 'develop' of https://github.com/evhub/coconut into develop
evhub Jul 27, 2019
e8250f3
Remove targetless MyPy test
evhub Jul 27, 2019
a6fddc0
Fix AppVeyor installation
evhub Jul 28, 2019
082c7d4
Fix py34 reqs
evhub Jul 28, 2019
3064638
Further fix AppVeyor req issues
evhub Jul 29, 2019
309e56b
Fix windows tests
evhub Aug 6, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ environment:
- PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7.x"
PYTHON_ARCH: "32"
- PYTHON: "C:\\Python33"
PYTHON_VERSION: "3.3.x"
PYTHON_ARCH: "32"
- PYTHON: "C:\\Python34"
PYTHON_VERSION: "3.4.x"
PYTHON_ARCH: "32"
Expand All @@ -26,9 +23,10 @@ environment:
PYTHON_ARCH: "32"

install:
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;c:\\MinGW\\bin;%PATH%"
- "SET PATH=%APPDATA%\\Python;%APPDATA%\\Python\\Scripts;%PYTHON%;%PYTHON%\\Scripts;c:\\MinGW\\bin;%PATH%"
- "copy c:\\MinGW\\bin\\mingw32-make.exe c:\\MinGW\\bin\\make.exe"
- make install
- python -m pip install --user --upgrade setuptools pip
- python -m pip install .[tests]

build: false

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ bin/
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
pip-wheel-metadata/

# Unit test / coverage reports
htmlcov/
Expand Down
17 changes: 10 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks.git
rev: v1.3.0
rev: v2.2.3
hooks:
- id: check-byte-order-marker
- id: check-merge-conflict
Expand All @@ -15,17 +15,20 @@ repos:
- id: pretty-format-json
args:
- --autofix
- id: autopep8-wrapper
- id: flake8
args:
- --ignore=W503,E501,E265,E402,F405,E305,E126
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.4.4
hooks:
- id: autopep8
args:
- --in-place
- --aggressive
- --aggressive
- --experimental
- --ignore=W503,E501,E722
- id: flake8
args:
- --ignore=W503,E501,E265,E402,F405,E305
- --ignore=W503,E501,E722,E402
- repo: https://github.com/asottile/add-trailing-comma
rev: v0.6.4
rev: v1.4.1
hooks:
- id: add-trailing-comma
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ notifications:
sudo: false
cache: pip
python:
- '2.6'
- '2.7'
- pypy
- '3.3'
- '3.4'
- '3.5'
- '3.6'
- pypy3
Expand Down
10 changes: 7 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,22 @@ After you've tested your changes locally, you'll want to add more permanent test
- python35
- `py35_test.coco`
+ Tests to be run only on Python 3.5 with `--target 3.5`.
- python36
- `py36_test.coco`
+ Tests to be run only on Python 3.6 with `--target 3.6`.

## Release Process

1. Preparation:
1. Run `make check` and update dependencies as necessary
1. Run `make check-reqs` and update dependencies as necessary
1. Run `make format`
1. Check changes in [`compiled-cocotest`](https://github.com/evhub/compiled-cocotest) and [`pyprover`](https://github.com/evhub/pyprover)
1. Check [Codacy issues](https://www.codacy.com/app/evanjhub) (for `coconut` and `compiled-cocotest`) and [LGTM alerts](https://lgtm.com/projects/g/evhub/coconut/)
1. Check changes in [`compiled-cocotest`](https://github.com/evhub/compiled-cocotest), [`pyprover`](https://github.com/evhub/pyprover), and [`coconut-prelude`](https://github.com/evhub/coconut-prelude)
1. Check [Codebeat](https://codebeat.co/a/evhub/projects) and [LGTM](https://lgtm.com/dashboard) for `coconut` and `compiled-cocotest`
1. Make sure [`coconut-develop`](https://pypi.python.org/pypi/coconut-develop) package looks good
1. Run `make docs` and ensure local documentation looks good
1. Make sure [develop documentation](http://coconut.readthedocs.io/en/develop/) looks good
1. Make sure [Travis](https://travis-ci.org/evhub/coconut/builds) and [AppVeyor](https://ci.appveyor.com/project/evhub/coconut) are passing
1. Run `make test-easter-eggs`
1. Turn off `develop` in `root.py`
1. Set `root.py` to new version number
1. If major release, set `root.py` to new version name
Expand Down
320 changes: 274 additions & 46 deletions DOCS.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ I certainly hope not! Unlike most transpiled languages, all valid Python is vali

### I want to use Coconut in a production environment; how do I achieve maximum performance?

First, you're going to want a fast compiler, so you should either [install Coconut with the `cPyparsing` option](DOCS.html#installation), or use [`PyPy`](https://pypy.org/). Second, there are two simple things you can do to make Coconut produce faster Python: compile with `--no-tco` and compile with a `--target` specification for the exact version of Python you want to run your code on. Passing `--target` helps Coconut optimize the compiled code for the Python version you want, and, though [Tail Call Optimization](DOCS.html#tail-call-optimization) is useful, it will usually significantly slow down functions that use it, so disabling it will often provide a major performance boost.
First, you're going to want a fast compiler, so you should either use [`cPyparsing`](https://github.com/evhub/cpyparsing) or [`PyPy`](https://pypy.org/). Second, there are two simple things you can do to make Coconut produce faster Python: compile with `--no-tco` and compile with a `--target` specification for the exact version of Python you want to run your code on. Passing `--target` helps Coconut optimize the compiled code for the Python version you want, and, though [Tail Call Optimization](DOCS.html#tail-call-optimization) is useful, it will usually significantly slow down functions that use it, so disabling it will often provide a major performance boost.

### I want to contribute to Coconut, how do I get started?

Expand Down
12 changes: 12 additions & 0 deletions FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

# github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
# patreon: # Replace with a single Patreon username
open_collective: coconut
# ko_fi: # Replace with a single Ko-fi username
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
# liberapay: # Replace with a single Liberapay username
# issuehunt: # Replace with a single IssueHunt username
# otechie: # Replace with a single Otechie username
# custom: # Replace with a single custom sponsorship URL
17 changes: 7 additions & 10 deletions HELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Installing Coconut, including all the features above, is drop-dead simple. Just
pip install coconut
```

_Note: Try re-running the above command with the `--user` option if you are encountering errors. Be sure that Coconut's installation location (on UNIX `/usr/local/bin` if you didn't use `--user` or `${HOME}/.local/bin/` if you did) is in your `PATH` environment variable. If you are still encountering errors installing Coconut with `pip`, you can also install Coconut with `conda` by following the [conda installation instructions in the documentation](DOCS.html#using-conda)._
_Note: If you are having trouble installing Coconut, try following the debugging steps in the [installation section of Coconut's documentation](DOCS.html#installation)._

To check that your installation is functioning properly, try entering into the command line
```
Expand Down Expand Up @@ -352,12 +352,11 @@ def factorial(n):
raise TypeError("the argument to factorial must be an integer >= 0")
```

By making use of the [Coconut built-in `addpattern`](DOCS.html#addpattern), we can take that from three indentation levels down to one. Take a look:
By making use of the [Coconut `addpattern` syntax](DOCS.html#addpattern), we can take that from three indentation levels down to one. Take a look:
```
def factorial(0) = 1

@addpattern(factorial)
def factorial(n is int if n > 0) =
addpattern def factorial(n is int if n > 0) =
"""Compute n! where n is an integer >= 0."""
range(1, n+1) |> reduce$(*)

Expand All @@ -373,14 +372,13 @@ First, assignment function notation. This one's pretty straightforward. If a fun

Second, pattern-matching function definition. Pattern-matching function definition does exactly that—pattern-matches against all the arguments that are passed to the function. Unlike normal function definition, however, if the pattern doesn't match (if for example the wrong number of arguments are passed), your function will raise a `MatchError`. Finally, like destructuring assignment, if you want to be more explicit about using pattern-matching function definition, you can add a `match` before the `def`.

Third, `addpattern`. `addpattern` takes one argument, a previously-defined pattern-matching function, and returns a decorator that decorates a new pattern-matching function by adding the new pattern as an additional case to the old patterns. Thus, `addpattern` can be thought of as doing exactly what it says—it adds a new pattern to an existing pattern-matching function.
Third, `addpattern`. `addpattern` creates a new pattern-matching function by adding the new pattern as an additional case to the old pattern-matching function it is replacing. Thus, `addpattern` can be thought of as doing exactly what it says—it adds a new pattern to an existing pattern-matching function.

Finally, not only can we rewrite the iterative approach using `addpattern`, as we did above, we can also rewrite the recursive approach using `addpattern`, like so:
```coconut
def factorial(0) = 1

@addpattern(factorial)
def factorial(n is int if n > 0) =
addpattern def factorial(n is int if n > 0) =
"""Compute n! where n is an integer >= 0."""
n * factorial(n - 1)

Expand All @@ -402,8 +400,7 @@ First up is `quick_sort` for lists. We're going to use a recursive `addpattern`-
```coconut
def quick_sort([]) = []

@addpattern(quick_sort)
def quick_sort([head] + tail) =
addpattern def quick_sort([head] + tail) =
"""Sort the input sequence using the quick sort algorithm."""
quick_sort(left) + [head] + quick_sort(right) where:
left = [x for x in tail if x < head]
Expand Down Expand Up @@ -544,7 +541,7 @@ Copy, paste! The big new thing here is how to write `data` constructors. Since `

In this case, the constructor checks whether nothing but another `vector` was passed, in which case it returns that, otherwise it returns the result of passing the arguments to the underlying constructor, the form of which is `vector(*pts)`, since that is how we declared the data type. We use sequence pattern-matching to determine whether we were passed a single vector, which is just a list or tuple of patterns to match against the contents of the sequence.

The other new construct used here is the `|*>`, or star-pipe, operator, which functions exactly like the normal pipe, except that instead of calling the function with one argument, it calls it with as many arguments as there are elements in the sequence passed into it. The difference between `|*>` and `|>` is exactly analogous to the difference between `f(args)` and `f(*args)`.
The other new construct used here is the `|*>`, or star-pipe, operator, which functions exactly like the normal pipe, except that instead of calling the function with one argument, it calls it with as many arguments as there are elements in the sequence passed into it. The difference between `|>` and `|*>` is exactly analogous to the difference between `f(args)` and `f(*args)`.

### n-Vector Methods

Expand Down
29 changes: 18 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.PHONY: install
install:
pip install "pip>=7.1.2"
pip install --upgrade setuptools pip
pip install .[tests]

.PHONY: dev
dev:
python -m pip install --upgrade setuptools pip
pip install --upgrade setuptools pip
pip install --upgrade -e .[dev]
pre-commit install -f --install-hooks

Expand All @@ -17,37 +17,44 @@ format: dev
# test-all takes a very long time and should usually only be run by Travis
.PHONY: test-all
test-all:
pytest --strict -s tests
pytest --strict -s ./tests

# for quickly testing nearly everything locally, just use test-basic
.PHONY: test-basic
test-basic:
python ./tests --force
python ./tests --strict --force
python ./tests/dest/runner.py
python ./tests/dest/extras.py

# same as test-basic, but doesn't recompile unchanged test files;
# should only be used when testing the tests not the compiler
.PHONY: test-tests
test-tests:
python ./tests
python ./tests --strict
python ./tests/dest/runner.py
python ./tests/dest/extras.py

# same as test-basic but also runs mypy
.PHONY: test-mypy
test-mypy:
python ./tests --force --target sys --mypy --follow-imports silent --ignore-missing-imports
python ./tests --strict --force --target sys --line-numbers --mypy --follow-imports silent --ignore-missing-imports
python ./tests/dest/runner.py
python ./tests/dest/extras.py

# same as test-basic but includes verbose output for better debugging
.PHONY: test-verbose
test-verbose:
python ./tests --force --verbose --jobs 0
python ./tests --strict --force --verbose --jobs 0
python ./tests/dest/runner.py
python ./tests/dest/extras.py

# same as test-basic but also tests easter eggs
.PHONY: test-easter-eggs
test-easter-eggs:
python ./tests --strict --force
python ./tests/dest/runner.py --test-easter-eggs
python ./tests/dest/extras.py

.PHONY: diff
diff:
git diff origin/develop
Expand All @@ -60,8 +67,8 @@ docs: clean
.PHONY: clean
clean:
rm -rf ./docs ./dist ./build ./tests/dest index.rst profile.json
find . -name '*.pyc' -delete
find . -name '__pycache__' -delete
-find . -name '*.pyc' -delete
-find . -name '__pycache__' -delete

.PHONY: wipe
wipe: clean
Expand All @@ -82,8 +89,8 @@ just-upload:
.PHONY: upload
upload: clean dev just-upload

.PHONY: check
check:
.PHONY: check-reqs
check-reqs:
python ./coconut/requirements.py

.PHONY: profile-code
Expand Down
56 changes: 48 additions & 8 deletions coconut/myparsing.py → coconut/_pyparsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

from coconut.root import * # NOQA

import os
import traceback
import functools

from coconut.constants import (
packrat_cache,
Expand All @@ -28,46 +30,84 @@
min_versions,
ver_str_to_tuple,
ver_tuple_to_str,
get_next_version,
pure_python_env_var,
PURE_PYTHON,
)

# warning: do not name this file cPyparsing or pyparsing or it might collide with the following imports
try:

if PURE_PYTHON:
raise ImportError("skipping cPyparsing check due to " + pure_python_env_var + " = " + os.environ.get(pure_python_env_var, ""))

import cPyparsing as _pyparsing
from cPyparsing import * # NOQA
from cPyparsing import ( # NOQA
_trim_arity,
_ParseResultsWithOffset,
__version__,
)
7E5E PYPARSING = "Cython cPyparsing v" + __version__
PYPARSING_PACKAGE = "cPyparsing"
PYPARSING_INFO = "Cython cPyparsing v" + __version__

except ImportError:
try:

import pyparsing as _pyparsing
from pyparsing import * # NOQA
from pyparsing import ( # NOQA
_trim_arity,
_ParseResultsWithOffset,
__version__,
)
PYPARSING = "Python pyparsing v" + __version__
PYPARSING_PACKAGE = "pyparsing"
PYPARSING_INFO = "Python pyparsing v" + __version__

except ImportError:
traceback.print_exc()
__version__ = None
PYPARSING_PACKAGE = "pyparsing"
PYPARSING_INFO = None

# -----------------------------------------------------------------------------------------------------------------------
# SETUP:
# -----------------------------------------------------------------------------------------------------------------------

if __version__ is None or ver_str_to_tuple(__version__) < min_versions["pyparsing"]:
req_ver_str = ver_tuple_to_str(min_versions["pyparsing"])
min_ver = min(min_versions["pyparsing"], min_versions["cPyparsing"][:3])
max_ver = get_next_version(max(min_versions["pyparsing"], min_versions["cPyparsing"][:3]))

if __version__ is None or not min_ver <= ver_str_to_tuple(__version__) < max_ver:
min_ver_str = ver_tuple_to_str(min_ver)
max_ver_str = ver_tuple_to_str(max_ver)
raise ImportError(
"Coconut requires pyparsing version >= " + req_ver_str
+ ("; got version " + __version__ if __version__ is not None else "")
+ " (run 'pip install --upgrade pyparsing' or"
+ " 'pip install --upgrade cPyparsing' to fix)",
"Coconut requires pyparsing/cPyparsing version >= " + min_ver_str + " and < " + max_ver_str
+ ("; got " + PYPARSING_INFO if PYPARSING_INFO is not None else "")
+ " (run 'pip install --upgrade " + PYPARSING_PACKAGE + "' to fix)",
)


def fast_str(cls):
"""A very simple __str__ implementation."""
return "<" + cls.__name__ + ">"


def fast_repr(cls):
"""A very simple __repr__ implementation."""
return "<" + cls.__name__ + ">"


# makes pyparsing much faster if it doesn't have to compute expensive
# nested string representations
for obj in vars(_pyparsing).values():
try:
if issubclass(obj, ParserElement):
obj.__str__ = functools.partial(fast_str, obj)
obj.__repr__ = functools.partial(fast_repr, obj)
except TypeError:
pass


if packrat_cache:
ParserElement.enablePackrat(packrat_cache)

Expand Down
2 changes: 1 addition & 1 deletion coconut/command/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
)

arguments.add_argument(
"--argv",
"--argv", "--args",
type=str,
nargs=argparse.REMAINDER,
help="set sys.argv to source plus remaining args for use in Coconut script being run",
Expand Down
Loading
0