Skip to content

[BUG] dash.testing TypeError #2183

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

Closed
martinschorb opened this issue Aug 5, 2022 · 7 comments · Fixed by #2187
Closed

[BUG] dash.testing TypeError #2183

martinschorb opened this issue Aug 5, 2022 · 7 comments · Fixed by #2187

Comments

@martinschorb
Copy link

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:

def dash_thread_server() -> ThreadedRunner:
but I don't know what exactly could be wrong...

@T4rk1n
Copy link
Contributor

T4rk1n commented Aug 9, 2022

@martinschorb Did you install with pip install dash[testing] ?

@martinschorb
Copy link
Author

@martinschorb Did you install with pip install dash[testing] ?

dash was installed from conda-forge

@martinschorb
Copy link
Author

is the [testing] also required when using conda?

@T4rk1n
Copy link
Contributor

T4rk1n commented Aug 9, 2022

@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.

@T4rk1n
Copy link
Contributor

T4rk1n commented Aug 9, 2022

The error message is confusing, perhaps we can set the type with a name more recognizable in case of this error?

@T4rk1n T4rk1n changed the title dash.testing TypeError [BUG] dash.testing TypeError Aug 9, 2022
@martinschorb
Copy link
Author

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 (conda/conda#2984) or instead determine package dependencies (conda/conda#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.

@alexcjohnson
Copy link
Collaborator

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

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 a pull request may close this issue.

3 participants