[PR #2518] fix: Replace hardcoded PostgresSaver with cls in factory method #2754

Closed
opened 2026-02-20 17:47:30 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/2518

State: closed
Merged: Yes


Replace hardcoded PostgresSaver with cls in the from_conn_string factory method to improve subclassing support.

Changes

  • Modified from_conn_string to use cls instead of PostgresSaver when instantiating new instances
  • This change allows subclasses to properly inherit and override the factory method

Why

This refactor makes the PostgresSaver class more extensible by following Python's convention of using cls in class methods. This enables proper inheritance patterns where subclasses can reuse the factory method without modification.

Testing

The change is backward compatible and doesn't alter existing functionality. All existing tests should continue to pass.

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/2518 **State:** closed **Merged:** Yes --- Replace hardcoded `PostgresSaver` with `cls` in the `from_conn_string` factory method to improve subclassing support. ## Changes - Modified `from_conn_string` to use `cls` instead of `PostgresSaver` when instantiating new instances - This change allows subclasses to properly inherit and override the factory method ## Why This refactor makes the `PostgresSaver` class more extensible by following Python's convention of using `cls` in class methods. This enables proper inheritance patterns where subclasses can reuse the factory method without modification. ## Testing The change is backward compatible and doesn't alter existing functionality. All existing tests should continue to pass.
yindo added the pull-request label 2026-02-20 17:47:30 -05:00
yindo closed this issue 2026-02-20 17:47:30 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#2754