Skip to content

Commit 1d42b64

Browse files
authored
Merge branch 'master' into hide-methods-from-objects
2 parents 4dedf7a + c453733 commit 1d42b64

File tree

898 files changed

+14340
-10138
lines changed

Some content is hidden

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

898 files changed

+14340
-10138
lines changed

.github/workflows/github-action-test-python.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
# You need to change to branch protection rules if you change the versions here
15-
python-version: [3.12.1, 3.13.0]
15+
python-version: [3.12.11, 3.13.7]
1616
steps:
1717
- uses: actions/checkout@v4
1818
- name: Set up Python ${{ matrix.python-version }}
@@ -24,5 +24,4 @@ jobs:
2424
cd python && ./allTestsForPyVersion
2525
- name: Test pytrace-generator
2626
run: |
27-
python3 python/src/runYourProgram.py --install-mode installOnly
2827
python3 pytrace-generator/test/runTests.py

ChangeLog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Write Your Python Program - CHANGELOG
22

3+
* 2.0.0 (2025-09-24)
4+
* Remove wrappers, only check types at function enter/exit points
5+
* Restructure directory layout
6+
* RUN button now longer copies files to the site-lib directory
7+
* 1.3.2 (2025-05-11)
8+
* Fix release (version 1.3.1. did no include the latest changes)
9+
* 1.3.1 (2025-05-10)
10+
* Fix bug with python 3.13 and wrappers
311
* 1.3.0 (2024-12-01)
412
* Fix bug with union of unions
513
* Improve scrolling #148

README.md

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[![Python CI](https://github.com/skogsbaer/write-your-python-program/actions/workflows/github-action-test-python.yml/badge.svg)](https://github.com/skogsbaer/write-your-python-program/actions/workflows/github-action-test-python.yml)
2-
[![Node.js CI](https://github.com/skogsbaer/write-your-python-program/actions/workflows/github-action-test-js.yml/badge.svg)](https://github.com/skogsbaer/write-your-python-program/actions/workflows/github-action-test-js.yml)
3-
41
# Write Your Python Program
52

63
A user-friendly python programming environment for beginners.
@@ -40,6 +37,11 @@ Run `wypp --help` for usage information.
4037

4138
Here is the [Changelog](ChangeLog.md).
4239

40+
* **Breaking change** in version 2.0.0 (2025-0-24): type annotations are now only
41+
checked when entering/exiting a function. Before, certain things such as lists
42+
or callable were put behind wrapper objects. For example, these wrappers ensured
43+
that only ints could be appended to a list of type `list[int]`. However, these
44+
wrappers came with several drawbacks, so they were removed in release 2.0.0
4345
* **Breaking change** in version 0.12.0 (2021-09-28): type annotations are now checked
4446
dynamically when the code is executed.
4547
This behavior can be deactivated in the settings of the extension.
@@ -50,7 +52,10 @@ You need an explicit import statement such as `from wypp import *`.
5052

5153
Here is a screen shot:
5254

53-
![Screenshot](screenshot.jpg)
55+
![Screenshot](screenshot.png)
56+
57+
There is also a visualization mode, similar to [Python Tutor](https://pythontutor.com/):
58+
![Screenshot](screenshot2.png)
5459

5560
When hitting the RUN button, the vscode extension saves the current file, opens
5661
a terminal and executes the file with Python, staying in interactive mode after
@@ -59,7 +64,7 @@ all definitions have been executed.
5964
The file being executed should contain the following import statement in the first line:
6065

6166
~~~python
62-
from wypp import*
67+
from wypp import *
6368
~~~
6469

6570
Running the file with the RUN button makes the following features available:
@@ -193,39 +198,6 @@ before the type being defined, for example to define recursive types or as
193198
the type of `self` inside of classes. In fact, there is no check at all to make sure
194199
that anotations refer to existing types.
195200

196-
For builtin `list[T]` the following operations are typechecked:
197-
- `list[idx]`
198-
- `list[idx] = value`
199-
- `list += [...]`
200-
- `list.append(value)`
201-
- `list.insert(idx, value)`
202-
- `list.extend(iterator)`
203-
- `for i in list:` (Iterator)
204-
205-
For builtin `set[T]` these operations are typechecked:
206-
- `set.add(value)`
207-
- `set.pop()`
208-
- `set.remove(value)` Value must be of `T`
209-
- `set.update(other, ...)`
210-
- `value in set` Value must be of `T`
211-
- `for i in set:` (Iterator)
212-
213-
For builtin `dict[K,V]` the supported typechecked operations are:
214-
- `dict.get(key)`
215-
- `dict.items()`
216-
- `dict.keys()`
217-
- `dict.pop()`
218-
- `dict.popitem()`
219-
- `dict.setdefault(key, default)` <br/>_Note:_ In contrast to the standard library `default` is required, to avoid inserting `None` as value into otherwise typed dicts.
220-
- `dict.update(other)`
221-
- `dict.update(key=value, ...)`
222-
- `dict.values()`
223-
- `key in dict` Key must be of `K`
224-
- `del dict[key]`
225-
- `for k in dict` (Iterator)
226-
- `reversed(dict)`
227-
- `dict[key]`
228-
- `dict[key] = value`
229201

230202
## Module name and current working directory
231203

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"displayName": "Write Your Python Program!",
44
"description": "A user friendly python environment for beginners",
55
"license": "See license in LICENSE",
6-
"version": "1.3.0",
6+
"version": "2.0.0",
77
"publisher": "StefanWehr",
88
"icon": "icon.png",
99
"engines": {
10-
"vscode": "^1.85.0"
10+
"vscode": "^1.94.2"
1111
},
1212
"keywords": [
1313
"Python",

python/.ignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

python/.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"python.analysis.diagnosticMode": "workspace",
3+
"python.autoComplete.extraPaths": [
4+
"/Users/swehr/.vscode/extensions/stefanwehr.write-your-python-program-1.3.2/python/src/"
5+
]
6+
}

python/TODO.org

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* Code duplication
2+
- wrappedclass.py, protocol.py and typedfunction.py

python/TODO_nowrappers.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* Test windows
2+
* location matcher for vscode
3+
* show "@record\nclass C" for record attributes
4+

python/allTests

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ function run()
1515
echo
1616
}
1717

18-
PYENV_VERSION=3.12.1 run
19-
PYENV_VERSION=3.13.0 run
18+
PYENV_VERSION=3.12 run
19+
PYENV_VERSION=3.13 run

python/allTestsForPyVersion

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,64 +5,61 @@ set -u
55

66
cd $(dirname $0)
77

8-
unit_test_path=src:tests:deps/untypy
9-
10-
function prepare_integration_tests()
11-
{
12-
echo "Preparing integration tests by install the WYPP library"
13-
local d=$(mktemp -d)
14-
trap "rm -rf $d" EXIT
15-
WYPP_INSTALL_DIR=$d python3 src/runYourProgram.py --install-mode installOnly
16-
integ_test_path=integration-tests:$d
17-
}
8+
unit_test_path=code/wypp:tests:code
9+
integration_test_path=code/wypp:integration-tests:code
1810

1911
function usage()
2012
{
2113
echo "USAGE: $0 [--unit | --integration] [ FILE ]"
2214
exit 1
2315
}
2416

25-
if [ -z "${1:-}" ]; then
26-
echo "Python version:"
27-
python3 --version
28-
echo "Running untypy tests"
29-
pushd deps/untypy > /dev/null
30-
./runtests.sh || exit 1
31-
popd > /dev/null
32-
echo "Done with untypy tests"
33-
echo "Running all unit tests, PYTHONPATH=$unit_test_path"
34-
PYTHONPATH=$unit_test_path python3 -m unittest tests/test*.py
35-
echo "Done with unit tests"
36-
echo
37-
prepare_integration_tests
38-
echo "Running all integration tests, PYTHONPATH=$integ_test_path"
39-
PYTHONPATH=$integ_test_path python3 -m unittest integration-tests/test*.py
40-
echo "Done with integration tests"
41-
else
42-
if [ "$1" == "--unit" ]; then
43-
what="unit"
44-
dir=tests
45-
p=$unit_test_path
46-
elif [ "$1" == "--integration" ]; then
47-
what="integration"
48-
dir=integration-tests
49-
prepare_integration_tests
50-
p=$integ_test_path
17+
function run_unit_tests()
18+
{
19+
echo "Running unit tests, PYTHONPATH=$unit_test_path"
20+
if [ -z "${1:-}" ]; then
21+
PYTHONPATH=$unit_test_path python3 -m unittest tests/test*.py
22+
ecode=$?
5123
else
52-
usage
24+
PYTHONPATH=$unit_test_path python3 -m unittest "$@"
25+
ecode=$?
5326
fi
54-
shift
55-
echo "Running $what tests $@ with PYTHONPATH=$p"
27+
echo "Done with unit tests"
28+
}
29+
30+
function run_integration_tests()
31+
{
32+
echo "Running all integration tests, PYTHONPATH=$integration_test_path"
5633
if [ -z "${1:-}" ]; then
57-
PYTHONPATH=$p python3 -m unittest $dir/test*.py
34+
PYTHONPATH=$integration_test_path python3 -m unittest integration-tests/test*.py
5835
ecode=$?
5936
else
60-
PYTHONPATH=$p python3 -m unittest "$@"
37+
PYTHONPATH=$integration_test_path python3 -m unittest "$@"
6138
ecode=$?
6239
fi
63-
echo "$what tests finished with exit code $ecode"
40+
echo "Done with integration tests"
41+
}
42+
43+
44+
echo "Python version:"
45+
python3 --version
46+
47+
if [ -z "${1:-}" ]; then
48+
run_unit_tests
49+
echo
50+
run_integration_tests
51+
echo
52+
echo "Running file tests ..."
53+
python3 ./fileTests.py
54+
elif [ "$1" == "--unit" ]; then
55+
shift
56+
run_unit_tests "$@"
6457
exit $ecode
58+
elif [ "$1" == "--integration" ]; then
59+
shift
60+
run_integration_tests "$@"
61+
exit $ecode
62+
else
63+
usage
6564
fi
6665

67-
echo "Running file tests ..."
68-
./fileTests

0 commit comments

Comments
 (0)