Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn when using deprecated functions (warnings.warn) #11439

Closed
KotlinIsland opened this issue Nov 3, 2021 · 3 comments
Closed

Warn when using deprecated functions (warnings.warn) #11439

KotlinIsland opened this issue Nov 3, 2021 · 3 comments

Comments

@KotlinIsland
Copy link
Contributor

Feature

import warnings
from typing import NoReturn

def foo() -> NoReturn:
    warnings.warn("this is deprecated", DeprecationWarning)
    raise NotImplementedError

foo()  # I would expect a warning here

Pitch

I think it would be based to report against deprecated methods, PyCharm supports this:
image

Another use case for this is warning of "unsupported operations":

class A:
    def foo(self) -> None:
        print()

class B(A):
    def foo(self) -> NoReturn:
        warnings.warn("this is an unsupported operation", DeprecationWarning)
        raise NotImplementedError()


B().foo()  # I would like a warning that this is unsupported
@hauntsaninja
Copy link
Collaborator

Thanks for the suggestion! PEP 702 is the way mypy would do this.

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale May 1, 2023
@bluenote10
Copy link
Contributor

@hauntsaninja What is the status of supporting PEP 702 in mypy? I tried to find some information or a tracking issue, but on first glance I couldn't find anything.

@hauntsaninja
Copy link
Collaborator

Feel free to open a tracking issue, or even better, a PR that implements it. Note that PEP 702 hasn't yet been officially accepted, so support would be provisional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants