PyCharm with Transcrypt

I've recently been using PyCharm with the Transcrypt transpiler.  While it has been working out really well for developing React apps in Python, one thing missing is auto-complete for the JavaScript libraries I import using require() in *.py files.   So for example, if I have a statement like this in the file:

MaterialUI = require('@material-ui/core')

Typing MaterialUI. does not give me list list of available properties and methods in the @material-ui/core library.

If I change the file type to .js then I get the list, but then I can't import the MaterialUI library into other Python modules using

from pymui import MaterialUI

Is there a way for PyCharm to treat the .py file as Python but still introspect the imported JavaScript libraries and provide autocomplete in Python modules that access them?

I know this is kind of a weird case, but it seems PyCharm has the technical capability to do it.


Comment actions Permalink

You can try changing file type settings to tell PyCharm to recognize all your .py files as JavaScript files. But this will affect all .py files in your project.

Also, you may be interested in this feature:

Feel free to vote and comment.

Comment actions Permalink

Thanks. Treating all py files as JS is not an option since it's mostly all Python code that I'm working with.  It's really just a few individual py files where I have my JS wrappers that assign the JS require() import to a Python attribute that can then be imported into other Python modules.  This keeps the JS stuff in one place and also keeps the Python linter happy.

Would something in Settings -> Languages & Frameworks -> Node.js & NPM section help with that if I set scope to just the py files it affects?  I'm not sure if those frameworks would affect the require() introspection in a py file.



Comment actions Permalink

It looks like language injections only work on strings and not keywords.  The crux of the problem seems to be that PyCharm doesn't recognize the "require" keyword in a Python file like it does in a JavaScript file, and so it doesn't act on it and attempt to do the introspection on the JS library name that is passed in to it.


Please sign in to leave a comment.