Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit c86eb7a

Browse files
committed
Update __init__.py to add IDE compatible imports.
1 parent d10f1c4 commit c86eb7a

File tree

2 files changed

+45
-21
lines changed

2 files changed

+45
-21
lines changed

dash_core_components/__init__.py

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,25 @@
22

33
import os as _os
44
import sys as _sys
5-
import glob as _glob
6-
from importlib import import_module as _import
7-
85
import dash as _dash
96

7+
from ._imports_ import *
8+
from ._imports_ import __all__
109
from .version import __version__
1110

11+
1212
if not hasattr(_dash, 'development'):
1313
print("Dash was not successfully imported. Make sure you don't have a file "
1414
"named \n'dash.py' in your current directory.", file=_sys.stderr)
1515
_sys.exit(1)
1616

17+
1718
_current_path = _os.path.dirname(_os.path.abspath(__file__))
1819

19-
_component_files = map(
20-
lambda x: _os.path.splitext(_os.path.basename(x))[0],
21-
filter(
22-
lambda x: _os.path.basename(x) not in ['__init__.py', 'version.py'],
23-
_glob.glob(_os.path.join(_current_path, '*.py'))
24-
)
25-
)
26-
27-
_components = [
28-
getattr(
29-
_import(".{:s}".format(c), package='dash_core_components'),
30-
c
31-
) for c in _component_files
32-
]
3320

3421
_this_module = _sys.modules[__name__]
3522

23+
3624
_js_dist = [
3725
{
3826
'external_url': 'https://cdn.plot.ly/plotly-1.38.0.min.js',
@@ -49,6 +37,7 @@
4937
}
5038
]
5139

40+
5241
_css_dist = [
5342
{
5443
'relative_package_path': [
@@ -70,7 +59,6 @@
7059
]
7160

7261

73-
for component in _components:
74-
setattr(_this_module, component.__name__, component)
75-
setattr(component, '_js_dist', _js_dist)
76-
setattr(component, '_css_dist', _css_dist)
62+
for _component in __all__:
63+
setattr(locals()[_component], '_js_dist', _js_dist)
64+
setattr(locals()[_component], '_css_dist', _css_dist)

dash_core_components/_imports_.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from .Checklist import Checklist
2+
from .DatePickerRange import DatePickerRange
3+
from .DatePickerSingle import DatePickerSingle
4+
from .Dropdown import Dropdown
5+
from .Graph import Graph
6+
from .Input import Input
7+
from .Interval import Interval
8+
from .Link import Link
9+
from .Location import Location
10+
from .Markdown import Markdown
11+
from .RadioItems import RadioItems
12+
from .RangeSlider import RangeSlider
13+
from .Slider import Slider
14+
from .SyntaxHighlighter import SyntaxHighlighter
15+
from .Textarea import Textarea
16+
from .Upload import Upload
17+
18+
19+
__all__ = [
20+
"Checklist",
21+
"DatePickerRange",
22+
"DatePickerSingle",
23+
"Dropdown",
24+
"Graph",
25+
"Input",
26+
"Interval",
27+
"Link",
28+
"Location",
29+
"Markdown",
30+
"RadioItems",
31+
"RangeSlider",
32+
"Slider",
33+
"SyntaxHighlighter",
34+
"Textarea",
35+
"Upload",
36+
]

0 commit comments

Comments
 (0)