Skip to content

Commit f6e1f03

Browse files
fix some line lengths to satisfy pre-commit
1 parent 0d759fd commit f6e1f03

File tree

7 files changed

+30
-45
lines changed

7 files changed

+30
-45
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,4 @@ dmypy.json
132132
#css/bootstrap/npm
133133
package-lock.json
134134
package.json
135-
node_modules
135+
node_modules

.pre-commit-config.yaml

+6-10
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ repos:
1414
args: ["--pytest-test-first"]
1515
- id: requirements-txt-fixer
1616
- id: trailing-whitespace
17+
exclude: ^src/kweb/static/bootstrap/
1718

18-
- repo: https://github.com/hakancelik96/unimport
19-
rev: 0.14.1
20-
hooks:
21-
- id: unimport
22-
args: [--remove, --include-star-import]
2319
- repo: https://github.com/pycqa/isort
2420
rev: "5.12.0"
2521
hooks:
@@ -28,7 +24,7 @@ repos:
2824
args: ["--profile", "black", "--filter-files"]
2925

3026
- repo: https://github.com/psf/black
31-
rev: "23.1.0"
27+
rev: "23.7.0"
3228
hooks:
3329
- id: black
3430

@@ -44,7 +40,7 @@ repos:
4440
files: ".ipynb"
4541

4642
- repo: https://github.com/asottile/pyupgrade
47-
rev: v3.3.1
43+
rev: v3.10.1
4844
hooks:
4945
- id: pyupgrade
5046
args: [--py310-plus, --keep-runtime-typing]
@@ -56,7 +52,7 @@ repos:
5652
# args: ["-L TE,TE/TM,te,ba,FPR,fpr_spacing,ro,donot"]
5753

5854
- repo: https://github.com/shellcheck-py/shellcheck-py
59-
rev: v0.9.0.2
55+
rev: v0.9.0.5
6056
hooks:
6157
- id: shellcheck
6258

@@ -66,7 +62,7 @@ repos:
6662
# - id: python-use-type-annotations
6763

6864
- repo: https://github.com/PyCQA/bandit
69-
rev: 1.7.4
65+
rev: 1.7.5
7066
hooks:
7167
- id: bandit
7268
args: [--exit-zero]
@@ -137,6 +133,6 @@ repos:
137133
# # - id: nbqa-isort
138134
# # args: ["--float-to-top"]
139135
- repo: https://github.com/charliermarsh/ruff-pre-commit
140-
rev: "v0.0.253"
136+
rev: "v0.0.285"
141137
hooks:
142138
- id: ruff

pyproject.toml

-7
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@ exclude = ''' # Specify the files/dirs that should be ignored by the black form
7171
)/
7272
'''
7373

74-
[tool.commitizen]
75-
name = "cz_conventional_commits"
76-
version = "0.1.1"
77-
version_files = [
78-
"pyproject.toml:version",
79-
]
80-
8174
[tool.mypy]
8275
python_version = "3.10"
8376
strict = true

src/kweb/main.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import pathlib
2-
import tempfile
3-
from glob import glob
1+
import os
42
from pathlib import Path
53
from typing import Any
64

75
from fastapi import FastAPI, Request
86
from fastapi.exceptions import HTTPException
9-
from fastapi.responses import HTMLResponse, RedirectResponse
7+
from fastapi.responses import HTMLResponse
108
from fastapi.staticfiles import StaticFiles
119
from fastapi.templating import Jinja2Templates
1210
from starlette.routing import WebSocketRoute
@@ -15,8 +13,6 @@
1513
from kweb import __version__ as version
1614
from kweb.server import LayoutViewServerEndpoint
1715

18-
import os
19-
2016
# module_path = Path(os.getenv("KWEB_EDAFILES", Path(__file__).parent.resolve()))
2117
module_path = Path(__file__).parent.absolute()
2218
home_path = Path.home() / ".gdsfactory" / "extra"
@@ -55,7 +51,8 @@ async def gds_view_static(
5551
if not exists:
5652
raise HTTPException(
5753
status_code=404,
58-
detail=f'No gds found with name "{gds_name}". It doesn\'t exist or is not accessible',
54+
detail=f'No gds found with name "{gds_name}".'
55+
" It doesn't exist or is not accessible",
5956
)
6057

6158
root_path = request.scope["root_path"]

src/kweb/server.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ def layer_dump(
109109
).to_png_data()
110110
).decode("ASCII"),
111111
"children": children,
112-
"empty": all(
113-
(c["empty"] for c in children) # type: ignore[call-overload]
114-
),
112+
"empty": all(c["empty"] for c in children),
115113
}
116114
)
117115
iter.next_sibling(1)
@@ -171,9 +169,7 @@ def layer_dump(
171169
).to_png_data()
172170
).decode("ASCII"),
173171
"children": children,
174-
"empty": all(
175-
(c["empty"] for c in children) # type: ignore[call-overload]
176-
),
172+
"empty": all(c["empty"] for c in children),
177173
}
178174
)
179175
iter.next_sibling(1)
@@ -273,9 +269,10 @@ async def connection(self, websocket: WebSocket, path: str | None = None) -> Non
273269
asyncio.create_task(self.timer(websocket))
274270

