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

Skip to content

Commit ed48d5a

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 6d101fd commit ed48d5a

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
@@ -2142,6 +2142,8 @@ def rgrids(
21422142
if all(p is None for p in [radii, labels, angle, fmt]) and not kwargs:
21432143
lines_out: list[Line2D] = ax.yaxis.get_gridlines()
21442144
labels_out: list[Text] = ax.yaxis.get_ticklabels()
2145+
elif radii is None:
2146+
raise TypeError("'radii' cannot be None when other parameters are passed")
21452147
else:
21462148
lines_out, labels_out = ax.set_rgrids(
21472149
radii, labels=labels, angle=angle, fmt=fmt, **kwargs)
@@ -2215,6 +2217,8 @@ def thetagrids(
22152217
if all(param is None for param in [angles, labels, fmt]) and not kwargs:
22162218
lines_out: list[Line2D] = ax.xaxis.get_ticklines()
22172219
labels_out: list[Text] = ax.xaxis.get_ticklabels()
2220+
elif angles is None:
2221+
raise TypeError("'angles' cannot be None when other parameters are passed")
22182222
else:
22192223
lines_out, labels_out = ax.set_thetagrids(angles,
22202224
labels=labels, fmt=fmt,

0 commit comments

Comments
 (0)
0