8000 Add more explicit error message for [r,theta]grids · matplotlib/matplotlib@10d2225 · GitHub
[go: up one dir, main page]

Skip to content

Commit 10d2225

Browse files
committed
Add more explicit error message for [r,theta]grids
mypy was unhappy because the first parameter in each case (angles/radii) is optional for the pyplot wrapper but required for the set_[r,theta]grids axes methods. The variable is optional because the pyplot version acts as both the getter and the setter, but the type is not sufficiently narrowed for mypy. If passed None, the underlying setters would error, though deeper in the stack either in numpy or upon setting ticks. Just be a bit more explicit and fail early with a targetted error message
1 parent 13eb563 commit 10d2225

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/matplotlib/pyplot.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,6 +2104,8 @@ def rgrids(
21042104
if all(p is None for p in [radii, labels, angle, fmt]) and not kwargs:
21052105
lines_out: list[Line2D] = ax.yaxis.get_gridlines()
21062106
labels_out: list[Text] = ax.yaxis.get_ticklabels()
2107+
elif radii is None:
2108+
raise TypeError("'radii' cannot be None when other parameters are passed")
21072109
else:
21082110
lines_out, labels_out = ax.set_rgrids(
21092111
radii, labels=labels, angle=angle, fmt=fmt, **kwargs)
@@ -2177,6 +2179,8 @@ def thetagrids(
21772179
if all(param is None for param in [angles, labels, fmt]) and not kwargs:
21782180
lines_out: list[Line2D] = ax.xaxis.get_ticklines()
21792181
labels_out: list[Text] = ax.xaxis.get_ticklabels()
2182+
elif angles is None:
2183+
raise TypeError("'angles' cannot be None when other parameters are passed")
21802184
else:
21812185
lines_out, labels_out = ax.set_thetagrids(angles,
21822186
labels=labels, fmt=fmt,

0 commit comments

Comments
 (0)
0