275271
async def timer(self, websocket: WebSocket) -> None:
276-
self.layout_view.on_image_updated_event = lambda: self.image_updated( # type: ignore[attr-defined,assignment]
277-
websocket
278-
)
272+
def update() -> None:
273+
self.image_updated(websocket)
274+
275+
self.layout_view.on_image_updated_event = update # type: ignore[assignment]
279276
while True:
280277
self.layout_view.timer() # type: ignore[attr-defined]
281278
await asyncio.sleep(0.01)
@@ -380,11 +377,13 @@ async def reader(self, websocket: WebSocket, data: str) -> None:
380377
)
381378
case "mouse_pressed":
382379
self.mouse_event(
383-
self.layout_view.send_mouse_press_event, js # type: ignore[arg-type]
380+
self.layout_view.send_mouse_press_event,
381+
js, # type: ignore[arg-type]
384382
)
385383
case "mouse_released":
386384
self.mouse_event(
387-
self.layout_view.send_mouse_release_event, js # type: ignore[arg-type]
385+
self.layout_view.send_mouse_release_event,
386+
js, # type: ignore[arg-type]
388387
)
389388
case "mouse_enter":
390389
self.layout_view.send_enter_event()

src/kweb/static/client.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ ul, #myUL {
131131
object-fit: contain;
132132
width: 80%;
133133
height: 80%;
134-
}
134+
}

src/kweb/static/client.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ function appendCells(parentelement, cells, current_index, addpadding=false) {
274274
}
275275
accordion.id = "cellgroup-" + c.id;
276276

277-
277+
278278
cellRow.appendChild(accordion);
279279

280280
accordion_item = document.createElement("div");
@@ -328,7 +328,7 @@ function appendCells(parentelement, cells, current_index, addpadding=false) {
328328

329329
appendCells(accordion_body, c.children, current_index, true);
330330
lastelement = accordion;
331-
331+
332332
} else {
333333
let cell_name_button = document.createElement("input");
334334
cell_name_button.className = "btn-check";
@@ -351,7 +351,7 @@ function appendCells(parentelement, cells, current_index, addpadding=false) {
351351
accordion_row.className = "row mx-0";
352352
accordion_row.appendChild(cell_name_button);
353353
accordion_row.appendChild(cell_name);
354-
354+
355355
let accordion = document.createElement("div");
356356
if (addpaddings) {
357357
accordion.className = "accordion accordion-flush ps-2 pe-0";
@@ -422,7 +422,7 @@ function appendLayers(parentelement, layers, addempty=false, addpaddings = false
422422
}
423423
accordion.id = "layergroup-" + l.id;
424424

425-
425+
426426
layerRow.appendChild(accordion);
427427

428428
accordion_item = document.createElement("div");
@@ -455,7 +455,7 @@ function appendLayers(parentelement, layers, addempty=false, addpaddings = false
455455
}
456456

457457
layer_image.addEventListener("click", click_layer_img);
458-
458+
459459
img_cont.appendChild(layer_image);
460460
let layer_name = document.createElement("div");
461461
layer_name.innerHTML = l.name;
@@ -484,7 +484,7 @@ function appendLayers(parentelement, layers, addempty=false, addpaddings = false
484484

485485
appendLayers(accordion_body, l.children, addempty=addempty);
486486
lastelement = accordion;
487-
487+
488488
} else {
489489
let img_cont = document.createElement("div");
490490
img_cont.className = "col-auto p-0";
@@ -512,7 +512,7 @@ function appendLayers(parentelement, layers, addempty=false, addpaddings = false
512512
accordion_row.appendChild(img_cont);
513513
accordion_row.appendChild(layer_name);
514514
accordion_row.appendChild(layer_source);
515-
515+
516516
let accordion = document.createElement("div");
517517
if (addpaddings) {
518518
accordion.className = "accordion accordion-flush px-2";
@@ -605,4 +605,4 @@ window.addEventListener("keydown", function(evt) {
605605
evt.preventDefault();
606606
sendKeyEvent(canvas, "keydown", evt);
607607
}
608-
});
608+
});

0 commit comments

Comments
 (0)