Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1372dbe

Browse files
committed
ENH: include property name in artist AttributeError
1 parent c4510ca commit 1372dbe

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/matplotlib/artist.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,8 @@ def _update_props(self, props, errfmt):
11901190
Helper for `.Artist.set` and `.Artist.update`.
11911191
11921192
*errfmt* is used to generate error messages for invalid property
1193-
names; it gets formatted with ``type(self)`` and the property name.
1193+
names; it gets formatted with ``type(self)`` for "{cls}" and the
1194+
property name for "{prop_name}".
11941195
"""
11951196
ret = []
11961197
with cbook._setattr_cm(self, eventson=False):
@@ -1203,7 +1204,8 @@ def _update_props(self, props, errfmt):
12031204
func = getattr(self, f"set_{k}", None)
12041205
if not callable(func):
12051206
raise AttributeError(
1206-
errfmt.format(cls=type(self), prop_name=k))
1207+
errfmt.format(cls=type(self), prop_name=k),
1208+
name=k)
12071209
ret.append(func(v))
12081210
if ret:
12091211
self.pchanged()

lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1501,8 +1501,9 @@ def test_calling_conventions(self):
15011501
ax.voxels(x, y)
15021502
# x, y, z are positional only - this passes them on as attributes of
15031503
# Poly3DCollection
1504-
with pytest.raises(AttributeError):
1504+
with pytest.raises(AttributeError, match="keyword argument 'x'") as exec_info:
15051505
ax.voxels(filled=filled, x=x, y=y, z=z)
1506+
assert exec_info.value.name == 'x'
15061507

15071508

15081509
def test_line3d_set_get_data_3d():

0 commit comments

Comments
 (0)