diff --git a/stdlib/2and3/turtle.pyi b/stdlib/2and3/turtle.pyi index c9d9d90f0ba0..c3ee65193a40 100644 --- a/stdlib/2and3/turtle.pyi +++ b/stdlib/2and3/turtle.pyi @@ -47,13 +47,13 @@ class TurtleScreen(TurtleScreenBase): def __init__(self, cv: Canvas, mode: str = ..., colormode: float = ..., delay: int = ...) -> None: ... def clear(self) -> None: ... @overload - def mode(self) -> str: ... + def mode(self, mode: None = ...) -> str: ... @overload def mode(self, mode: str) -> None: ... def setworldcoordinates(self, llx: float, lly: float, urx: float, ury: float) -> None: ... def register_shape(self, name: str, shape: Union[_PolygonCoords, Shape, None] = ...) -> None: ... @overload - def colormode(self) -> float: ... + def colormode(self, cmode: None = ...) -> float: ... @overload def colormode(self, cmode: float) -> None: ... def reset(self) -> None: ... @@ -65,11 +65,11 @@ class TurtleScreen(TurtleScreenBase): @overload def bgcolor(self, r: float, g: float, b: float) -> None: ... @overload - def tracer(self) -> int: ... + def tracer(self, n: None = ...) -> int: ... @overload def tracer(self, n: int, delay: Optional[int] = ...) -> None: ... @overload - def delay(self) -> int: ... + def delay(self, delay: None = ...) -> int: ... @overload def delay(self, delay: int) -> None: ... def update(self) -> None: ... @@ -82,11 +82,12 @@ class TurtleScreen(TurtleScreenBase): def listen(self, xdummy: Optional[float] = ..., ydummy: Optional[float] = ...) -> None: ... def ontimer(self, fun: Callable[[], Any], t: int = ...) -> None: ... @overload - def bgpic(self) -> str: ... + def bgpic(self, picname: None = ...) -> str: ... @overload def bgpic(self, picname: str) -> None: ... @overload - def screensize(self) -> Tuple[int, int]: ... + def screensize(self, canvwidth: None = ..., canvheight: None = ..., bg: None = ...) -> Tuple[int, int]: ... + # Looks like if self.cv is not a ScrolledCanvas, this could return a tuple as well @overload def screensize(self, canvwidth: int, canvheight: int, bg: Optional[_Color] = ...) -> None: ... onscreenclick = onclick @@ -114,18 +115,18 @@ class TNavigator(object): def xcor(self) -> float: ... def ycor(self) -> float: ... @overload - def goto(self, x: Tuple[float, float]) -> None: ... + def goto(self, x: Tuple[float, float], y: None = ...) -> None: ... @overload def goto(self, x: float, y: float) -> None: ... def home(self) -> None: ... def setx(self, x: float) -> None: ... def sety(self, y: float) -> None: ... @overload - def distance(self, x: Union[TNavigator, Tuple[float, float]]) -> float: ... + def distance(self, x: Union[TNavigator, Tuple[float, float]], y: None = ...) -> float: ... @overload def distance(self, x: float, y: float) -> float: ... @overload - def towards(self, x: Union[TNavigator, Tuple[float, float]]) -> float: ... + def towards(self, x: Union[TNavigator, Tuple[float, float]], y: None = ...) -> float: ... @overload def towards(self, x: float, y: float) -> float: ... def heading(self) -> float: ... @@ -145,18 +146,18 @@ class TNavigator(object): class TPen(object): def __init__(self, resizemode: str = ...) -> None: ... @overload - def resizemode(self) -> str: ... + def resizemode(self, rmode: None = ...) -> str: ... @overload def resizemode(self, rmode: str) -> None: ... @overload - def pensize(self) -> int: ... + def pensize(self, width: None = ...) -> int: ... @overload def pensize(self, width: int) -> None: ... def penup(self) -> None: ... def pendown(self) -> None: ... def isdown(self) -> bool: ... @overload - def speed(self) -> int: ... + def speed(self, speed: None = ...) -> int: ... @overload def speed(self, speed: _Speed) -> None: ... @overload @@ -208,7 +209,7 @@ class RawTurtle(TPen, TNavigator): def clear(self) -> None: ... def clone(self: _T) -> _T: ... @overload - def shape(self) -> str: ... + def shape(self, name: None = ...) -> str: ... @overload def shape(self, name: str) -> None: ... # Unsafely overlaps when no arguments are provided @@ -218,7 +219,7 @@ class RawTurtle(TPen, TNavigator): def shapesize(self, stretch_wid: Optional[float] = ..., stretch_len: Optional[float] = ..., outline: Optional[float] = ...) -> None: ... if sys.version_info >= (3,): @overload - def shearfactor(self) -> float: ... + def shearfactor(self, shear: None = ...) -> float: ... @overload def shearfactor(self, shear: float) -> None: ... # Unsafely overlaps when no arguments are provided @@ -229,7 +230,7 @@ class RawTurtle(TPen, TNavigator): def get_shapepoly(self) -> Optional[_PolygonCoords]: ... def settiltangle(self, angle: float) -> None: ... @overload - def tiltangle(self) -> float: ... + def tiltangle(self, angle: None = ...) -> float: ... @overload def tiltangle(self, angle: float) -> None: ... def tilt(self, angle: float) -> None: ... @@ -258,7 +259,14 @@ class RawTurtle(TPen, TNavigator): class _Screen(TurtleScreen): def __init__(self) -> None: ... - def setup(self, width: int = ..., height: int = ..., startx: int = ..., starty: int = ...) -> None: ... + # Note int and float are interpreted differently, hence the Union instead of just float + def setup( + self, + width: Union[int, float] = ..., + height: Union[int, float] = ..., + startx: Optional[int] = ..., + starty: Optional[int] = ... + ) -> None: ... def title(self, titlestring: str) -> None: ... def bye(self) -> None: ... def exitonclick(self) -> None: ... @@ -271,7 +279,7 @@ class Turtle(RawTurtle): RawPen = RawTurtle Pen = Turtle -def write_docstringdict(filename: str) -> None: ... +def write_docstringdict(filename: str = ...) -> None: ... # Note: it's somewhat unfortunate that we have to copy the function signatures. # It would be nice if we could partially reduce the redundancy by doing something @@ -295,13 +303,13 @@ if sys.version_info >= (3,): def clear() -> None: ... @overload -def mode() -> str: ... +def mode(mode: None = ...) -> str: ... @overload def mode(mode: str) -> None: ... def setworldcoordinates(llx: float, lly: float, urx: float, ury: float) -> None: ... def register_shape(name: str, shape: Union[_PolygonCoords, Shape, None] = ...) -> None: ... @overload -def colormode() -> float: ... +def colormode(cmode: None = ...) -> float: ... @overload def colormode(cmode: float) -> None: ... def reset() -> None: ... @@ -313,11 +321,11 @@ def bgcolor(color: _Color) -> None: ... @overload def bgcolor(r: float, g: float, b: float) -> None: ... @overload -def tracer() -> int: ... +def tracer(n: None = ...) -> int: ... @overload def tracer(n: int, delay: Optional[int] = ...) -> None: ... @overload -def delay() -> int: ... +def delay(delay: None = ...) -> int: ... @overload def delay(delay: int) -> None: ... def update() -> None: ... @@ -330,11 +338,11 @@ def onkey(fun: Callable[[], Any], key: str) -> None: ... def listen(xdummy: Optional[float] = ..., ydummy: Optional[float] = ...) -> None: ... def ontimer(fun: Callable[[], Any], t: int = ...) -> None: ... @overload -def bgpic() -> str: ... +def bgpic(picname: None = ...) -> str: ... @overload def bgpic(picname: str) -> None: ... @overload -def screensize() -> Tuple[int, int]: ... +def screensize(canvwidth: None = ..., canvheight: None = ..., bg: None = ...) -> Tuple[int, int]: ... @overload def screensize(canvwidth: int, canvheight: int, bg: Optional[_Color] = ...) -> None: ... onscreenclick = onclick @@ -357,18 +365,18 @@ def pos() -> Vec2D: ... def xcor() -> float: ... def ycor() -> float: ... @overload -def goto(x: Tuple[float, float]) -> None: ... +def goto(x: Tuple[float, float], y: None = ...) -> None: ... @overload def goto(x: float, y: float) -> None: ... def home() -> None: ... def setx(x: float) -> None: ... def sety(y: float) -> None: ... @overload -def distance(x: Union[TNavigator, Tuple[float, float]]) -> float: ... +def distance(x: Union[TNavigator, Tuple[float, float]], y: None = ...) -> float: ... @overload def distance(x: float, y: float) -> float: ... @overload -def towards(x: Union[TNavigator, Tuple[float, float]]) -> float: ... +def towards(x: Union[TNavigator, Tuple[float, float]], y: None = ...) -> float: ... @overload def towards(x: float, y: float) -> float: ... def heading() -> float: ... @@ -387,18 +395,18 @@ seth = setheading # Functions copied from TPen: @overload -def resizemode() -> str: ... +def resizemode(rmode: None = ...) -> str: ... @overload def resizemode(rmode: str) -> None: ... @overload -def pensize() -> int: ... +def pensize(width: None = ...) -> int: ... @overload def pensize(width: int) -> None: ... def penup() -> None: ... def pendown() -> None: ... def isdown() -> bool: ... @overload -def speed() -> int: ... +def speed(speed: None = ...) -> int: ... @overload def speed(speed: _Speed) -> None: ... @overload @@ -445,7 +453,7 @@ ht = hideturtle def setundobuffer(size: Optional[int]) -> None: ... def undobufferentries() -> int: ... @overload -def shape() -> str: ... +def shape(name: None = ...) -> str: ... @overload def shape(name: str) -> None: ... # Unsafely overlaps when no arguments are provided @@ -455,7 +463,7 @@ def shapesize() -> Tuple[float, float, float]: ... # type: ignore def shapesize(stretch_wid: Optional[float] = ..., stretch_len: Optional[float] = ..., outline: Optional[float] = ...) -> None: ... if sys.version_info >= (3,): @overload - def shearfactor() -> float: ... + def shearfactor(shear: None = ...) -> float: ... @overload def shearfactor(shear: float) -> None: ... # Unsafely overlaps when no arguments are provided @@ -466,7 +474,7 @@ if sys.version_info >= (3,): def get_shapepoly() -> Optional[_PolygonCoords]: ... def settiltangle(angle: float) -> None: ... @overload -def tiltangle() -> float: ... +def tiltangle(angle: None = ...) -> float: ... @overload def tiltangle(angle: float) -> None: ... def tilt(angle: float) -> None: ...