Skip to content
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

Import submodules into __init__.py for IDE code completion #174

Merged
merged 2 commits into from Dec 12, 2017

Conversation

alysivji
Copy link
Contributor

@alysivji alysivji commented Dec 2, 2017

Fix for #144, but only for the dash library itself.

I was also looking to add IDE completion for dash-core-components, but this seems a bit more difficult as component data is loaded from metadata.json.

import dash_core_components as dcc
print(dir(dcc))

We see all the core components in the namespace (and, therefore, in IPython), but they do not show up in the IDE. Hardcoding __all__ is a workaround, but not something I want to do.

@chriddyp do you have any thoughts on this?

dash/__init__.py Outdated
@@ -1,3 +1,7 @@
from .dash import Dash # noqa: F401
from . import authentication # noqa: F401
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's leave this one out, as it isn't used anymore (dash-auth package is used instead)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@chriddyp
Copy link
Member

This looks good to me. Is this syntax safe for python 2 and python 3? Tests passed, so I'm assuming that it is.

@chriddyp
Copy link
Member

IDE completion for the component libraries will probably require doing code generation/builds rather than dynamic code evaulation at runtime. This was started in #150, I'll continue the discussion over there.

@chriddyp
Copy link
Member

I was also looking to add IDE completion for dash-core-components, but this seems a bit more difficult as component data is loaded from metadata.json.

I've added some comments about what would be required to do this here: #150 (comment)

@alysivji
Copy link
Contributor Author

Relative imports work in both Python 2 and 3. Looks like they were introduced in Python2.5 via PEP 328.

Thanks for the detailed writeup on how to add IDE completion for components. I will take a look when I get some time.

@chriddyp
Copy link
Member

Thanks @alysivji !

@chriddyp chriddyp merged commit b61f0d3 into plotly:master Dec 12, 2017
HammadTheOne pushed a commit to HammadTheOne/dash that referenced this pull request May 28, 2021
Update component gen process for recent MDN changes
HammadTheOne pushed a commit that referenced this pull request Jul 23, 2021
Update component gen process for recent MDN changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants