Skip to content

Broken imports in matplotlib tests in 6.2.0 #5253

Closed

Description

@mgorny

Since the 6.2.0 release, pytest fails to collect matplot tests:

========================================================= test session starts =========================================================
platform linux -- Python 3.13.5, pytest-8.4.1, pluggy-1.6.0
rootdir: /tmp/plotly.py
configfile: pyproject.toml
plugins: anyio-4.9.0, typeguard-4.4.4
collected 3383 items / 1 error                                                                                                        

=============================================================== ERRORS ================================================================
________________________________ ERROR collecting plotly/matplotlylib/mplexporter/tests/test_utils.py _________________________________
ImportError while importing test module '/tmp/plotly.py/plotly/matplotlylib/mplexporter/tests/test_utils.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.13/importlib/__init__.py:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
plotly/matplotlylib/mplexporter/tests/test_utils.py:2: in <module>
    from . import plt
E   ImportError: cannot import name 'plt' from 'plotly.matplotlylib.mplexporter.tests' (/tmp/plotly.py/plotly/matplotlylib/mplexporter/tests/__init__.py)
========================================================== warnings summary ===========================================================
plotly/conftest.py:4
  /tmp/plotly.py/plotly/conftest.py:4: PytestRemovedIn9Warning:
  
  The (path: py.path.local) argument is deprecated, please use (collection_path: pathlib.Path)
  see https://docs.pytest.org/en/latest/deprecations.html#py-path-local-arguments-for-hooks-replaced-with-pathlib-path

tests/test_io/test_to_from_plotly_json.py:112
  /tmp/plotly.py/tests/test_io/test_to_from_plotly_json.py:112: UserWarning:
  
  no explicit representation of timezones available for np.datetime64

.venv/lib/python3.13/site-packages/pdfrw/objects/pdfstring.py:120
  /tmp/plotly.py/.venv/lib/python3.13/site-packages/pdfrw/objects/pdfstring.py:120: SyntaxWarning:
  
  invalid escape sequence '\('

.venv/lib/python3.13/site-packages/pdfrw/objects/pdfstring.py:375
  /tmp/plotly.py/.venv/lib/python3.13/site-packages/pdfrw/objects/pdfstring.py:375: SyntaxWarning:
  
  invalid escape sequence '\['

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================= short test summary info =======================================================
ERROR plotly/matplotlylib/mplexporter/tests/test_utils.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
==================================================== 4 warnings, 1 error in 8.27s =====================================================

This seems to be caused by eb95abc that removed the plt import from plotly/matplotlylib/mplexporter/tests/__init__.py.

To reproduce:

pip install -e .[dev_optional] matplotlib
pytest

CC @gvwilson

Activity

  1. changed the title [-]Broken imports in matplotlib tests in 6.0.0[/-] [+]Broken imports in matplotlib tests in 6.2.0[/+] on Jun 27, 2025
  2. mgorny commented on Jun 27, 2025

    @mgorny
    ContributorAuthor

    Sorry, meant 6.2.0.

  3. janosh commented on Jun 29, 2025

    @janosh
    Contributor

    i also started getting broken internal imports

    ---> 16 from plotly.validators.scatter.line import DashValidator
         17 from plotly.validators.scatter.marker import SymbolValidator
         18 from tqdm import tqdm
    
    ModuleNotFoundError: No module named 'plotly.validators.scatter'

    downgrading to plotly==6.1.1 fixes the issue

  4. self-assigned this
    on Jul 2, 2025
  5. added
    bugsomething broken
    P1needed for current cycle
    on Jul 2, 2025
  6. gvwilson commented on Jul 2, 2025

    @gvwilson
    Contributor

    thanks for the report and confirmation - I'll try to prioritize work on this problem this week.

  7. janosh commented on Jul 10, 2025

    @janosh
    Contributor

    from my side this issue is resolved thanks to janosh/pymatviz#310. no need to restore SymbolValidator or DashValidator but i recommend the v6.2.0 release notes be updated to document this breaking change!

  8. mgorny commented on Aug 13, 2025

    @mgorny
    ContributorAuthor

    The test suite is still broken in 6.3.0, though.

  9. added a commit that references this issue on Aug 13, 2025
    622428a
  10. mgorny commented on Aug 13, 2025

    @mgorny
    ContributorAuthor

    Filed #5322 to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1needed for current cyclebugsomething brokenregressionthis used to work

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions