Skip to content

Commit b7d3378

Browse files
committed
linting
1 parent ae32a68 commit b7d3378

File tree

5 files changed

+36
-20
lines changed

5 files changed

+36
-20
lines changed

labextension/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"watch": "run-p watch:src watch:labextension",
4141
"watch:src": "jlpm build:lib -w --preserveWatchOutput",
4242
"watch:labextension": "jupyter labextension watch .",
43-
"deduplicate": "yarn-deduplicate -s fewer --fail"
43+
"deduplicate": "yarn-deduplicate -s fewer --fail",
44+
"lint:prettier": "prettier --write --list-different \"../.github/*.yaml\" \"../*.{yaml,yml,md}\" \"../docs/**/*.md\" \"src/**/*.{tsx,ts}\""
4445
},
4546
"dependencies": {
4647
"@jupyterlab/application": "^2.0 || ^3.0 || ^4.0",
@@ -49,6 +50,7 @@
4950
"devDependencies": {
5051
"@jupyterlab/builder": "^4.0.6",
5152
"npm-run-all": "^4.1.5",
53+
"prettier": "^3.0.3",
5254
"rimraf": "^5.0.1",
5355
"typescript": "~5.2.2",
5456
"yarn-berry-deduplicate": "^6.0.0"

labextension/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const argSchema = {
3535
function newServerProxyWidget(
3636
id: string,
3737
url: string,
38-
text: string
38+
text: string,
3939
): MainAreaWidget<IFrame> {
4040
const content = new IFrame({
4141
sandbox: [
@@ -67,15 +67,15 @@ async function activate(
6767
app: JupyterFrontEnd,
6868
labShell: ILabShell | null,
6969
launcher: ILauncher | null,
70-
restorer: ILayoutRestorer | null
70+
restorer: ILayoutRestorer | null,
7171
): Promise<void> {
7272
const baseUrl = PageConfig.getBaseUrl();
7373
// Fetch configured server processes from {base_url}/server-proxy/servers-info
7474
const response = await fetch(`${baseUrl}server-proxy/servers-info`);
7575

7676
if (!response.ok) {
7777
console.warn(
78-
"Could not fetch metadata about registered servers. Make sure jupyter-server-proxy is installed."
78+
"Could not fetch metadata about registered servers. Make sure jupyter-server-proxy is installed.",
7979
);
8080
console.warn(response);
8181
return;

labextension/yarn.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ __metadata:
123123
"@jupyterlab/builder": ^4.0.6
124124
"@jupyterlab/launcher": ^2.0 || ^3.0 || ^4.0
125125
npm-run-all: ^4.1.5
126+
prettier: ^3.0.3
126127
rimraf: ^5.0.1
127128
typescript: ~5.2.2
128129
yarn-berry-deduplicate: ^6.0.0
@@ -3350,6 +3351,15 @@ __metadata:
33503351
languageName: node
33513352
linkType: hard
33523353

3354+
"prettier@npm:^3.0.3":
3355+
version: 3.0.3
3356+
resolution: "prettier@npm:3.0.3"
3357+
bin:
3358+
prettier: bin/prettier.cjs
3359+
checksum: e10b9af02b281f6c617362ebd2571b1d7fc9fb8a3bd17e371754428cda992e5e8d8b7a046e8f7d3e2da1dcd21aa001e2e3c797402ebb6111b5cd19609dd228e0
3360+
languageName: node
3361+
linkType: hard
3362+
33533363
"process@npm:^0.11.10":
33543364
version: 0.11.10
33553365
resolution: "process@npm:0.11.10"

tests/acceptance/test_acceptance.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
try:
1313
import notebook
14+
1415
NOTEBOOK_VERSION = int(notebook.__version__.split(".")[0])
1516
except ImportError:
1617
NOTEBOOK_VERSION = None

tests/conftest.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def a_server(
6565

6666
# prepare an env
6767
env = dict(os.environ)
68-
env.update(JUPYTER_TOKEN=a_token)
68+
env.update(JUPYTER_TOKEN=a_token, JUPYTER_PLATFORM_DIRS="1")
6969

7070
# start the process
7171
server_proc = Popen(args, cwd=str(tmp_path), env=env)
@@ -75,36 +75,39 @@ def a_server(
7575
canary_url = f"{url}favicon.ico"
7676
shutdown_url = f"{url}api/shutdown?token={a_token}"
7777

78-
retries = 10
78+
wait_until_urlopen(canary_url)
79+
80+
print(f"{a_server_cmd} is ready...", flush=True)
81+
82+
yield url
83+
84+
# clean up after server is no longer needed
85+
print(f"{a_server_cmd} shutting down...", flush=True)
86+
wait_until_urlopen(shutdown_url, data=[])
87+
server_proc.wait()
88+
print(f"{a_server_cmd} is stopped", flush=True)
89+
7990

91+
def wait_until_urlopen(url, **kwargs):
92+
retries = 10
8093
while retries:
94+
time.sleep(1)
8195
try:
82-
urlopen(canary_url)
96+
urlopen(url, **kwargs)
8397
break
8498
except URLError:
8599
if not retries:
86100
print(
87-
f"{a_server_cmd} not ready, aborting",
101+
f"{url} not ready, aborting",
88102
flush=True,
89103
)
90104
raise
91105
print(
92-
f"{a_server_cmd} not ready, will try again in 0.5s [{retries} retries]",
106+
f"{url} not ready, will try again in 0.5s [{retries} retries]",
93107
flush=True,
94108
)
95-
time.sleep(0.5)
96109
retries -= 1
97110

98-
print(f"{a_server_cmd} is ready...", flush=True)
99-
100-
yield url
101-
102-
# clean up after server is no longer needed
103-
print(f"{a_server_cmd} shutting down...", flush=True)
104-
urlopen(shutdown_url, data=[])
105-
server_proc.wait()
106-
print(f"{a_server_cmd} is stopped", flush=True)
107-
108111

109112
@fixture
110113
def a_server_port_and_token(

0 commit comments

Comments
 (0)