@@ -296,7 +296,7 @@ def __init__(
296
296
if 'result_type' in _deprecated_kwargs :
297
297
if output_type is not str : # pragma: no cover
298
298
raise TypeError ('`result_type` and `output_type` cannot be set at the same time.' )
299
- warnings .warn ('`result_type` is deprecated, use `output_type` instead' , DeprecationWarning )
299
+ warnings .warn ('`result_type` is deprecated, use `output_type` instead' , DeprecationWarning , stacklevel = 2 )
300
300
output_type = _deprecated_kwargs .pop ('result_type' )
301
301
302
302
self .output_type = output_type
@@ -310,19 +310,23 @@ def __init__(
310
310
warnings .warn (
311
311
'`result_tool_name` is deprecated, use `output_type` with `ToolOutput` instead' ,
312
312
DeprecationWarning ,
313
+ stacklevel = 2 ,
313
314
)
314
315
315
316
self ._deprecated_result_tool_description = _deprecated_kwargs .pop ('result_tool_description' , None )
316
317
if self ._deprecated_result_tool_description is not None :
317
318
warnings .warn (
318
319
'`result_tool_description` is deprecated, use `output_type` with `ToolOutput` instead' ,
319
320
DeprecationWarning ,
321
+ stacklevel = 2 ,
320
322
)
321
323
result_retries = _deprecated_kwargs .pop ('result_retries' , None )
322
324
if result_retries is not None :
323
325
if output_retries is not None : # pragma: no cover
324
326
raise TypeError ('`output_retries` and `result_retries` cannot be set at the same time.' )
325
- warnings .warn ('`result_retries` is deprecated, use `max_result_retries` instead' , DeprecationWarning )
327
+ warnings .warn (
328
+ '`result_retries` is deprecated, use `max_result_retries` instead' , DeprecationWarning , stacklevel = 2
329
+ )
326
330
output_retries = result_retries
327
331
328
332
default_output_mode = (
@@ -472,7 +476,7 @@ async def main():
472
476
if 'result_type' in _deprecated_kwargs : # pragma: no cover
473
477
if output_type is not str :
474
478
raise TypeError ('`result_type` and `output_type` cannot be set at the same time.' )
475
- warnings .warn ('`result_type` is deprecated, use `output_type` instead.' , DeprecationWarning )
479
+ warnings .warn ('`result_type` is deprecated, use `output_type` instead.' , DeprecationWarning , stacklevel = 2 )
476
480
output_type = _deprecated_kwargs .pop ('result_type' )
477
481
478
482
_utils .validate_empty_kwargs (_deprecated_kwargs )
@@ -640,7 +644,7 @@ async def main():
640
644
if 'result_type' in _deprecated_kwargs : # pragma: no cover
641
645
if output_type is not str :
642
646
raise TypeError ('`result_type` and `output_type` cannot be set at the same time.' )
643
- warnings .warn ('`result_type` is deprecated, use `output_type` instead.' , DeprecationWarning )
647
+ warnings .warn ('`result_type` is deprecated, use `output_type` instead.' , DeprecationWarning , stacklevel = 2 )
644
648
output_type = _deprecated_kwargs .pop ('result_type' )
645
649
646
650
_utils .validate_empty_kwargs (_deprecated_kwargs )
@@ -879,7 +883,7 @@ def run_sync(
879
883
if 'result_type' in _deprecated_kwargs : # pragma: no cover
880
884
if output_type is not str :
881
885
raise TypeError ('`result_type` and `output_type` cannot be set at the same time.' )
882
- warnings .warn ('`result_type` is deprecated, use `output_type` instead.' , DeprecationWarning )
886
+ warnings .warn ('`result_type` is deprecated, use `output_type` instead.' , DeprecationWarning , stacklevel = 2 )
883
887
output_type = _deprecated_kwargs .pop ('result_type' )
884
888
885
889
_utils .validate_empty_kwargs (_deprecated_kwargs )
@@ -997,7 +1001,7 @@ async def main():
997
1001
if 'result_type' in _deprecated_kwargs : # pragma: no cover
998
1002
if output_type is not str :
999
1003
raise TypeError ('`result_type` and `output_type` cannot be set at the same time.' )
1000
- warnings .warn ('`result_type` is deprecated, use `output_type` instead.' , DeprecationWarning )
1004
+ warnings .warn ('`result_type` is deprecated, use `output_type` instead.' , DeprecationWarning , stacklevel = 2 )
1001
1005
output_type = _deprecated_kwargs .pop ('result_type' )
1002
1006
1003
1007
_utils .validate_empty_kwargs (_deprecated_kwargs )
@@ -1336,7 +1340,11 @@ async def output_validator_deps(ctx: RunContext[str], data: str) -> str:
1336
1340
return func
1337
1341
1338
1342
@deprecated ('`result_validator` is deprecated, use `output_validator` instead.' )
1339
- def result_validator (self , func : Any , / ) -> Any : ...
1343
+ def result_validator (self , func : Any , / ) -> Any :
1344
+ warnings .warn (
1345
+ '`result_validator` is deprecated, use `output_validator` instead.' , DeprecationWarning , stacklevel = 2
1346
+ )
1347
+ return self .output_validator (func ) # type: ignore
1340
1348
1341
1349
@overload
1342
1350
def tool (self , func : ToolFuncContext [AgentDepsT , ToolParams ], / ) -> ToolFuncContext [AgentDepsT , ToolParams ]: ...
0 commit comments