Skip to content

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

@KotlinIsland

Description

@KotlinIsland

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions