You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The attached code demonstrates a type checking problem which occurs when constructing operations with graphtik at the head of its master branch, which is not present in the 10.5.0 release!
In summary, the following two type errors are found by pyright:
Upon attempting to compose an operation which has been created using the @operation decorator, the error Argument of type "dict[Unknown, Unknown]" cannot be assigned to parameter "op1" of type "Operation" in function "compose" is triggered.
Upon attempting to pass a string as the name of an operation being created using the @operation decorator, the error Argument of type "Literal['astronaut_responder']" cannot be assigned to parameter "name" of type "Token" in function "operation" is triggered.
Is this likely to be a misconfiguration somewhere on my side, or is there something which is a work-in-progress at the head of master branch which should be ignored for now?
fromgraphtik.fnopimportoperationfromgraphtik.pipelineimportcompose@operation(needs="needed", provides="provided")deftype_checker_not_ok_op(s: str) ->str:
"""Provoke a type checking failure by using the decorator to create a `FnOp`."""return"hello "+sdeftype_checker_ok_fn(s: str) ->str:
"""Bare undecorated function to wrap as an operation."""return"hello "+stype_checker_ok_op=operation(type_checker_ok_fn, needs="needed", provides="provided")
@operation(name="astronaut_responder", needs="astronaut_name", provides="provided")deftype_checker_not_ok_name_op(astronaut_name: str) ->str:
"""Provoke a type checking failure for the `name` parameter using the decorator."""return"I'm sorry, "+astronaut_name+", I'm afraid I can't do that."deftype_checker_checker_activator() ->None:
"""Provoke the type checker."""pipe_1=compose("A pipeline", type_checker_not_ok_op)
pipe_2=compose("Another pipeline", type_checker_ok_op)
pipe_3=compose("A third pipeline", type_checker_not_ok_name_op)
# All pipelines work, but:# * the first one fails type checking:# * the second one is identical and passes type checking# * the third one fails type checking for the `name` parameter:# $ pyright --version# pyright 1.1.323# $ pyright foo.py# /home/williamg/Projects/foo.py# /home/williamg/Projects/foo.py:19:17 - error: Argument of type "Literal['astronaut_responder']" cannot be assigned to parameter "name" of type "Token" in function "operation"# "Literal['astronaut_responder']" is incompatible with "Token" (reportGeneralTypeIssues)# /home/williamg/Projects/foo.py:27:36 - error: Argument of type "dict[Unknown, Unknown]" cannot be assigned to parameter "op1" of type "Operation" in function "compose"# "dict[Unknown, Unknown]" is incompatible with "Operation" (reportGeneralTypeIssues)# /home/williamg/Projects/foo.py:29:42 - error: Argument of type "dict[Unknown, Unknown]" cannot be assigned to parameter "op1" of type "Operation" in function "compose"# "dict[Unknown, Unknown]" is incompatible with "Operation" (reportGeneralTypeIssues)# 3 errors, 0 warnings, 0 informationsprint(pipe_1.compute({"needed": "cruel world"})["provided"])
print(pipe_2.compute({"needed": "kind world"})["provided"])
print(pipe_3.compute({"astronaut_name": "Dave"})["provided"])
if__name__=="__main__":
type_checker_checker_activator()
The text was updated successfully, but these errors were encountered:
The attached code demonstrates a type checking problem which occurs when constructing
operation
s with graphtik at the head of its master branch, which is not present in the 10.5.0 release!In summary, the following two type errors are found by
pyright
:@operation
decorator, the errorArgument of type "dict[Unknown, Unknown]" cannot be assigned to parameter "op1" of type "Operation" in function "compose"
is triggered.@operation
decorator, the errorArgument of type "Literal['astronaut_responder']" cannot be assigned to parameter "name" of type "Token" in function "operation"
is triggered.Is this likely to be a misconfiguration somewhere on my side, or is there something which is a work-in-progress at the head of
master
branch which should be ignored for now?The text was updated successfully, but these errors were encountered: