mirror of
https://github.com/servo/servo.git
synced 2025-08-12 17:05:33 +01:00
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:
parent
4ce5b17605
commit
b05d265de5
7 changed files with 176 additions and 88 deletions
3
third_party/WebIDL/WebIDL.py
vendored
3
third_party/WebIDL/WebIDL.py
vendored
|
@ -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",
|
||||
|
|
21
third_party/WebIDL/idltype-tags-type-hint.patch
vendored
Normal file
21
third_party/WebIDL/idltype-tags-type-hint.patch
vendored
Normal 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",
|
1
third_party/WebIDL/update.sh
vendored
1
third_party/WebIDL/update.sh
vendored
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue