Skip to content

removing import that is prone to circular imports #9079

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

Merged
merged 1 commit into from
Aug 23, 2017

Conversation

fariza
Copy link
Member

@fariza fariza commented Aug 23, 2017

matplotlib.text was importing matplotlib.backend_bases.RendererBase without actually using it.

The problem is not that it doesn't use it, the problem is that this import creates a circular import.
The circular import became evident when working on PR #9022 adding
from matplotlib.table import Table to matplotlib.backend_tools.py gave the following error

  File "histogram_cumulative.py", line 39, in <module>
    import matplotlib.pyplot as plt
  File "/home/fariza/workspace/matplotlib/lib/matplotlib/pyplot.py", line 29, in <module>
    import matplotlib.colorbar
  File "/home/fariza/workspace/matplotlib/lib/matplotlib/colorbar.py", line 36, in <module>
    import matplotlib.contour as contour
  File "/home/fariza/workspace/matplotlib/lib/matplotlib/contour.py", line 22, in <module>
    import matplotlib.text as text
  File "/home/fariza/workspace/matplotlib/lib/matplotlib/text.py", line 33, in <module>
    from matplotlib.backend_bases import RendererBase
  File "/home/fariza/workspace/matplotlib/lib/matplotlib/backend_bases.py", line 68, in <module>
    import matplotlib.backend_tools as tools
  File "/home/fariza/workspace/matplotlib/lib/matplotlib/backend_tools.py", line 16, in <module>
    from matplotlib.table import Table
  File "/home/fariza/workspace/matplotlib/lib/matplotlib/table.py", line 34, in <module>
    from .text import Text
ImportError: cannot import name 'Text'

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 if tests pass

@QuLogic QuLogic merged commit b884161 into matplotlib:master Aug 23, 2017
@QuLogic QuLogic added this to the 2.1 (next point release) milestone Aug 23, 2017
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 this pull request may close these issues.

3 participants