How should `warnings.deprecated` be handled with `typing.overload`?

PEP 702 introduced warnings.deprecated, and gives an example to deprecate a specific overload:

@overload
@deprecated("Only str will be allowed")
def foo(x: int) -> str: ...
@overload
def foo(x: str) -> str: ...

I am encountering a function that is deprecated and includes two overloads:

@overload
def validate_arguments(func: None = None, *, config: 'ConfigType' = None) -> Callable[['AnyCallableT'], 'AnyCallableT']:
    ...


@overload
def validate_arguments(func: 'AnyCallableT') -> 'AnyCallableT':
    ...


@deprecated(
    'The `validate_arguments` method is deprecated; use `validate_call` instead.',
    category=PydanticDeprecatedSince20,
    stacklevel=2,
)
def validate_arguments(func: Optional['AnyCallableT'] = None, *, config: 'ConfigType' = None) -> Any:

To be clear, it is the function that is deprecated (not one of the overloads). How should I treat this case?
Add the deprecated decorator on both overloads?

I’m asking this from a typing perspective, as pyright currently only consider the function as being deprecated if called:

image

Whereas functions without overloads are marked as being deprecated even without calling them:
image

What you did is correct; I think pyright should consider the whole function as deprecated if the implementation is decorated.

Please open an issue in the pyright issue tracker.

Thanks to both of you.

Thanks for reporting this. It will be addressed in next week’s pyright release.