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