Skip to content

Overloaded deprecated method use is not reported #18474

Closed
python-gitlab/python-gitlab
#3122

Description

@sobolevn

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)

Activity

  1. sobolevn commented on Jan 15, 2025

    @sobolevn
    MemberAuthor

    cc @tyralla who solved similar problems.

  2. tyralla commented on Jan 15, 2025

    @tyralla
    Collaborator

    Strange. I will have a look at it. Thanks for reporting!

  3. Viicos commented on Jan 15, 2025

    @Viicos
    Contributor

    Is it fixed by #18333, by any chance?

  4. sobolevn commented on Jan 15, 2025

    @sobolevn
    MemberAuthor

    Nope :(

    Using the same gist:

    (.venv) ~/Desktop/mypy  master ✗                                                          
    » gh pr checkout 18333  
    
    » mypy ex.py
    ex.py:5: error: An overloaded function outside a stub file must have an implementation  [no-overload-impl]
    ex.py:11: error: overload def () of function ex.func is deprecated: reason1  [deprecated]
    ex.py:14: error: An overloaded function outside a stub file must have an implementation  [no-overload-impl]
    
  5. added a commit that references this issue on Jan 15, 2025
    2461eff
  6. added a commit that references this issue on Jan 28, 2025
    93d1ce4
  7. added a commit that references this issue on Feb 24, 2025
    7e68e3a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions