Skip to content

Commit 28cf237

Browse files
authored
Merge pull request #31758 from anntzer/tl
Fix invalid format string in set_xticklabels error message.
2 parents e3bc6a3 + cc24bcf commit 28cf237

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

lib/matplotlib/axis.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,11 +2227,10 @@ def set_ticklabels(self, labels, *, minor=False, fontdict=None, **kwargs):
22272227
labels = [t.get_text() if hasattr(t, 'get_text') else t
22282228
for t in labels]
22292229
except TypeError:
2230-
raise TypeError(f"{labels:=} must be a sequence") from None
2230+
raise TypeError(f"{labels=!r} must be a sequence") from None
22312231
locator = (self.get_minor_locator() if minor
22322232
else self.get_major_locator())
22332233
if not labels:
2234-
# eg labels=[]:
22352234
formatter = mticker.NullFormatter()
22362235
elif (isinstance(locator, mticker.FixedLocator) or
22372236
(hasattr(locator, 'base') and

lib/matplotlib/tests/test_axes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7032,6 +7032,8 @@ def test_xticks_bad_args():
70327032
ax = plt.figure().add_subplot()
70337033
with pytest.raises(TypeError, match='must be a sequence'):
70347034
ax.set_xticks([2, 9], 3.1)
7035+
with pytest.raises(TypeError, match='must be a sequence'):
7036+
ax.set_xticks([2, 9], ax)
70357037
with pytest.raises(ValueError, match='must be 1D'):
70367038
plt.xticks(np.arange(4).reshape((-1, 1)))
70377039
with pytest.raises(ValueError, match='must be 1D'):

0 commit comments

Comments
 (0)