Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1e91f11

Browse filesBrowse files
authored
Merge pull request #13602 from anntzer/unhashable
Deprecate cbook.is_hashable.
2 parents 381acf5 + ea9c158 commit 1e91f11
Copy full SHA for 1e91f11

File tree

Expand file treeCollapse file tree

3 files changed

+10
-7
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+10
-7
lines changed
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Deprecations
2+
````````````
3+
4+
``cbook.is_hashable`` is deprecated (use
5+
``isinstance(..., collections.abc.Hashable)`` instead).

‎lib/matplotlib/cbook/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook/__init__.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ def iterable(obj):
350350
return True
351351

352352

353+
@deprecated("3.1", alternative="isinstance(..., collections.abc.Hashable)")
353354
def is_hashable(obj):
354355
"""Returns true if *obj* can be hashed"""
355356
try:

‎lib/matplotlib/legend.py

Copy file name to clipboardExpand all lines: lib/matplotlib/legend.py
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -754,18 +754,15 @@ def get_legend_handler(legend_handler_map, orig_handle):
754754
method-resolution-order. If no matching key is found, it
755755
returns ``None``.
756756
"""
757-
if is_hashable(orig_handle):
758-
try:
759-
return legend_handler_map[orig_handle]
760-
except KeyError:
761-
pass
762-
757+
try:
758+
return legend_handler_map[orig_handle]
759+
except (TypeError, KeyError): # TypeError if unhashable.
760+
pass
763761
for handle_type in type(orig_handle).mro():
764762
try:
765763
return legend_handler_map[handle_type]
766764
except KeyError:
767765
pass
768-
769766
return None
770767

771768
def _init_legend_box(self, handles, labels, markerfirst=True):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.