Skip to content

Overloaded deprecated method use is not reported #18474

Open
@sobolevn

Description

Playground: https://mypy-play.net/?mypy=latest&python=3.12&gist=6ae94d19a2160b47cd3c3f2f0bc96553

This code does not produce a [deprecated] error:

# mypy: enable-error-code = deprecated
from typing import overload
from typing_extensions import deprecated

class Some:
    @overload
    @deprecated("reason2")
    def some(self) -> None: ...
    @overload
    def some(self, x: int) -> None: ...

Some().some()  # no error here!

However, this one does:

@overload
@deprecated("reason1")
def func() -> None: ...
@overload
def func(x: int) -> None: ...

func()  # E: overload def () of function __main__.func is deprecated: reason1

Version:

» mypy --version
mypy 1.15.0+dev.c9ed867352b0be6b2cca9df3c856f9047409751b (compiled: no)

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions