Uh oh!
There was an error while loading. Please reload this page.
[3.13] gh-138772: Add tests for Turtle.dot() signature (GH-138773) - #140992
Conversation
hugovk
commented
Nov 4, 2025
Let's keep it minimal and just add It can be another decision whether to backport all the other stuff. |
JanEricNitschke
commented
Nov 4, 2025
Should be ready now |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
| self.turtle.dot(size="blue") | ||
| self.turtle.dot(20, "blue") | ||
| self.turtle.dot(20, "blue") | ||
| self.turtle.dot(20, (0, 0, 0)) | ||
| self.turtle.dot(20, 0, 0, 0) | ||
| with self.assertRaises(TypeError): | ||
| self.turtle.dot(color="blue") |
There was a problem hiding this comment.
These lines
self.turtle.dot(size="blue")and
withself.assertRaises(TypeError):
self.turtle.dot(color="blue")are surprising.
I've tested these and it worked as here, but it doesn't make sense.
And the docs say size is an integer, and color is a color string, as expected.
Is it a bug, alright?
(just checked before open a new issue)
There was a problem hiding this comment.
Yeah, it is a bit weird, but the actual logic is:
defdot(self, size=None, *color):
"""Draw a dot with diameter size, using color. Optional arguments: size -- an integer >= 1 (if given) color -- a colorstring or a numeric color tuple Draw a circular dot with diameter size, using color. If size is not given, the maximum of pensize+4 and 2*pensize is used. Example (for a Turtle instance named turtle): >>> turtle.dot() >>> turtle.fd(50); turtle.dot(20, "blue"); turtle.fd(50) """ifnotcolor:
ifisinstance(size, (str, tuple)):
color=self._colorstr(size)
size=self._pensize+max(self._pensize, 4)
else:
color=self._pencolorifnotsize:
size=self._pensize+max(self._pensize, 4)
else:
ifsizeisNone:
size=self._pensize+max(self._pensize, 4)
color=self._colorstr(color)And the correct matching typehint is
@overloaddefdot(self, size: int|_Color|None=None) ->None: ...
@overloaddefdot(self, size: int|None, color: _Color, /) ->None: ...
@overloaddefdot(self, size: int|None, r: float, g: float, b: float, /) ->None: ...The signature from the docs is
turtle.dot()
turtle.dot(size)
turtle.dot(color, /)
turtle.dot(size, color, /)
turtle.dot(size, r, g, b, /)This makes it pretty clear the "color" is not a keyword arg, so (color="blue") shouldnt, work. But to make ("blue") and (20) work you have to have (size="blue") be valid, even though is probably isnt desired or recommended.
There was a problem hiding this comment.
I've opened an issue concerning size="blue": #141062
Uh oh!
There was an error while loading. Please reload this page.
(cherry picked from commit 2462807)
Wasnt 100% sure how to best do this, because all of the
TestTurtleScreenandTestTurtletests didn't exist at all in 3.13. So i just chose the simples way and clicked "accept incoming" on the resolution which added all tests in these classes because i think it makes sense. And obviously added the required imports.Or should i keep it to the absolutely minimal changes and only do