Skip to content
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

Enable mypy for langgraph lib #1771

Merged
merged 9 commits into from
Sep 19, 2024
Merged

Conversation

nfcampos
Copy link
Contributor

No description provided.

@nfcampos nfcampos changed the title Fix some typing issues in langgraph lib Enable mypy for langgraph lib Sep 19, 2024
self, checkpoint: Optional[C], config: RunnableConfig
) -> Generator[Self, None, None]: ...

async def afrom_checkpoint(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing async?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was removed from the actual lib a while ago, but had been left in this protocol in checkpoint lib

def __init__(self, typ: Type[Value], names: set[Value]) -> None:
super().__init__(typ)
self.names = names
self.seen = set()
self.seen: set[str] = set()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why type as str rather than Value ?

libs/langgraph/langgraph/graph/graph.py Outdated Show resolved Hide resolved
libs/langgraph/langgraph/graph/state.py Outdated Show resolved Hide resolved
@@ -702,11 +714,23 @@ def _get_channels(
if name != "__slots__"
}
return (
{k: v for k, v in all_keys.items() if not is_managed_value(v)},
{k: v for k, v in all_keys.items() if isinstance(v, BaseChannel)},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because mypy doesn't know that everything that isn't a managed value is a base channel

tools: Union[ToolExecutor, Sequence[BaseTool], ToolNode],
*,
state_schema: Optional[StateSchemaType] = None,
messages_modifier: Optional[MessagesModifier] = None,
state_modifier: Optional[StateModifier] = None,
checkpointer: Optional[BaseCheckpointSaver] = None,
interrupt_before: Optional[Sequence[str]] = None,
interrupt_after: Optional[Sequence[str]] = None,
interrupt_before: Optional[list[str]] = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooc - why the change here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the type accepted by compile changed too

@@ -1,10 +1,13 @@
# type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

nfcampos and others added 2 commits September 19, 2024 14:37
Co-authored-by: William FH <13333726+hinthornw@users.noreply.github.com>
@nfcampos nfcampos merged commit 0bbe461 into main Sep 19, 2024
46 checks passed
@nfcampos nfcampos deleted the nc/19sep/mypy-langgraph-partial branch September 19, 2024 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants