script_binding: Add type check on servo script bindings (#38161)

Introduce type checking with Pyrefly in `components/script_bindings`

This commit adds Pyrefly-based type checking to the
`components/script_bindings` directory. The primary goal is to catch
type inconsistencies early and reduce the likelihood of unexpected
runtime errors.

This change affects the `webidl` component, as these script bindings are
responsible for connecting WebIDL specifications to the Rust codebase.

Testing: `./mach test-wpt webidl`
Fixes: *Link to an issue this pull requests fixes or remove this line if
there is no issue*

---------

Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
This commit is contained in:
Jerens Lensun 2025-08-01 12:34:24 +08:00 committed by GitHub
parent 4ce5b17605
commit b05d265de5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 176 additions and 88 deletions

View file

@ -12,6 +12,7 @@ import string
import traceback
from collections import OrderedDict, defaultdict
from itertools import chain
from typing import Any
from ply import lex, yacc
@ -2522,7 +2523,7 @@ class IDLEnum(IDLObjectWithIdentifier):
class IDLType(IDLObject):
Tags = enum(
Tags: Any = enum(
# The integer types
"int8",
"uint8",

View file

@ -0,0 +1,21 @@
diff --git a/third_party/WebIDL/WebIDL.py b/third_party/WebIDL/WebIDL.py
index b742a06bddd..babad83322f 100644
--- a/third_party/WebIDL/WebIDL.py
+++ b/third_party/WebIDL/WebIDL.py
@@ -12,6 +12,7 @@ import string
import traceback
from collections import OrderedDict, defaultdict
from itertools import chain
+from typing import Any
from ply import lex, yacc
@@ -2527,7 +2528,7 @@ class IDLEnum(IDLObjectWithIdentifier):
class IDLType(IDLObject):
- Tags = enum(
+ Tags: Any = enum(
# The integer types
"int8",
"uint8",

View file

@ -8,6 +8,7 @@ patch < like-as-iterable.patch
patch < builtin-array.patch
patch < array-type.patch
patch < transferable.patch
patch < idltype-tags-type-hint.patch
wget https://hg.mozilla.org/mozilla-central/archive/tip.zip/dom/bindings/parser/tests/ -O tests.zip
rm -r tests