mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 18:50:33 +00:00
fix(core): make removal optional in warn_deprecated (#37056)
Drop the `NotImplementedError` branch in `warn_deprecated` so callers can pass `pending=False` without specifying a `removal` version. The previous behavior contradicted the docstring (which claimed an empty default would auto-compute a removal version) — no such computation existed; the function just raised a placeholder "Need to determine which default deprecation schedule to use" error.
This commit is contained in:
@@ -71,10 +71,16 @@ def test_warn_deprecated(kwargs: dict[str, Any], expected_message: str) -> None:
|
||||
assert str(warning) == expected_message
|
||||
|
||||
|
||||
def test_undefined_deprecation_schedule() -> None:
|
||||
"""This test is expected to fail until we defined a deprecation schedule."""
|
||||
with pytest.raises(NotImplementedError):
|
||||
warn_deprecated("1.0.0", pending=False)
|
||||
def test_warn_deprecated_without_removal() -> None:
|
||||
"""`removal` is optional; warning omits the removal phrase when not provided."""
|
||||
with warnings.catch_warnings(record=True) as warning_list:
|
||||
warnings.simplefilter("always")
|
||||
warn_deprecated("1.0.0", name="SomeFunction", pending=False)
|
||||
|
||||
assert len(warning_list) == 1
|
||||
message = str(warning_list[0].message)
|
||||
assert message == "`SomeFunction` was deprecated in LangChain 1.0.0"
|
||||
assert "will be removed" not in message
|
||||
|
||||
|
||||
@deprecated(since="2.0.0", removal="3.0.0", pending=False)
|
||||
|
||||
Reference in New Issue
Block a user