Skip to content

The ellipsis in the function parameters of challenge intermediate/literalstring causes challenge failed #81

Closed
@b1indsight

Description

@b1indsight

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions