@@ -358,16 +358,17 @@ def finalize(wrapper: Callable[..., Any], new_doc: str) -> T:
358
358
# Modify the docstring to include a deprecation notice.
359
359
if (
360
360
_alternative
361
- and _alternative .split ("." )[- 1 ].lower () == _alternative .split ("." )[- 1 ]
361
+ and _alternative .rsplit ("." , maxsplit = 1 )[- 1 ].lower ()
362
+ == _alternative .rsplit ("." , maxsplit = 1 )[- 1 ]
362
363
):
363
364
_alternative = f":meth:`~{ _alternative } `"
364
365
elif _alternative :
365
366
_alternative = f":class:`~{ _alternative } `"
366
367
367
368
if (
368
369
_alternative_import
369
- and _alternative_import .split ("." )[- 1 ].lower ()
370
- == _alternative_import .split ("." )[- 1 ]
370
+ and _alternative_import .rsplit ("." , maxsplit = 1 )[- 1 ].lower ()
371
+ == _alternative_import .rsplit ("." , maxsplit = 1 )[- 1 ]
371
372
):
372
373
_alternative_import = f":meth:`~{ _alternative_import } `"
373
374
elif _alternative_import :
@@ -471,7 +472,7 @@ def warn_deprecated(
471
472
if not message :
472
473
message = ""
473
474
package_ = (
474
- package or name .split ("." )[0 ].replace ("_" , "-" )
475
+ package or name .split ("." , maxsplit = 1 )[0 ].replace ("_" , "-" )
475
476
if "." in name
476
477
else "LangChain"
477
478
)
@@ -490,7 +491,7 @@ def warn_deprecated(
490
491
message += f" and will be removed { removal } "
491
492
492
493
if alternative_import :
493
- alt_package = alternative_import .split ("." )[0 ].replace ("_" , "-" )
494
+ alt_package = alternative_import .split ("." , maxsplit = 1 )[0 ].replace ("_" , "-" )
494
495
if alt_package == package_ :
495
496
message += f". Use { alternative_import } instead."
496
497
else :
0 commit comments