-
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
Provide an ignore mechanism #21
Comments
I'm wondering if a comment-style approach would be simpler here?
? |
It would be indeed much more simpler, unfortunately the standard Python's AST parser trashes all the comments. I want to use the typed_ast module to do type inference and it support type annotations in comments, maybe it can be also used for this purpose. |
Oh really? Damn stupid AST parser :( There is also this module http://redbaron.readthedocs.io/en/latest/ |
But I like the idea of the typed_ast module! |
It seems that typed_ast only allows comments on some lines, like def statements... and never on import statements.. @Lawouach that coverage library that you mentioned uses redbaron? |
Nope, the ast module but I think they do their own trick https://github.com/nedbat/coveragepy/blob/master/coverage/parser.py Search for the |
https://github.com/PyCQA/baron is effectively interesting, but it would require quite a lot of work to adapt PJ to that, even if it supported Python 3. |
I have needed this when using other python transpilers - Transcrypt uses a function (I think JS), and Rapydscript a special kind of string (v-string: v'console.log("hello from js")'). |
I am using strip-hints then py2many uses a very crude but effective import remover to strip out imports which wont have any meaning in the target language. |
It may happen that your Python code contains statements that are necessary for that Python code to run in Python but aren't required in JS.
Or, for instance, you maybe interested in hinting types in Python using the typing module but you don't want to import that module in JS.
Right now, this:
gets transformed to (es5):
The hints are only for the Python code benefits and should be ignored while transpiling.
Could we have come up with a solution so that simple statements are left out?
The text was updated successfully, but these errors were encountered: