Skip to content

Commit 1c6be7e

Browse files
Updated requirements (#2461)
* Added a manual test for t-strings * Updating requirements to allow t-strings
1 parent 0ca6d42 commit 1c6be7e

8 files changed

Lines changed: 99 additions & 17 deletions

File tree

‎.github/workflows/test.yml‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ on:
1919
jobs:
2020
BuildAndTest:
2121
runs-on: ubuntu-latest
22-
env:
23-
MINICONDA_PYTHON_VERSION: py38
24-
MINICONDA_VERSION: 4.11.0
2522
steps:
2623
- name: Checkout
2724
uses: actions/checkout@v5
@@ -36,6 +33,12 @@ jobs:
3633
- name: git log
3734
run: git log --graph -3
3835

36+
- name: Setup Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: 3.14
40+
cache: "pip"
41+
3942
- name: Install node
4043
uses: actions/setup-node@v5
4144
with:
@@ -54,12 +57,9 @@ jobs:
5457
${{ runner.os }}-build-
5558
${{ runner.os }}-
5659
57-
- name: setup Miniconda
58-
uses: conda-incubator/setup-miniconda@v3
59-
6060
- name: Create and activate virtual environment
6161
run: |
62-
python3 -m venv test_venv
62+
python3.14 -m venv test_venv
6363
source test_venv/bin/activate
6464
echo PATH=$PATH >> $GITHUB_ENV
6565
echo VIRTUAL_ENV=$VIRTUAL_ENV >> $GITHUB_ENV

‎.pre-commit-config.yaml‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ ci:
44
#skip: [eslint]
55
autoupdate_schedule: monthly
66

7+
default_language_version:
8+
python: python3.14
9+
710
default_stages: [pre-commit]
811
repos:
912
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -24,22 +27,22 @@ repos:
2427
- id: trailing-whitespace
2528

2629
- repo: https://github.com/psf/black-pre-commit-mirror
27-
rev: 25.9.0
30+
rev: 26.1.0
2831
hooks:
2932
- id: black
3033
exclude: core/tests
3134
args: ["-l", "88", "--skip-string-normalization"]
3235

3336
- repo: https://github.com/codespell-project/codespell
34-
rev: v2.4.1
37+
rev: v2.4.2
3538
hooks:
3639
- id: codespell # See 'pyproject.toml' for args
3740
exclude: fs\.py|\.js\.map$
3841
additional_dependencies:
3942
- tomli
4043

4144
- repo: https://github.com/astral-sh/ruff-pre-commit
42-
rev: v0.13.3
45+
rev: v0.15.5
4346
hooks:
4447
- id: ruff
4548
exclude: core/tests

‎core/src/stdlib/pyscript.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎core/src/stdlib/pyscript/web.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ def another_handler(event):
205205
from pyscript import document, Event # noqa: F401
206206
from pyscript.ffi import create_proxy, is_none
207207

208-
209208
# Utility functions for finding and wrapping DOM elements.
210209

211210

‎core/tests/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
a:hover { opacity: 1; }
1515
</style>
1616
</head>
17-
<body><ul><li><strong><span>javascript</span></strong><ul><li><a href="./javascript/async-listener.html">async-listener<small>.html</small></a></li><li><strong><a href="./javascript/config-parser/index.html">config-parser</a></strong></li><li><a href="./javascript/config-url.html">config-url<small>.html</small></a></li><li><a href="./javascript/config_type.html">config_type<small>.html</small></a></li><li><strong><a href="./javascript/fetch/index.html">fetch</a></strong></li><li><a href="./javascript/ffi.html">ffi<small>.html</small></a></li><li><a href="./javascript/hooks.html">hooks<small>.html</small></a></li><li><strong><a href="./javascript/issue-2093/index.html">issue-2093</a></strong></li><li><a href="./javascript/js-storage.html">js-storage<small>.html</small></a></li><li><a href="./javascript/js_modules.html">js_modules<small>.html</small></a></li><li><strong><a href="./javascript/loader/index.html">loader</a></strong></li><li><a href="./javascript/media.html">media<small>.html</small></a></li><li><a href="./javascript/mpy-error.html">mpy-error<small>.html</small></a></li><li><a href="./javascript/mpy-no-error.html">mpy-no-error<small>.html</small></a></li><li><a href="./javascript/mpy.html">mpy<small>.html</small></a></li><li><a href="./javascript/py-terminal-main.html">py-terminal-main<small>.html</small></a></li><li><a href="./javascript/py-terminal-worker.html">py-terminal-worker<small>.html</small></a></li><li><a href="./javascript/py-terminal.html">py-terminal<small>.html</small></a></li><li><a href="./javascript/py-terminals.html">py-terminals<small>.html</small></a></li><li><strong><a href="./javascript/pyodide-cache/index.html">pyodide-cache</a></strong></li><li><strong><a href="./javascript/pyodide-lockfile/index.html">pyodide-lockfile</a></strong></li><li><a href="./javascript/storage.html">storage<small>.html</small></a></li><li><strong><a href="./javascript/worker-config/index.html">worker-config</a></strong></li><li><a href="./javascript/worker-symbols.html">worker-symbols<small>.html</small></a></li><li><strong><span>workers</span></strong><ul><li><strong><a href="./javascript/workers/create_named/index.html">create_named</a></strong></li><li><strong><a href="./javascript/workers/mpy/index.html">mpy</a></strong></li><li><strong><a href="./javascript/workers/py/index.html">py</a></strong></li></ul></li></ul></li><li><strong><a href="./manual/index.html">manual</a></strong><ul><li><a href="./manual/all-done.html">all-done<small>.html</small></a></li><li><a href="./manual/async.html">async<small>.html</small></a></li><li><a href="./manual/camera.html">camera<small>.html</small></a></li><li><a href="./manual/click.html">click<small>.html</small></a></li><li><a href="./manual/code-a-part.html">code-a-part<small>.html</small></a></li><li><a href="./manual/combo.html">combo<small>.html</small></a></li><li><a href="./manual/config.html">config<small>.html</small></a></li><li><a href="./manual/create-element.html">create-element<small>.html</small></a></li><li><a href="./manual/dialog.html">dialog<small>.html</small></a></li><li><a href="./manual/display.html">display<small>.html</small></a></li><li><strong><a href="./manual/donkey/index.html">donkey</a></strong></li><li><a href="./manual/emoji.html">emoji<small>.html</small></a></li><li><a href="./manual/error.html">error<small>.html</small></a></li><li><strong><a href="./manual/ffi_timeout/index.html">ffi_timeout</a></strong></li><li><strong><a href="./manual/fs/index.html">fs</a></strong></li><li><strong><a href="./manual/game/index.html">game</a></strong></li><li><a href="./manual/html-decode.html">html-decode<small>.html</small></a></li><li><a href="./manual/input.html">input<small>.html</small></a></li><li><a href="./manual/interpreter.html">interpreter<small>.html</small></a></li><li><strong><a href="./manual/issue-2228/index.html">issue-2228</a></strong></li><li><strong><a href="./manual/issue-2246/index.html">issue-2246</a></strong></li><li><strong><a href="./manual/issue-2302/index.html">issue-2302</a></strong></li><li><strong><a href="./manual/issue-2304/index.html">issue-2304</a></strong></li><li><strong><a href="./manual/issue-7015/index.html">issue-7015</a></strong></li><li><a href="./manual/multi.html">multi<small>.html</small></a></li><li><a href="./manual/multiple-editors.html">multiple-editors<small>.html</small></a></li><li><a href="./manual/no-error.html">no-error<small>.html</small></a></li><li><strong><a href="./manual/no_sab/index.html">no_sab</a></strong></li><li><strong><a href="./manual/piratical/index.html">piratical</a></strong></li><li><a href="./manual/py-editor.html">py-editor<small>.html</small></a></li><li><a href="./manual/py-editor-failure.html">py-editor-failure<small>.html</small></a></li><li><strong><a href="./manual/py-terminals/index.html">py-terminals</a></strong><ul><li><a href="./manual/py-terminals/no-repl.html">no-repl<small>.html</small></a></li><li><a href="./manual/py-terminals/repl.html">repl<small>.html</small></a></li></ul></li><li><a href="./manual/py_modules.html">py_modules<small>.html</small></a></li><li><strong><a href="./manual/remote/index.html">remote</a></strong></li><li><strong><a href="./manual/service-worker/index.html">service-worker</a></strong></li><li><a href="./manual/split-config.html">split-config<small>.html</small></a></li><li><a href="./manual/submit.html">submit<small>.html</small></a></li><li><a href="./manual/target.html">target<small>.html</small></a></li><li><a href="./manual/test_display_HTML.html">test_display_HTML<small>.html</small></a></li><li><a href="./manual/test_when.html">test_when<small>.html</small></a></li><li><a href="./manual/worker.html">worker<small>.html</small></a></li></ul></li><li><strong><a href="./python/index.html">python</a></strong></li></ul></body>
17+
<body><ul><li><strong><span>javascript</span></strong><ul><li><a href="./javascript/async-listener.html">async-listener<small>.html</small></a></li><li><strong><a href="./javascript/config-parser/index.html">config-parser</a></strong></li><li><a href="./javascript/config-url.html">config-url<small>.html</small></a></li><li><a href="./javascript/config_type.html">config_type<small>.html</small></a></li><li><strong><a href="./javascript/fetch/index.html">fetch</a></strong></li><li><a href="./javascript/ffi.html">ffi<small>.html</small></a></li><li><a href="./javascript/hooks.html">hooks<small>.html</small></a></li><li><strong><a href="./javascript/issue-2093/index.html">issue-2093</a></strong></li><li><a href="./javascript/js-storage.html">js-storage<small>.html</small></a></li><li><a href="./javascript/js_modules.html">js_modules<small>.html</small></a></li><li><strong><a href="./javascript/loader/index.html">loader</a></strong></li><li><a href="./javascript/media.html">media<small>.html</small></a></li><li><a href="./javascript/mpy-error.html">mpy-error<small>.html</small></a></li><li><a href="./javascript/mpy-no-error.html">mpy-no-error<small>.html</small></a></li><li><a href="./javascript/mpy.html">mpy<small>.html</small></a></li><li><a href="./javascript/py-terminal-main.html">py-terminal-main<small>.html</small></a></li><li><a href="./javascript/py-terminal-worker.html">py-terminal-worker<small>.html</small></a></li><li><a href="./javascript/py-terminal.html">py-terminal<small>.html</small></a></li><li><a href="./javascript/py-terminals.html">py-terminals<small>.html</small></a></li><li><strong><a href="./javascript/pyodide-cache/index.html">pyodide-cache</a></strong></li><li><strong><a href="./javascript/pyodide-lockfile/index.html">pyodide-lockfile</a></strong></li><li><a href="./javascript/storage.html">storage<small>.html</small></a></li><li><strong><a href="./javascript/worker-config/index.html">worker-config</a></strong></li><li><a href="./javascript/worker-symbols.html">worker-symbols<small>.html</small></a></li><li><strong><span>workers</span></strong><ul><li><strong><a href="./javascript/workers/create_named/index.html">create_named</a></strong></li><li><strong><a href="./javascript/workers/mpy/index.html">mpy</a></strong></li><li><strong><a href="./javascript/workers/py/index.html">py</a></strong></li></ul></li></ul></li><li><strong><a href="./manual/index.html">manual</a></strong><ul><li><a href="./manual/all-done.html">all-done<small>.html</small></a></li><li><a href="./manual/async.html">async<small>.html</small></a></li><li><a href="./manual/camera.html">camera<small>.html</small></a></li><li><a href="./manual/click.html">click<small>.html</small></a></li><li><a href="./manual/code-a-part.html">code-a-part<small>.html</small></a></li><li><a href="./manual/combo.html">combo<small>.html</small></a></li><li><a href="./manual/config.html">config<small>.html</small></a></li><li><a href="./manual/create-element.html">create-element<small>.html</small></a></li><li><a href="./manual/dialog.html">dialog<small>.html</small></a></li><li><a href="./manual/display.html">display<small>.html</small></a></li><li><strong><a href="./manual/donkey/index.html">donkey</a></strong></li><li><a href="./manual/emoji.html">emoji<small>.html</small></a></li><li><a href="./manual/error.html">error<small>.html</small></a></li><li><strong><a href="./manual/ffi_timeout/index.html">ffi_timeout</a></strong></li><li><strong><a href="./manual/fs/index.html">fs</a></strong></li><li><strong><a href="./manual/game/index.html">game</a></strong></li><li><a href="./manual/html-decode.html">html-decode<small>.html</small></a></li><li><a href="./manual/input.html">input<small>.html</small></a></li><li><a href="./manual/interpreter.html">interpreter<small>.html</small></a></li><li><strong><a href="./manual/issue-2228/index.html">issue-2228</a></strong></li><li><strong><a href="./manual/issue-2246/index.html">issue-2246</a></strong></li><li><strong><a href="./manual/issue-2302/index.html">issue-2302</a></strong></li><li><strong><a href="./manual/issue-2304/index.html">issue-2304</a></strong></li><li><strong><a href="./manual/issue-7015/index.html">issue-7015</a></strong></li><li><a href="./manual/multi.html">multi<small>.html</small></a></li><li><a href="./manual/multiple-editors.html">multiple-editors<small>.html</small></a></li><li><a href="./manual/no-error.html">no-error<small>.html</small></a></li><li><strong><a href="./manual/no_sab/index.html">no_sab</a></strong></li><li><strong><a href="./manual/piratical/index.html">piratical</a></strong></li><li><a href="./manual/py-editor.html">py-editor<small>.html</small></a></li><li><a href="./manual/py-editor-failure.html">py-editor-failure<small>.html</small></a></li><li><strong><a href="./manual/py-terminals/index.html">py-terminals</a></strong><ul><li><a href="./manual/py-terminals/no-repl.html">no-repl<small>.html</small></a></li><li><a href="./manual/py-terminals/repl.html">repl<small>.html</small></a></li></ul></li><li><a href="./manual/py_modules.html">py_modules<small>.html</small></a></li><li><strong><a href="./manual/remote/index.html">remote</a></strong></li><li><strong><a href="./manual/service-worker/index.html">service-worker</a></strong></li><li><a href="./manual/split-config.html">split-config<small>.html</small></a></li><li><a href="./manual/submit.html">submit<small>.html</small></a></li><li><a href="./manual/t-strings.html">t-strings<small>.html</small></a></li><li><a href="./manual/target.html">target<small>.html</small></a></li><li><a href="./manual/test_display_HTML.html">test_display_HTML<small>.html</small></a></li><li><a href="./manual/test_when.html">test_when<small>.html</small></a></li><li><a href="./manual/worker.html">worker<small>.html</small></a></li></ul></li><li><strong><a href="./python/index.html">python</a></strong></li></ul></body>
1818
</html>

‎core/tests/manual/t-strings.html‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>t-strings</title>
7+
<link rel="stylesheet" href="../../dist/core.css">
8+
<script type="module" src="../../dist/core.js"></script>
9+
<script type="mpy" src="t-strings.py"></script>
10+
</head>
11+
</html>

‎core/tests/manual/t-strings.py‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
from pyscript import window, document
2+
3+
SHOW_COMMENT = window.NodeFilter.SHOW_COMMENT
4+
5+
already_parsed = {}
6+
7+
# accepts a t-string template, returns a JS DOM node 🤯
8+
def domdom(template):
9+
strings = template.strings
10+
if strings in already_parsed:
11+
content = already_parsed[strings].cloneNode(True)
12+
else:
13+
interpolations = template.interpolations
14+
el = document.createElement('template')
15+
16+
# create unique content that can be understood by the parser
17+
el.innerHTML = '<!--🐍-->'.join(strings)
18+
content = el.content
19+
already_parsed[strings] = el.content
20+
21+
tw = document.createTreeWalker(content, SHOW_COMMENT)
22+
i = 0
23+
while True :
24+
node = tw.nextNode()
25+
if node is None: break
26+
if node.data == '🐍':
27+
node.replaceWith(interpolations[i].value.node)
28+
i += 1
29+
30+
return content
31+
32+
33+
class Text:
34+
def __init__(self, value, node=None):
35+
self._value = str(value)
36+
self.node = document.createTextNode(self._value) if node is None else node
37+
38+
@property
39+
def value(self):
40+
return self._value
41+
42+
@value.setter
43+
def value(self, value):
44+
self._value = str(value)
45+
self.node.data = self._value
46+
47+
def __str__(self):
48+
return f'#text: {self._value}'
49+
50+
# just to demo JS string casting
51+
def toString(self):
52+
return str(self)
53+
54+
55+
# create a new text and leak it for demo purposes
56+
content = Text('Hello World!')
57+
window.content = content
58+
59+
print(f"<div>{content}</div>")
60+
61+
# see domdom in action 🥳
62+
document.body.append(
63+
domdom(
64+
t"<div>{content}</div>"
65+
),
66+
# domdom(
67+
# t"<div>{content}</div>"
68+
# )
69+
)

‎requirements.txt‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
black==24.10.0
2-
pre-commit==3.7.1
3-
python-minifier==3.1.0
4-
setuptools==72.1.0
1+
black==26.1.0
2+
pre-commit==4.5.1
3+
python-minifier==3.2.0
4+
setuptools==82.0.0

0 commit comments

Comments
 (0)