Skip to content

Commit

Permalink
Fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollonval committed May 22, 2024
1 parent 539aeb3 commit 973f681
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 36 deletions.
1 change: 0 additions & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ project_short_description: A Jupyter Server extension to execute code cell from
python_name: jupyter_server_nbmodel
repository: https://github.com/datalayer/jupyter-server-nbmodel
test: true

6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: Build

on:
push:
branches: main
branches:
- main
pull_request:
branches: '*'
branches:
- '*'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repos:
[mdformat-gfm, mdformat-frontmatter, mdformat-footnote]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 0.4.4
rev: v0.4.4
hooks:
- id: ruff
args: ["--fix"]
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ for the frontend extension.
## Requirements

- Jupyter Server
- [optional] JupyterLab >= 4.0.0
- \[optional\] JupyterLab >= 4.0.0

## Install

Expand Down Expand Up @@ -79,7 +79,6 @@ sequenceDiagram

### With input case


Execution of a Python code snippet: `input("Age:")`

```mermaid
Expand Down Expand Up @@ -107,7 +106,7 @@ sequenceDiagram
Server-->>-Frontend: Status 300 & Pending input
Frontend->>+Server: POST /api/kernels/<id>/input
Server->>Kernel: Send input msg
Server-->>-Frontend:
Server-->>-Frontend:
loop While status is 202
Frontend->>+Server: GET /api/kernels/<id>/requests/<uid>
Server->>ExecutionStack: Get task result
Expand All @@ -122,7 +121,7 @@ sequenceDiagram
Server-->>-Frontend: Status 200 & result
```

