Expression of type "Unknown | None" cannot be assigned to declared type "Runnable[Unknown, Unknown]"
Type "Unknown | None" cannot be assigned to type "Runnable[Unknown, Unknown]"
Type "None" cannot be assigned to type "Runnable[Unknown, Unknown]" Pylance(reportGeneralTypeIssues)
Pylance suggests that the code cannot guarantee that the .get("runnable") call returns a Runnable.
This is an inconvenience when copy-pasting to get started with chainlit.
Solution
I suggest you change the docs to the following, to inform the type checker that we will always receive a value with the type Runnable:
Would make a PR directly, but the repo seems to require me to create a fork, so I'm taking the lazy route and just raising an issue ;-)
Potential Limitations
typing.cast was introduced in Python 3.5 together with the typing module, so if you only support Python v3.5+, this change should work for everyone. If it's correct that chainlit currently supports >=3.8.1 and <3.12, the change should be fine.
Path: /integrations/langchain
This is a suggestion for a minor improvement of the LangChain integration docs.
Environment
Problem
The below code, generates an inconvenient warning from Pylance in VS Code.
Code:
Warning:
Pylance suggests that the code cannot guarantee that the
.get("runnable")
call returns a Runnable.This is an inconvenience when copy-pasting to get started with
chainlit
.Solution
I suggest you change the docs to the following, to inform the type checker that we will always receive a value with the type Runnable:
Would make a PR directly, but the repo seems to require me to create a fork, so I'm taking the lazy route and just raising an issue ;-)
Potential Limitations
typing.cast
was introduced in Python 3.5 together with thetyping
module, so if you only support Python v3.5+, this change should work for everyone. If it's correct thatchainlit
currently supports >=3.8.1 and <3.12, the change should be fine.Have not tested this with any other type checker.