-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
py2many test cases #61
Comments
Thanks for reporting. The purpose of this project is more that of helping the developer that has to frequently switch from python to js during development, rather than a one-to-one translation of python concepts. For this reason some of the "issues" you have written above probably will not be "fixed", especially because I tried to limit the runtime to a minimum where other projects like transcrypt do come with an accompanying library and runtime that tries to emulate more of python behavior. In addition to that, listing all your issues in one bug report doesn't help focusing on each one. Anyway, thanks again |
I didnt create a bunch of separate isues as I've found that most py->js transpilers have peculiar choices about what Python syntax they indent to support, vs what is out of scope, so some of the bugs I might raise are WONTFIXES, but others are considered to be bugs. I dont mean "peculiar" as derogatory - just each person solving this problem are all making different choices. Even Transcrypt is failing lots of py2many test cases, and seems intent on keeping some of their failings. The transpilers that want to maintain perfect CPython compatibility end up with a horridly large JS runtime shim. So far it looks like
I've investigated this a bit further, and it looks like |
No you're getting it wrong: pj as no special support for sets:
as you can see it doesn't generates a Usually a pj user would just use |
I am looking for a python to JS implementation to run within or alongside https://github.com/adsharma/py2many , and running pj on the tests in https://github.com/adsharma/py2many/tree/main/tests/cases I found some issues, that I thought worth sharing.
Most obvious is lack of support for
__name__
, especiallyif __name__ === "__main__":
. This isnt a big problem, as py2many can rewrite this before invoking pj.Another is that the
typing
import is not removed, which is already raised at #21 .Beyond that, compilation to ES6 fails for
ValueError: Unknown data type received.
ValueError: Unknown data type received.
TransformationError: Node type 'Set': Line: 10, column: 6. No transformation for the node
UnsupportedSyntaxError: Node type 'ClassDef': Line: 6, column: 0. Multiple inheritance is not supported
Many others fail for ES5 mode because they are using imports, usually of stdlib, and especially of stdlib which should just be stripped, especially
typing
c.f. #21 (comment)Invoking the successfully transpiled JS code often fails. e.g.
[].append
is not translated into the JS equivalent[].push
, which is breaking a few of the tests at runtime. After I manually fix that, a fun one isbitops.py
which fails because of bitops on booleans is resulting in ints instead of booleans. i.e. pj causesands
to be[ 0, 0, 0, 1 ]
which is not equal to[false, false, false, true]
. I've found bitops.py trips all of the Python to JavaScript transpilers that I've tried.The new Set syntax
{1, 2}
should be easy to implement assuming thatset
type is already implemented.stdlib
enum
support is covered by casesint_enum
andstr_enum
. These are special cases where multiple inheritance is used (mostly) to inform the underlying Python class about behaviour of the members, and could be roughly supported without actually supporting multiple inheritance. e.g.py2many
detects specific multiple base combinations for this.The text was updated successfully, but these errors were encountered: