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

improve dash import test #1493

Merged
merged 3 commits into from
Dec 10, 2020
Merged

improve dash import test #1493

merged 3 commits into from
Dec 10, 2020

Conversation

alexcjohnson
Copy link
Collaborator

@alexcjohnson alexcjohnson commented Dec 10, 2020

Fixes #1143 - with the help of companion PRs in the various component repos. (In principle we should do this for all component repos as well as the boilerplate)

Through a confusing set of circumstances described in #1143, having a Python file with one of several common names in your directory (but NOT dash.py) which imports any dash component package causes a circular import of dash itself, which manifests as failing the "make sure you don't have a dash.py file in your directory" check in the __init__.py of the component package, because dash hasn't finished importing so doesn't have the attributes we're looking for.

I'm tempted to delete these checks entirely - if we did that, the circumstance described above would work fine, but when you do make a dash.py you'd see the error message:

  File "/Users/alex/plotly/dash-core-components/dash_core_components/__init__.py", line 30, in <module>
    from ._imports_ import *  # noqa: F401, F403
  File "/Users/alex/plotly/dash-core-components/dash_core_components/_imports_.py", line 1, in <module>
    from .Checklist import Checklist
  File "/Users/alex/plotly/dash-core-components/dash_core_components/Checklist.py", line 3, in <module>
    from dash.development.base_component import Component, _explicitize_args
ModuleNotFoundError: No module named 'dash.development'; 'dash' is not a package

Which is essentially what you'd see if you did this with any other Python package - import pandas when you have a file pandas.py for example.

And if we ever end up combining packages this whole business will be moot, as you'll never get to the point of generating this error. Still, for now these changes should solve the issue.

Contributor Checklist

  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR
  • I have added entry in the CHANGELOG.md

.circleci/config.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@Marc-Andre-Rivet Marc-Andre-Rivet left a comment

Choose a reason for hiding this comment

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

@alexcjohnson alexcjohnson merged commit cd2ff7c into dev Dec 10, 2020
@alexcjohnson alexcjohnson deleted the import-test branch December 10, 2020 16:03
alexcjohnson added a commit to plotly/dash-bio that referenced this pull request Dec 10, 2020
alexcjohnson added a commit to plotly/dash-cytoscape that referenced this pull request Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants