dash
dash copied to clipboard
[BUG] dash.testing TypeError
Dear all,
I tried to run the example test from https://dash.plotly.com/testing. When executing pytest -k bsly001
, I run into:
_________________________________ ERROR at setup of test_bsly001_falsy_child _________________________________
@pytest.fixture
def dash_thread_server() -> ThreadedRunner:
"""Start a local dash server in a new thread."""
> with ThreadedRunner() as starter:
../../../../miniconda3/envs/dashtest/lib/python3.10/site-packages/dash/testing/plugin.py:110:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = typing.Any, args = (), kwds = {}
def __call__(self, *args, **kwds):
> raise TypeError(f"Cannot instantiate {self!r}")
E TypeError: Cannot instantiate typing.Any
../../../../miniconda3/envs/dashtest/lib/python3.10/typing.py:387: TypeError
========================================== short test summary info ===========================================
ERROR test_page1.py::test_bsly001_falsy_child - TypeError: Cannot instantiate typing.Any
- I use a fresh conda environment
-
pip list
:
async-generator 1.10
attrs 22.1.0
Brotli 1.0.9
brotlipy 0.7.0
certifi 2022.6.15
cffi 1.15.1
charset-normalizer 2.1.0
click 8.1.3
cryptography 37.0.1
dash 2.6.1
Flask 2.2.0
Flask-Compress 0.0.0
h11 0.13.0
idna 3.3
importlib-metadata 4.11.4
iniconfig 1.1.1
itsdangerous 2.1.2
Jinja2 3.1.2
MarkupSafe 2.1.1
outcome 1.2.0
packaging 21.3
pip 22.2.2
plotly 5.9.0
pluggy 1.0.0
py 1.11.0
pycparser 2.21
pyOpenSSL 22.0.0
pyparsing 3.0.9
PySocks 1.7.1
pytest 7.1.2
requests 2.28.1
selenium 4.2.0
setuptools 63.3.0
sniffio 1.2.0
sortedcontainers 2.4.0
tenacity 8.0.1
tomli 2.0.1
trio 0.21.0
trio-websocket 0.9.2
typing_extensions 4.3.0
urllib3 1.26.11
Werkzeug 2.2.1
wheel 0.37.1
wsproto 1.1.0
zipp 3.8.1
- downgrading
typing
to v.3 does not help
Similar Errors seem to be due to some wrong type definitions in functions. It points here: https://github.com/plotly/dash/blob/e746bdbbac5a3581a6cac7ba0431ef03bf7859b5/dash/testing/plugin.py#L108 but I don't know what exactly could be wrong...
@martinschorb Did you install with pip install dash[testing]
?
@martinschorb Did you install with
pip install dash[testing]
?
dash
was installed from conda-forge
is the [testing]
also required when using conda?
@martinschorb Yes it is always required for the testing utilities, what is happening here is the imports failed and we put the types to typing.Any
for dash to work without those but you cannot use the fixtures if it's not installed.
The error message is confusing, perhaps we can set the type with a name more recognizable in case of this error?
OK, that makes sense.
What confuses me are the brackets. When using conda:
conda install "dash[testing]" -c conda-forge
I get:
Looking for: ['dash']
...
All requested packages already installed
In fact, it seems that square brackets are not interpreted as optional packages by conda (https://github.com/conda/conda/issues/2984) or instead determine package dependencies (https://github.com/conda/conda/issues/7502).
In addition, "The Dash testing is now part of the main Dash package." stated on the main page lead me to thinking that it was already installed.
Is there a way to install dash testing through conda? dash_testing
or dash-testing
do not exist.
Probably the documentation could be more clear that currently pip
is the only way to obtain it.
Hmph, no, conda doesn't appear to support extras (to be clear, these aren't optional parts of our dash itself, they're optional dependencies. One suggested solution is to make a metapackage that installs the extras alongside the main package. Unfortunately dash has five different extras defined so in principle to make this work in Conda we'd either need 32 packages to cover all possible flavors of which extras to install, or make five additional packages that each just install one set of extras. Meantime just to get the dash fixtures working you can explicitly include all the packages listed here: https://github.com/plotly/dash/blob/dev/requires-testing.txt