question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typehints / intellisense for Brython?

See original GitHub issue

Developing in Brython makes your IDE throw all sorts of inspection warnings, since the IDE cannot find the imports.

Steps to Fix:

  1. Stubs for Brython specific modules be created, and exposed via the brython package, so that they are accessible in the code as from brython.browser import document.

  2. Allow imports via the brython package. That is, the following two imports should produce the same results when brython is loaded on the webpage.

    from browser import html
    
    from brython.browser import html
    

Everything else remains the same. These newly exposed modules simply provide the IDE with the definitions. Brython still uses its precompiled brython.js and brython_stdlib.js files to provide functionality for these imports.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
gilchcommented, Jul 31, 2019

Maybe a .pyi file with type annotations would suffice? PyCharm, at least, seems to use those even if the corresponding .py file is absent. See PEP 484 for more information about the .pyi files. I’m also not sure if going through the brython package is necessary. It should be possible to have the PyPI package install multiple modules.

1reaction
PierreQuentelcommented, Aug 28, 2019

I understand the need, but solving this issue requires a good knowledge of development tools. I can’t keep it in the scope of the Brython project, so I am closing it with the tag “won’t fix”. Sorry about that ! If you want to create a specific project for this, I will try to help if I can.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No stubs for brython for PyCharm - crucial to make it ... - GitHub
I need autocomplete during coding in PyCharm. Python heart is fast coding so it is crucial. I can not import really module from...
Read more >
module browser.template - Brython documentation
The module template allows to dynamically generate some elements in a page, by including Python code blocks or expressions inside the HTML code....
Read more >
Introduction - Brython documentation
The Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, ......
Read more >
module browser.html - Brython documentation
module browser.html. This module exposes the HTML tags. The tag name is in uppercase letters. The classes defined are : HTML4 tags :...
Read more >
Introducing PyScript (summary of PyCon keynote)
Brython (similarly is Skulpt but which lacks DOM manipulation) is a new implementation with parser & built-in objects written in JS and standard...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found