Skip to content

Commit 504efc3

Browse files
committed
include dcc and table extras in __all__
and test that this fixes imports from the old packages
1 parent 4bdc6e9 commit 504efc3

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

components/dash-core-components/dash_core_components_base/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@
44
import dash as _dash
55

66
from ._imports_ import * # noqa: F401, F403, E402
7-
from ._imports_ import __all__ # noqa: E402
7+
from ._imports_ import __all__ as _components
88
from .express import ( # noqa: F401, E402
99
send_bytes,
1010
send_data_frame,
1111
send_file,
1212
send_string,
1313
)
1414

15+
__all__ = _components + [
16+
"send_bytes",
17+
"send_data_frame",
18+
"send_file",
19+
"send_string",
20+
]
21+
1522
_basepath = _os.path.dirname(__file__)
1623
_filepath = _os.path.abspath(_os.path.join(_basepath, "package-info.json"))
1724
with open(_filepath) as f:

components/dash-table/dash_table_base/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
_sys.exit(1)
1515

1616
from ._imports_ import * # noqa: E402, F401, F403
17-
from ._imports_ import __all__ # noqa: E402
17+
from ._imports_ import __all__ as _components
1818
from . import Format # noqa: F401, E402
1919
from . import FormatTemplate # noqa: F401, E402
2020

21+
__all__ = _components + ["Format", "FormatTemplate"]
22+
2123
_basepath = _os.path.dirname(__file__)
2224
_filepath = _os.path.abspath(_os.path.join(_basepath, "package-info.json"))
2325
with open(_filepath) as f:

tests/unit/test_old_imports.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from pytest import warns
2+
3+
from dash import dcc, dash_table
4+
5+
6+
def filter_dir(package):
7+
ignore = [
8+
"warnings",
9+
"json",
10+
"async_resources",
11+
"package",
12+
"package_name",
13+
"f",
14+
"express",
15+
]
16+
return sorted(
17+
[
18+
item
19+
for item in dir(package)
20+
if item == "__version__" or (item[0] not in "@_" and item not in ignore)
21+
]
22+
)
23+
24+
25+
def test_old_dcc():
26+
with warns(UserWarning, match="dash_core_components package is deprecated"):
27+
import dash_core_components as _dcc
28+
29+
old_dir = filter_dir(_dcc)
30+
new_dir = filter_dir(dcc)
31+
32+
assert old_dir == new_dir
33+
34+
35+
def test_old_table():
36+
with warns(UserWarning, match="dash_table package is deprecated"):
37+
import dash_table as _dt
38+
39+
old_dir = filter_dir(_dt)
40+
new_dir = filter_dir(dash_table)
41+
42+
assert old_dir == new_dir

0 commit comments

Comments
 (0)