Skip to content

Commit 53cb4ca

Browse files
abidlabsgradio-pr-botclaude
authored
Run pnpm lint and pnpm ts:check on CI (#13526)
* Fix format diagnostics * add changeset * Fix format diagnostics * Fix frontend runtime test regressions * add changeset * Fix post-merge frontend diagnostics * add changeset * Simplify optional spaces imports * add changeset * Enable frontend lint and typecheck in CI * add changeset * Address review comments after merging main - Resolve merge conflicts in FullscreenButton wiring (keep dispatch where main added it; keep null guard + svg renderer in nativeplot) - gallery: make handle_save take a root-bound upload callback; drop unused Client import - tootils: drop duplicate ILoadingStatus, use the @gradio/statustracker type - types: widen frontend_fn return type to match process_frontend_fn runtime - dataframe: remove leftover console.log in measure_row Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Allow I18nData in choice display names for ty typecheck PR #13534 added runtime support for i18n'd choice display names in Radio/CheckboxGroup/Dropdown/SimpleDropdown but didn't widen the `choices` type, so `ty` flags `demo/i18n/run.py`. Widen the tuple display side to `str | I18nData` to match `label`/`info` and the runtime behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * changes --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0a933b4 commit 53cb4ca

149 files changed

Lines changed: 701 additions & 2326 deletions

File tree

Some content is hidden

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

.agents/skills/gradio/references/api-signatures.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ Creates a checkbox that can be set to `True` or `False`. Can be used as an input
3737
## `Dropdown`
3838

3939
```python
40-
Dropdown(choices: Sequence[str | int | float | tuple[str, str | int | float]] | None = None, value: str | int | float | Sequence[str | int | float] | Callable | DefaultValue | None = DefaultValue(), type: Literal['value', 'index'] = "value", multiselect: bool | None = None, allow_custom_value: bool = False, max_choices: int | None = None, filterable: bool = True, label: str | I18nData | None = None, info: str | I18nData | None = None, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool | None = None, container: bool = True, scale: int | None = None, min_width: int = 160, interactive: bool | None = None, visible: bool | Literal['hidden'] = True, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", buttons: list[Button] | None = None)
40+
Dropdown(choices: Sequence[str | int | float | tuple[str | I18nData, str | int | float]] | None = None, value: str | int | float | Sequence[str | int | float] | Callable | DefaultValue | None = DefaultValue(), type: Literal['value', 'index'] = "value", multiselect: bool | None = None, allow_custom_value: bool = False, max_choices: int | None = None, filterable: bool = True, label: str | I18nData | None = None, info: str | I18nData | None = None, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool | None = None, container: bool = True, scale: int | None = None, min_width: int = 160, interactive: bool | None = None, visible: bool | Literal['hidden'] = True, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", buttons: list[Button] | None = None)
4141
```
4242

4343
Creates a dropdown of choices from which a single entry or multiple entries can be selected (as an input component) or displayed (as an output component).
4444

4545
## `Radio`
4646

4747
```python
48-
Radio(choices: Sequence[str | int | float | tuple[str, str | int | float]] | None = None, value: str | int | float | Callable | None = None, type: Literal['value', 'index'] = "value", label: str | I18nData | None = None, info: str | I18nData | None = None, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool | None = None, container: bool = True, scale: int | None = None, min_width: int = 160, interactive: bool | None = None, visible: bool | Literal['hidden'] = True, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", rtl: bool = False, buttons: list[Button] | None = None)
48+
Radio(choices: Sequence[str | int | float | tuple[str | I18nData, str | int | float]] | None = None, value: str | int | float | Callable | None = None, type: Literal['value', 'index'] = "value", label: str | I18nData | None = None, info: str | I18nData | None = None, every: Timer | float | None = None, inputs: Component | Sequence[Component] | set[Component] | None = None, show_label: bool | None = None, container: bool = True, scale: int | None = None, min_width: int = 160, interactive: bool | None = None, visible: bool | Literal['hidden'] = True, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, key: int | str | tuple[int | str, ...] | None = None, preserved_by_key: list[str] | str | None = "value", rtl: bool = False, buttons: list[Button] | None = None)
4949
```
5050

5151
Creates a set of (string or numeric type) radio buttons of which only one can be selected.

.changeset/neat-poems-scream.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
"@gradio/annotatedimage": minor
3+
"@gradio/atoms": minor
4+
"@gradio/audio": minor
5+
"@gradio/browserstate": minor
6+
"@gradio/button": minor
7+
"@gradio/chatbot": minor
8+
"@gradio/checkbox": minor
9+
"@gradio/client": minor
10+
"@gradio/code": minor
11+
"@gradio/column": minor
12+
"@gradio/core": minor
13+
"@gradio/dataframe": minor
14+
"@gradio/dataset": minor
15+
"@gradio/dialogue": minor
16+
"@gradio/draggable": minor
17+
"@gradio/dropdown": minor
18+
"@gradio/fallback": minor
19+
"@gradio/file": minor
20+
"@gradio/fileexplorer": minor
21+
"@gradio/form": minor
22+
"@gradio/gallery": minor
23+
"@gradio/highlightedtext": minor
24+
"@gradio/html": minor
25+
"@gradio/image": minor
26+
"@gradio/imageeditor": minor
27+
"@gradio/imageslider": minor
28+
"@gradio/json": minor
29+
"@gradio/label": minor
30+
"@gradio/markdown": minor
31+
"@gradio/markdown-code": minor
32+
"@gradio/model3d": minor
33+
"@gradio/multimodaltextbox": minor
34+
"@gradio/nativeplot": minor
35+
"@gradio/navbar": minor
36+
"@gradio/number": minor
37+
"@gradio/paramviewer": minor
38+
"@gradio/plot": minor
39+
"@gradio/radio": minor
40+
"@gradio/row": minor
41+
"@gradio/simpledropdown": minor
42+
"@gradio/simpleimage": minor
43+
"@gradio/simpletextbox": minor
44+
"@gradio/slider": minor
45+
"@gradio/statustracker": minor
46+
"@gradio/tabs": minor
47+
"@gradio/textbox": minor
48+
"@gradio/upload": minor
49+
"@gradio/utils": minor
50+
"@gradio/video": minor
51+
"@gradio/workflowcanvas": minor
52+
"@self/spa": minor
53+
"@self/storybook": minor
54+
"@self/tootils": minor
55+
"gradio": minor
56+
"gradio_test": minor
57+
---
58+
59+
feat:Run `pnpm lint` and `pnpm ts:check` on CI

.config/eslint.config.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,19 @@ const js_rules = {
3333
"no-unexpected-multiline": "error",
3434
"no-unreachable": "error",
3535
"array-callback-return": "error",
36-
complexity: "error",
37-
"no-else-return": "error",
38-
"no-useless-return": "error",
3936
"no-undef": "error"
4037
};
4138

4239
const ts_rules = {
4340
...ts_rules_disabled,
4441
"@typescript-eslint/adjacent-overload-signatures": "error",
45-
"@typescript-eslint/explicit-function-return-type": [
46-
"error",
47-
{ allowExpressions: true }
48-
],
4942
"@typescript-eslint/consistent-type-exports": "error",
50-
"@typescript-eslint/ban-types": "error",
5143
"@typescript-eslint/array-type": "error",
5244
"@typescript-eslint/no-inferrable-types": "error"
5345
};
5446

5547
const jsdoc_rules = {
56-
...jsdoc_rules_disabled,
57-
"jsdoc/require-param-description": "error",
58-
"jsdoc/require-returns-description": "error"
48+
...jsdoc_rules_disabled
5949
};
6050

6151
const { browser, es2021, node } = globals;
@@ -71,6 +61,8 @@ export default [
7161
"**/*.test.ts",
7262
"**/*.node-test.ts",
7363
"**/*.stories.*",
64+
"client/js/src/test/**/*",
65+
"js/build/out/**/*",
7466
"js/spa/test/**/*",
7567
"**/*vite.config.ts",
7668
"**/_website/**/*",

.config/svelte.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
22

33
export default {
4-
preprocess: vitePreprocess()
4+
preprocess: vitePreprocess(),
5+
compilerOptions: {
6+
experimental: {
7+
async: true
8+
}
9+
}
510
};

.github/workflows/tests-js.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ jobs:
6464
run: pnpm --filter @gradio/client build
6565
- name: format check
6666
run: pnpm format:check
67-
# - name: lint
68-
# run: pnpm lint
69-
# - name: typecheck
70-
# run: pnpm ts:check
67+
- name: lint
68+
run: pnpm lint
69+
- name: typecheck
70+
run: pnpm ts:check
7171
- name: unit tests
7272
run: pnpm test:run
7373
- name: client tests

client/js/src/helpers/api_info.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ export function get_description(
230230
return type?.description;
231231
}
232232

233-
/* eslint-disable complexity */
234233
export function handle_message(
235234
data: any,
236235
last_status: Status["stage"]
@@ -402,7 +401,6 @@ export function handle_message(
402401

403402
return { type: "none", status: { stage: "error", queue } };
404403
}
405-
/* eslint-enable complexity */
406404

407405
/**
408406
* Maps the provided `data` to the parameters defined by the `/info` endpoint response.

client/js/src/utils/submit.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable complexity */
21
import type {
32
Status,
43
Payload,

cs.js

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@ import path from "path";
33
import { execSync } from "child_process";
44
import { getPackages } from "@manypkg/get-packages";
55

6+
/**
7+
* @typedef {"patch" | "minor" | "major"} VersionBump
8+
* @typedef {{ feat: string; fix: string; highlight: string; [key: string]: string }} ReadmeContent
9+
* @typedef {{ version: VersionBump; reamde_content: ReadmeContent }} ChangedPackage
10+
* @typedef {{ name: string; dir: string; version: string; packge_json: Record<string, any>; changelog: string }} PackageToWrite
11+
*/
12+
613
const changsetsFolder = path.join(process.cwd(), ".changeset");
714
const files = readdirSync(changsetsFolder);
815
const mdFiles = files.filter(
916
(file) => file.endsWith(".md") && !file.startsWith("README.md")
1017
);
1118

19+
/** @param {string} filePath */
1220
const getGitInfo = (filePath) => {
1321
const gitInfo = execSync(
1422
`git log -n 1 --pretty=format:"%H -bingboong- %s" -- ${filePath}`,
@@ -48,10 +56,11 @@ const changedPackages = changsets.reduce(
4856
if (packages) {
4957
packages.forEach((_package) => {
5058
const [name, version] = _package.split(":");
59+
if (!name || !version || !pr) return;
5160

5261
if (!acc[name]) {
5362
acc[name] = {
54-
version: version.trim(),
63+
version: /** @type {VersionBump} */ (version.trim()),
5564
reamde_content: {
5665
feat: "",
5766
fix: "",
@@ -61,7 +70,7 @@ const changedPackages = changsets.reduce(
6170
};
6271
} else {
6372
acc[name].version = getMaximumBump(
64-
version.trim(),
73+
/** @type {VersionBump} */ (version.trim()),
6574
acc[name].version
6675
);
6776
acc[name].reamde_content[type] += `\n${format_readme_content(
@@ -76,17 +85,30 @@ const changedPackages = changsets.reduce(
7685
}
7786
return acc;
7887
},
79-
{}
88+
/** @type {Record<string, ChangedPackage>} */ ({})
8089
);
8190

91+
/**
92+
* @param {VersionBump} newVersion
93+
* @param {VersionBump} oldVersion
94+
* @returns {VersionBump}
95+
*/
8296
function getMaximumBump(newVersion, oldVersion) {
8397
const versionOrder = ["patch", "minor", "major"];
8498
const newVersionIndex = versionOrder.indexOf(newVersion);
8599
const oldVersionIndex = versionOrder.indexOf(oldVersion);
86100

87-
return versionOrder[Math.max(newVersionIndex, oldVersionIndex)];
101+
return /** @type {VersionBump} */ (
102+
versionOrder[Math.max(newVersionIndex, oldVersionIndex)]
103+
);
88104
}
89105

106+
/**
107+
* @param {string} pr
108+
* @param {string} short_sha
109+
* @param {string} sha
110+
* @param {string} _content
111+
*/
90112
function format_readme_content(pr, short_sha, sha, _content) {
91113
return `- [${pr}](https://github.com/gradio-app/gradio/pull/${pr.replace(
92114
"#",
@@ -96,6 +118,7 @@ function format_readme_content(pr, short_sha, sha, _content) {
96118

97119
const { packages } = await getPackages(process.cwd());
98120

121+
/** @type {PackageToWrite[]} */
99122
const packages_to_write = [];
100123

101124
for (const pkg of packages) {
@@ -109,6 +132,7 @@ for (const pkg of packages) {
109132
version: new_version
110133
};
111134

135+
/** @type {[string, string][]} */
112136
let deps_updated = [];
113137
for (const dep in new_package_json.dependencies) {
114138
if (`"${dep}"` in changedPackages) {
@@ -123,7 +147,10 @@ for (const pkg of packages) {
123147

124148
deps_updated.push([
125149
dep,
126-
get_new_version(dep_version, changedPackages[`"${dep}"`].version)
150+
get_new_version(
151+
dep_version ?? "0.0.0",
152+
changedPackages[`"${dep}"`].version
153+
)
127154
]);
128155
}
129156
}
@@ -171,6 +198,12 @@ for (const pkg of packages) {
171198
}
172199
}
173200

201+
/**
202+
* @param {string} name
203+
* @param {string} version
204+
* @param {ReadmeContent} changes
205+
* @param {[string, string][]} deps_updated
206+
*/
174207
function make_changelog(name, version, changes, deps_updated) {
175208
const { feat, fix, highlight } = changes;
176209
let changelog = `# ${name}
@@ -194,6 +227,10 @@ function make_changelog(name, version, changes, deps_updated) {
194227
return changelog;
195228
}
196229

230+
/**
231+
* @param {string} version
232+
* @param {VersionBump | string} bump
233+
*/
197234
function get_new_version(version, bump) {
198235
const [_major, _minor, _patch, prerelease] = version.split(".");
199236

demo/main_note/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from math import log2, pow
22

33
import numpy as np
4-
from scipy.fftpack import fft
4+
from scipy.fftpack import fft # ty: ignore[unresolved-import]
55

66
import gradio as gr
77
from gradio.media import get_audio

demo/spectogram/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import matplotlib.pyplot as plt
22
import numpy as np
3-
from scipy import signal
3+
from scipy import signal # ty: ignore[unresolved-import]
44

55
import gradio as gr
66

0 commit comments

Comments
 (0)