> [!NOTE]
> \[!NOTE\]
> The code snippet is always send in the body of the POST `/api/kernels/<id>/execute`
> request to avoid document model discrepancy; the document on the backend is only
> eventually identical with the frontends (document updates are not instantaneous).
Expand Down Expand Up @@ -220,7 +219,6 @@ More precisely, the JupyterLab helper [Galata](https://github.com/jupyterlab/jup

More information are provided within the [ui-tests](./ui-tests/README.md) README.


### Manual testing

```bash
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Here is a summary of the steps to cut a new release:
- Check the draft changelog
- Run the "Step 2: Publish Release" workflow

> [!NOTE]
> \[!NOTE\]
> Check out the [workflow documentation](https://jupyter-releaser.readthedocs.io/en/latest/get_started/making_release_from_repo.html)
> for more information.
Expand Down
1 change: 0 additions & 1 deletion binder/postBuild
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import subprocess
import sys
from pathlib import Path


ROOT = Path.cwd()

def _(*args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

pytest_plugins = ("pytest_jupyter.jupyter_server", )
pytest_plugins = ("pytest_jupyter.jupyter_server",)


@pytest.fixture
Expand All @@ -9,4 +9,4 @@ def jp_server_config(jp_server_config):
"ServerApp": {
"jpserver_extensions": {"jupyter_server_nbmodel": True, "jupyter_server_ydoc": False}
}
}
}
3 changes: 1 addition & 2 deletions examples/basic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@
"metadata": {},
"outputs": [],
"source": [
"# FIXME\n",
"# input(\"Age: \")"
"input(\"Age: \")"
]
},
{
Expand Down
12 changes: 4 additions & 8 deletions jupyter_server_nbmodel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@
# in editable mode with pip. It is highly recommended to install
# the package from a stable release or in editable mode: https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs
import warnings
warnings.warn("Importing 'jupyter_server_nbmodel' outside a proper installation.")

warnings.warn("Importing 'jupyter_server_nbmodel' outside a proper installation.", stacklevel=1)
__version__ = "dev"
from .extension import Extension


def _jupyter_labextension_paths():
return [{
"src": "labextension",
"dest": "jupyter-server-nbmodel"
}]
return [{"src": "labextension", "dest": "jupyter-server-nbmodel"}]


def _jupyter_server_extension_points():
return [{
"module": "jupyter_server_nbmodel", "app": Extension
}]
return [{"module": "jupyter_server_nbmodel", "app": Extension}]
5 changes: 3 additions & 2 deletions jupyter_server_nbmodel/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import typing as t
import uuid
from dataclasses import asdict, dataclass, is_dataclass
from dataclasses import asdict, dataclass
from functools import partial
from http import HTTPStatus

Expand Down Expand Up @@ -75,7 +75,7 @@ async def _get_ycell(
metadata: dict | None,
) -> y.Map | None:
if ydoc is None:
msg = "jupyter-collaboration extension is not installed on the server. Outputs won't be written within the document."
msg = "jupyter-collaboration extension is not installed on the server. Outputs won't be written within the document." # noqa: E501
get_logger().warning(msg)
return None

Expand Down Expand Up @@ -263,6 +263,7 @@ async def _kernel_worker(
if to_raise is not None:
raise to_raise


class ExecutionStack:
"""Execution request stack.
Expand Down
10 changes: 3 additions & 7 deletions jupyter_server_nbmodel/tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import re

import pytest
from flaky import flaky
from jupyter_client.kernelspec import NATIVE_KERNEL_NAME

TEST_TIMEOUT = 15
Expand All @@ -17,7 +16,7 @@
async def _wait_request(fetch, endpoint: str):
"""Poll periodically to fetch the execution request result."""
start_time = datetime.datetime.now()
elapsed = 0.
elapsed = 0.0
while elapsed < 0.9 * TEST_TIMEOUT:
await asyncio.sleep(SLEEP)
response = await fetch(endpoint, raise_error=False)
Expand Down Expand Up @@ -182,16 +181,13 @@ async def test_post_input_execute(jp_fetch, pending_kernel_is_ready):
)
assert response3.code == 201

response4 = await _wait_request(
jp_fetch,
location
)
response4 = await _wait_request(jp_fetch, location)
assert response4.code == 200
payload2 = json.loads(response4.body)
assert payload2 == {
"status": "ok",
"execution_count": 1,
"outputs": '[{"output_type": "execute_result", "metadata": {}, "data": {"text/plain": "\'42\'"}, "execution_count": 1}]',
"outputs": '[{"output_type": "execute_result", "metadata": {}, "data": {"text/plain": "\'42\'"}, "execution_count": 1}]', # noqa: E501
}

r2 = await jp_fetch("api", "kernels", kernel["id"], method="DELETE")
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
}
},
"disabledExtensions": [
"@jupyterlab/notebook-extension:cell-executor",
"@jupyter/docprovider-extension:notebook-cell-executor"
"@jupyterlab/notebook-extension:cell-executor",
"@jupyter/docprovider-extension:notebook-cell-executor"
],
"extension": true,
"outputDir": "jupyter_server_nbmodel/labextension"
Expand Down
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ warn_redundant_casts = true
[tool.ruff]
target-version = "py38"
line-length = 100

[tool.ruff.lint]
select = [
"A",
"B",
Expand Down Expand Up @@ -122,9 +124,14 @@ ignore = [
"C901",
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# S603 `subprocess` call: check for execution of untrusted input
# T201 `print` found
"binder/postBuild" = ["S603", "T201"]
# S101 Use of `assert` detected
"jupyter_server_nbmodel/tests/*" = ["S101"]
# F821 Undefined name `c`
"ui-tests/jupyter_server_test_config.py" = ["F821"]

[tool.jupyter-releaser.options]
version_cmd = "hatch version"
Expand Down
1 change: 1 addition & 0 deletions ui-tests/jupyter_server_test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
opens the server to the world and provide access to JupyterLab
JavaScript objects through the global window variable.
"""

from jupyterlab.galata import configure_jupyter_server

configure_jupyter_server(c)
Expand Down
4 changes: 3 additions & 1 deletion ui-tests/tests/jupyter_server_nbmodel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ test('should emit an activation console message', async ({ page }) => {
await page.goto();

expect(
logs.filter(s => s === 'JupyterLab extension jupyter-server-nbmodel is activated!')
logs.filter(
s => s === 'JupyterLab extension jupyter-server-nbmodel is activated!'
)
).toHaveLength(1);
});

0 comments on commit 973f681

Please sign in to comment.