From b4abdf1f9fa5cd423ef5a3dc1c714aa579800492 Mon Sep 17 00:00:00 2001 From: Erick Friis Date: Wed, 5 Jun 2024 00:10:56 -0400 Subject: [PATCH] core: throw error on invalid alternative_import in deprecated --- libs/core/langchain_core/_api/deprecation.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libs/core/langchain_core/_api/deprecation.py b/libs/core/langchain_core/_api/deprecation.py index 1c253d99215..6c0af2b8589 100644 --- a/libs/core/langchain_core/_api/deprecation.py +++ b/libs/core/langchain_core/_api/deprecation.py @@ -100,6 +100,16 @@ def deprecated( pass """ + if ( + alternative_import + and "." not in alternative_import + or " " in alternative_import + ): + raise ValueError( + "alternative_import must be a fully qualified module path, e.g. " + "`package.module.Class`" + ) + def deprecate( obj: T, *,