Skip to content

Commit 893a986

Browse files
authored
Merge pull request #2 from fleming79/async-everywhere
Async everywhere
2 parents 8c84dcd + 2ce1182 commit 893a986

53 files changed

Lines changed: 1793 additions & 1991 deletions

Some content is hidden

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

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
- name: Install Python
5151
uses: actions/setup-python@v4
5252
with:
53-
python-version: '3.12'
53+
python-version: '3.11'
5454
architecture: 'x64'
5555
- uses: actions/download-artifact@v4
5656
with:

.github/workflows/packaging.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,10 @@ jobs:
5050
fail-fast: false
5151
matrix:
5252
os: [ubuntu, macos, windows]
53-
python: ['3.12', '3.13']
53+
python: ['3.11', '3.13']
5454
include:
55-
- python: '3.12'
55+
- python: '3.11'
5656
dist: 'ipylab*.tar.gz'
57-
- python: '3.13'
58-
dist: 'ipylab*.whl'
5957
- os: windows
6058
py_cmd: python
6159
pip_cmd: python -m pip

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ repos:
3030
hooks:
3131
- id: check-json5
3232
- repo: https://github.com/python-jsonschema/check-jsonschema
33-
rev: 0.31.3
33+
rev: 0.32.1
3434
hooks:
3535
- id: check-github-workflows
3636
- repo: https://github.com/ComPWA/taplo-pre-commit
3737
rev: v0.9.3
3838
hooks:
3939
- id: taplo-format
4040
- repo: https://github.com/astral-sh/ruff-pre-commit
41-
rev: v0.9.10
41+
rev: v0.11.4
4242
hooks:
4343
- id: ruff
4444
types_or: [python, jupyter]

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"editor.formatOnSave": true,
1414
"python.terminal.activateEnvInCurrentTerminal": true,
1515
"python.createEnvironment.trigger": "prompt",
16-
"python.analysis.typeCheckingMode": "basic",
1716
"python.testing.pytestArgs": ["tests"],
1817
"python.testing.unittestEnabled": false,
1918
"python.testing.pytestEnabled": true

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ These versions enable:
8787
- Viewing widgets from kernels inside from other kernels.
8888

8989
```bash
90-
# For per-kernel-widget-manager support (Install modified version of ipywidgets, jupyterlab_widgets & widgetsnbextension)
91-
92-
pip install --no-binary --force-reinstall ipylab[per-kernel-widget-manager]
90+
pip install --no-binary --force-reinstall ipylab
9391
```
9492

9593
## Running the examples locally
@@ -115,13 +113,13 @@ jupyter lab
115113

116114
```bash
117115
# create a new conda environment
118-
mamba create -n ipylab -c conda-forge nodejs python=3.11 -y
116+
conda create -n ipylab -c conda-forge nodejs python=3.11 -y
119117

120118
# activate the environment
121119
conda activate ipylab
122120

123121
# install the Python package
124-
pip install -e .[dev,per-kernel-widget-manager,test] # (with per-kernel-widget-manager)
122+
pip install -e .[dev,test,examples]
125123

126124
# link the extension files
127125
jupyter labextension develop . --overwrite
@@ -142,6 +140,10 @@ jlpm lint
142140
#or
143141
jlpm lint:check
144142

143+
# Pyright
144+
145+
pip install pyright[nodejs]
146+
pyright
145147
```
146148

147149
### VS code debugging

examples/code_editor.ipynb

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"metadata": {},
3434
"outputs": [],
3535
"source": [
36-
"import asyncio\n",
36+
"import anyio\n",
3737
"\n",
3838
"import ipylab\n",
3939
"from ipylab.code_editor import CodeEditorOptions"
@@ -51,12 +51,13 @@
5151
" mime_type=\"text/x-python\",\n",
5252
" description=\"<b>Code editor</b>\",\n",
5353
" tooltip=\"This is a code editor. Code completion is provided for Python\",\n",
54-
" value=\"def test():\\n ipylab.app.notification.notify('CodeEditor evaluation')\\n\\n# Place the cursor in the CodeEditor and press `Shift Enter`\\ntest()\",\n",
54+
" value=\"def test():\\n app.notification.notify('CodeEditor evaluation')\\n\\n# Place the cursor in the CodeEditor and press `Shift Enter`\\ntest()\",\n",
5555
" layout={\"height\": \"120px\", \"overflow\": \"hidden\"},\n",
5656
" description_allow_html=True,\n",
5757
")\n",
58-
"asyncio.get_event_loop().call_later(0.5, ce.focus)\n",
59-
"ce"
58+
"display(ce)\n",
59+
"await ce.ready()\n",
60+
"ce.focus()"
6061
]
6162
},
6263
{
@@ -123,12 +124,11 @@
123124
"\n",
124125
"\n",
125126
"async def test():\n",
126-
" import asyncio\n",
127127
" import random\n",
128128
"\n",
129129
" for _ in range(20):\n",
130130
" ce.value = random.choice(values) # noqa: S311\n",
131-
" await asyncio.sleep(random.randint(10, 300) / 1e3) # noqa: S311"
131+
" await anyio.sleep(random.randint(10, 300) / 1e3) # noqa: S311"
132132
]
133133
},
134134
{
@@ -148,7 +148,7 @@
148148
"metadata": {},
149149
"outputs": [],
150150
"source": [
151-
"t = ce.to_task(test())"
151+
"await test()"
152152
]
153153
},
154154
{
@@ -157,16 +157,6 @@
157157
"id": "11",
158158
"metadata": {},
159159
"outputs": [],
160-
"source": [
161-
"t.cancel()"
162-
]
163-
},
164-
{
165-
"cell_type": "code",
166-
"execution_count": null,
167-
"id": "12",
168-
"metadata": {},
169-
"outputs": [],
170160
"source": [
171161
"# Place the label above\n",
172162
"ce.layout.flex_flow = \"column\""
@@ -175,17 +165,17 @@
175165
{
176166
"cell_type": "code",
177167
"execution_count": null,
178-
"id": "13",
168+
"id": "12",
179169
"metadata": {},
180170
"outputs": [],
181171
"source": [
182172
"# Add the same editor to the shell.\n",
183-
"ipylab.app.shell.add(ce)"
173+
"await ce.app.shell.add(ce)"
184174
]
185175
},
186176
{
187177
"cell_type": "markdown",
188-
"id": "14",
178+
"id": "13",
189179
"metadata": {},
190180
"source": [
191181
"### Other mime_types\n",
@@ -196,7 +186,7 @@
196186
{
197187
"cell_type": "code",
198188
"execution_count": null,
199-
"id": "15",
189+
"id": "14",
200190
"metadata": {},
201191
"outputs": [],
202192
"source": [
@@ -206,7 +196,7 @@
206196
{
207197
"cell_type": "code",
208198
"execution_count": null,
209-
"id": "16",
199+
"id": "15",
210200
"metadata": {},
211201
"outputs": [],
212202
"source": [
@@ -230,7 +220,7 @@
230220
"name": "python",
231221
"nbconvert_exporter": "python",
232222
"pygments_lexer": "ipython3",
233-
"version": "3.11.10"
223+
"version": "3.12.9"
234224
}
235225
},
236226
"nbformat": 4,

0 commit comments

Comments
 (0)