-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
stubs: false positiveType checkers report false errorsType checkers report false errors
Description
Turtle.dot()
is currently stubbed like:
from typing import TypeAlias
_Color: TypeAlias = str | tuple[float, float, float]
class Turtle:
def dot(self, size: int | None = None, *color: _Color) -> None: ...
Which for this code:
turtle = Turtle()
turtle.dot()
turtle.dot(10)
turtle.dot(size=10)
turtle.dot((0, 0, 0))
turtle.dot("blue")
turtle.dot(20, "blue")
turtle.dot(20, "blue")
turtle.dot(20, (0, 0, 0))
turtle.dot(20, 0, 0, 0)
Leads to these errors with pyright:
Argument of type "tuple[Literal[0], Literal[0], Literal[0]]" cannot be assigned to parameter "size" of type "int | None" in function "dot"
Type "tuple[Literal[0], Literal[0], Literal[0]]" is not assignable to type "int | None"
"tuple[Literal[0], Literal[0], Literal[0]]" is not assignable to "int"
"tuple[Literal[0], Literal[0], Literal[0]]" is not assignable to "None" (reportArgumentType)
Argument of type "Literal['blue']" cannot be assigned to parameter "size" of type "int | None" in function "dot"
Type "Literal['blue']" is not assignable to type "int | None"
"Literal['blue']" is not assignable to "int"
"Literal['blue']" is not assignable to "None" (reportArgumentType)
Argument of type "Literal[0]" cannot be assigned to parameter "color" of type "_Color" in function "dot"
Type "Literal[0]" is not assignable to type "_Color"
"Literal[0]" is not assignable to "str"
"Literal[0]" is not assignable to "tuple[float, float, float]" (reportArgumentType)
Argument of type "Literal[0]" cannot be assigned to parameter "color" of type "_Color" in function "dot"
Type "Literal[0]" is not assignable to type "_Color"
"Literal[0]" is not assignable to "str"
"Literal[0]" is not assignable to "tuple[float, float, float]" (reportArgumentType)
Argument of type "Literal[0]" cannot be assigned to parameter "color" of type "_Color" in function "dot"
Type "Literal[0]" is not assignable to type "_Color"
"Literal[0]" is not assignable to "str"
"Literal[0]" is not assignable to "tuple[float, float, float]" (reportArgumentType)
However they all work at runtime: https://github.com/python/cpython/pull/138773/files
Metadata
Metadata
Assignees
Labels
stubs: false positiveType checkers report false errorsType checkers report false errors