8000 Undefined name: cbook --> matplotlib.cbook by cclauss · Pull Request #11301 · matplotlib/matplotlib · GitHub 8000
[go: up one dir, main page]

Skip to content

Conversation

@cclauss
Copy link
@cclauss cclauss commented May 24, 2018

Use the fully qualified name because matplotlib is currently imported but matplotlib.cbook is not.

flake8 testing of https://github.com/matplotlib/matplotlib on Python 3.6.3

$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

./lib/matplotlib/sphinxext/plot_directive.py:341:5: F821 undefined name 'cbook'
    cbook.warn_deprecated('3.0', name='remove_coding', removal='3.1')
    ^
1     F821 undefined name 'cbook'
1

@anntzer anntzer added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label May 24, 2018
@anntzer anntzer added this to the v3.0 milestone May 24, 2018
@anntzer
Copy link
Contributor
anntzer commented May 24, 2018

Can you instead use the following patch, which is the standard deprecation form:

@@ -164,7 +164,7 @@ except UserWarning:
     plt.switch_backend("Agg")
 else:
     import matplotlib.pyplot as plt
-from matplotlib import _pylab_helpers
+from matplotlib import _pylab_helpers, cbook
 
 __version__ = 2
 
@@ -334,11 +334,11 @@ def split_code_at_show(text):
     return parts
 
 
+@cbook.deprecated('3.0')
 def remove_coding(text):
     r"""
     Remove the coding comment, which six.exec\_ doesn't like.
     """
-    cbook.warn_deprecated('3.0', name='remove_coding', removal='3.1')
     sub_re = re.compile("^#\s*-\*-\s*coding:\s*.*-\*-$", flags=re.MULTILINE)
     return sub_re.sub("", text)

Thanks.

Use the _fully qualified name_ because __matplotlib__ is currently imported but __matplotlib.cbook__ is not.

flake8 testing of https://github.com/matplotlib/matplotlib on Python 3.6.3

$ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__
```
./lib/matplotlib/sphinxext/plot_directive.py:341:5: F821 undefined name 'cbook'
    cbook.warn_deprecated('3.0', name='remove_coding', removal='3.1')
    ^
1     F821 undefined name 'cbook'
1
```
Copy link
Member
@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

@anntzer are you ok to leave the depreaction as is?

@anntzer
Copy link
Contributor
anntzer commented May 24, 2018

Sure.

@anntzer anntzer merged commit ca6628b into matplotlib:master May 24, 2018
@cclauss cclauss deleted the patch-2 branch May 24, 2018 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0