-
-
Notifications
You must be signed in to change notification settings - Fork 776
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We've gotten a lot of complaints about how hard it is to call certain JS functions, but it's hard to do much to improve the situation without knowing anything about the specific function being called. However, if we know about the API, we can choose how to convert to/from JS as appropriate and make things a lot easier. This adds a method to JsProxy called `bind_sig` which adjusts how __getattr__ and __call__ work on the proxy so we can choose our converters. I added a class called JsSignature which guides what we do when we call the function. I completely rewrote JsProxy_Vectorcall to use this. I added handling for Promise results so we can automatically bind a signature to the result of the Promise. There's a lot leftover to do: * Generator and AsyncGenerator types * Alternatives A | B (try A converter and if it raises a TypeError fall back to B) * TypedDict converters * Make calling certain objects call `Reflect.construct` * Cleaner __getattr__ handling, __setattr__ handling * A way to raise AttributeError if the attribute is missing from the signature even if it's present in the JS object (important for backwards compatibility) * Signatures for JS stdlib functions My idea is that the signatures should simultaneously function as mypy typehints as much as this is practical.
- Loading branch information
Showing
16 changed files
with
1,724 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.