Closed
Description
In challenge intermediate/literalstring, function execute_query
has a parament accepted Iterable[str]
,and set default value ...
. The same pattern is observed in the provided solution.
def execute_query(sql, parameters: Iterable[str] = ...):
"""No need to implement it"""
This will cause a type check error by pyright
error: Expression of type "ellipsis" cannot be assigned to parameter of type "Iterable[str]"
It seems like I must access type check by changing Iterable[str]
to Iterable[str] | EllipsisType
, like
from typing import Iterable, LiteralString
from types import EllipsisType
def execute_query(sql: LiteralString, parameters: Iterable[str] | EllipsisType = ...):
"""No need to implement it"""
or change ...
to ()
for type check.
from typing import Iterable, LiteralString
from types import EllipsisType
def execute_query(sql: LiteralString, parameters: Iterable[str] = ()):
"""No need to implement it"""
I don't think either of the above solutions to be the best way for this issue, but I don't know any better way to use ellipsis for default parameter with type hint.
Metadata
Metadata
Assignees
Labels
No labels