Skip to content

Commit b4c96d8

Browse files
Chore/project maintenance (#50)
* chore: update project dependencies * chore: code formatting * ci/ruff-check-workflow
1 parent c0ea40c commit b4c96d8

9 files changed

Lines changed: 2101 additions & 1993 deletions

File tree

.github/workflows/main.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,30 @@ jobs:
2020
uses: astral-sh/setup-uv@v5
2121
with:
2222
enable-cache: true
23+
cache-suffix: py${{ matrix.python-version }}
2324

2425
- name: Cache Playwright browsers
2526
id: playwright-cache
2627
uses: actions/cache@v4
2728
with:
2829
path: ~/.cache/ms-playwright
29-
key: playwright-${{ runner.os }}-${{ matrix.python-version }}-1.48.0
30+
key: playwright-${{ runner.os }}-${{ matrix.python-version }}-1.57
3031
restore-keys: |
31-
playwright-${{ runner.os }}-${{ matrix.python-version }}-1.48.0-
32+
playwright-${{ runner.os }}-${{ matrix.python-version }}-1.57-
3233
3334
# Prevent "man-db" trigger updates during apt installs, which can take a long time
3435
- name: Remove man-db
3536
run: sudo apt-get purge -y man-db
3637
shell: bash
3738

39+
- name: Create uv virtual environment
40+
run: uv python pin ${{ matrix.python-version }}
41+
shell: bash
42+
43+
- name: Project deps
44+
run: uv sync --only-group playwright --only-group test --no-sources
45+
shell: bash
46+
3847
- name: Install Playwright
3948
run: |
4049
# Install playwright dependencies if not cached
@@ -43,15 +52,7 @@ jobs:
4352
fi
4453
shell: bash
4554

46-
- name: Create uv virtual environment
47-
run: uv python pin ${{ matrix.python-version }}
48-
shell: bash
49-
50-
- name: Project deps
51-
run: uv sync --dev --no-sources
52-
shell: bash
53-
5455
- name: run test
5556
timeout-minutes: 4
56-
run: uv run pytest tests/
57+
run: uv run --python python --no-dev pytest tests/
5758
shell: bash

.github/workflows/ruff-check.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Ruff Code Check
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
12+
env:
13+
RUFF_CONFIG_FILE: "pyproject.toml"
14+
15+
jobs:
16+
ruff-format:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v5
24+
with:
25+
enable-cache: true
26+
27+
- name: Install dependencies (with lint group)
28+
run: uv sync --only-group lint
29+
30+
- name: Run Ruff Linting (Check Code Quality)
31+
run: |
32+
if [ -n "${{ env.RUFF_CONFIG_FILE }}" ]; then
33+
uvx ruff check . --config ${{ env.RUFF_CONFIG_FILE }}
34+
else
35+
uvx ruff check .
36+
fi
37+
38+
- name: Run Ruff Formatting Check
39+
run: |
40+
if [ -n "${{ env.RUFF_CONFIG_FILE }}" ]; then
41+
uvx ruff format . --check --config ${{ env.RUFF_CONFIG_FILE }}
42+
else
43+
uvx ruff format . --check
44+
fi

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.12.2
5+
hooks:
6+
# Run the linter.
7+
- id: ruff-check
8+
args: [ --fix ]
9+
# Run the formatter.
10+
- id: ruff-format

examples/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from nicegui import ui
2-
from .utils.intersection import Intersection
32
from .utils.module_utils import (
43
load_and_execute_module,
54
get_page_module_names,
@@ -29,8 +28,10 @@ def _(module=module):
2928
ui.element("iframe").classes("w-[80vw] h-[50vh]").props(f'src="/{module}"')
3029
)
3130

32-
with ui.expansion("source code").classes("w-full").props(
33-
"header-class='outline'"
31+
with (
32+
ui.expansion("source code")
33+
.classes("w-full")
34+
.props("header-class='outline'")
3435
):
3536
ui.code(get_source_code(module)).classes("w-full")
3637

examples/pages/pagination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
columns[0]["frozen"] = True # type: ignore
99

1010
tabledata = [
11-
{"id": i + 1, **{col["field"]: f"row{i+1}-{col['field']}" for col in columns}}
11+
{"id": i + 1, **{col["field"]: f"row{i + 1}-{col['field']}" for col in columns}}
1212
for i in range(100)
1313
]
1414

nicegui_tabulator/core/tabulator.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,9 @@ def fn(row_number: int, row_index: int):
352352

353353
return wrapper
354354

355-
def set_data(self, data: List[Dict], *, timeout: float = 1, check_interval: float = 0.01):
355+
def set_data(
356+
self, data: List[Dict], *, timeout: float = 1, check_interval: float = 0.01
357+
):
356358
"""set the data of the table.
357359
358360
@see https://tabulator.info/docs/6.2/data#array
@@ -364,7 +366,9 @@ def set_data(self, data: List[Dict], *, timeout: float = 1, check_interval: floa
364366
365367
"""
366368
self._set_data_on_server(data)
367-
self.run_table_method("setData", data, timeout=timeout, check_interval=check_interval)
369+
self.run_table_method(
370+
"setData", data, timeout=timeout, check_interval=check_interval
371+
)
368372
return self
369373

370374
def replace_data(self, data: List[Dict]):
@@ -379,7 +383,9 @@ def replace_data(self, data: List[Dict]):
379383
self.set_data(data)
380384
return self
381385

382-
def update_data(self, data: List[Dict], *, timeout: float = 1, check_interval: float = 0.01):
386+
def update_data(
387+
self, data: List[Dict], *, timeout: float = 1, check_interval: float = 0.01
388+
):
383389
"""update the data of the table.
384390
385391
@see https://tabulator.info/docs/6.2/update#alter-update
@@ -391,7 +397,9 @@ def update_data(self, data: List[Dict], *, timeout: float = 1, check_interval: f
391397
392398
"""
393399
self._update_data_on_server(data)
394-
self.run_table_method("updateData", data, timeout=timeout, check_interval=check_interval)
400+
self.run_table_method(
401+
"updateData", data, timeout=timeout, check_interval=check_interval
402+
)
395403
return self
396404

397405
def add_data(
@@ -416,10 +424,19 @@ def add_data(
416424
417425
"""
418426
self._add_data_on_server(data, at_top, index)
419-
self.run_table_method("addData", data, at_top, index, timeout=timeout, check_interval=check_interval)
427+
self.run_table_method(
428+
"addData",
429+
data,
430+
at_top,
431+
index,
432+
timeout=timeout,
433+
check_interval=check_interval,
434+
)
420435
return self
421436

422-
def update_or_add_data(self, data: List[Dict], *, timeout: float = 1, check_interval: float = 0.01):
437+
def update_or_add_data(
438+
self, data: List[Dict], *, timeout: float = 1, check_interval: float = 0.01
439+
):
423440
"""update or add data to the table.
424441
If the data you are passing to the table contains a mix of existing rows to be updated and new rows to be added then you can call the updateOrAddData function. This will check each row object provided and update the existing row if available, or else create a new row with the data.
425442
@@ -432,7 +449,9 @@ def update_or_add_data(self, data: List[Dict], *, timeout: float = 1, check_inte
432449
433450
"""
434451
self._update_or_add_data_on_server(data)
435-
self.run_table_method("updateOrAddData", data, timeout=timeout, check_interval=check_interval)
452+
self.run_table_method(
453+
"updateOrAddData", data, timeout=timeout, check_interval=check_interval
454+
)
436455
return self
437456

438457
def clear_data(self, *, timeout: float = 1, check_interval: float = 0.01):
@@ -446,7 +465,9 @@ def clear_data(self, *, timeout: float = 1, check_interval: float = 0.01):
446465
447466
"""
448467
self._set_data_on_server([])
449-
self.run_table_method("clearData", timeout=timeout, check_interval=check_interval)
468+
self.run_table_method(
469+
"clearData", timeout=timeout, check_interval=check_interval
470+
)
450471
return self
451472

452473
def sync_data_to_client(self):

pyproject.toml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,22 @@ dependencies = [
1616

1717
[dependency-groups]
1818
dev = [
19-
"pytest~=8.3.5",
20-
"playwright==1.48.0",
21-
"pytest-playwright~=0.7",
19+
{include-group = "test"},
20+
{include-group = "playwright"},
21+
{include-group = "lint"},
22+
]
23+
24+
test = [
25+
"pytest>=8.3.5",
2226
"pandas",
2327
"numpy",
28+
]
2429

30+
playwright = [
31+
"playwright==1.57.0",
32+
"pytest-playwright>=0.7.1",
2533
]
34+
2635
git = [
2736
"pre-commit>=3.5.0",
2837
]

scripts/css_processor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
from pathlib import Path
32

43

0 commit comments

Comments
 (0)