-
Notifications
You must be signed in to change notification settings - Fork 33
The ellipsis in the function parameters of challenge intermediate/literalstring causes challenge failed #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
May I ask which type checker are you using? Python-Type-Challenges uses pyright and it works as expected, see playground. It is normal that different type checkers behave differently here and there.
|
I'm using Pyright version 1.1.344, which you can reproduce in this playground. I found a related discussion in this issue of pyright and the corresponding release note of version 1.1.329. The key change mentioned is:
When an ellipsis is used in a function body, means not been implemented, Pyright treats the ellipsis as Any, for example: from typing import LiteralString, Iterable
def execute_query(sql: LiteralString, parameters: Iterable[str] = ...):
... will get: > pyright --pythonversion=3.12 test.py
0 errors, 0 warnings, 0 informations When using docstring, from typing import LiteralString, Iterable
def execute_query(sql: LiteralString, parameters: Iterable[str] = ...):
"""Not implemented yet.""" > pyright --pythonversion=3.12 test.py
test.py:3:67 - error: Expression of type "ellipsis" cannot be assigned to parameter of type "Iterable[str]"
"ellipsis" is incompatible with protocol "Iterable[str]"
"__iter__" is not present (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations I think adding an ellipsis within the function |
Thanks for digging into this. You're right about the current behavior (this comment describes it). I'll make a change to question.py to use ellipsis in function body. |
In challenge intermediate/literalstring, function
execute_query
has a parament acceptedIterable[str]
,and set default value...
. The same pattern is observed in the provided solution.This will cause a type check error by pyright
It seems like I must access type check by changing
Iterable[str]
toIterable[str] | EllipsisType
, likeor change
...
to()
for type check.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.
The text was updated successfully, but these errors were encountered: