Skip to content

Commit

Permalink
Address PR reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
InSyncWithFoo committed Jul 27, 2024
1 parent 8c7f06b commit 902f681
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
# > * `from` imports

from _directives_deprecated_pep702_example import Ham # E: Use of deprecated class Ham

import _directives_deprecated_pep702_example as library

from typing_extensions import deprecated


# > * References through module, class, or instance attributes

Expand Down Expand Up @@ -42,3 +43,65 @@

spam + 1 # E: Use of deprecated method Spam.__add__
spam += 1 # E: Use of deprecated method Spam.__add__


# > * Any usage of deprecated objects in their defining module


@deprecated("Deprecated")
def lorem() -> None: ...


ipsum = lorem() # E: Use of deprecated function lorem


# > There are additional scenarios where deprecations could come into play.
# > For example, an object may implement a `typing.Protocol`,
# > but one of the methods required for protocol compliance is deprecated.
# > As scenarios such as this one appear complex and relatively unlikely to come up in practice,
# > this PEP does not mandate that type checkers detect them.

from typing import Protocol, override


class Fooable(Protocol):

@deprecated("Deprecated")
def foo(self) -> None: ...

def bar(self) -> None: ...


class Fooer(Fooable):

@override
def foo(self) -> None: # E?: Implementation of deprecated method foo
...

def bar(self) -> None: ...


def foo_it(fooable: Fooable) -> None:
fooable.foo() # E: Use of deprecated method foo
fooable.bar()


# https://github.com/python/typing/pull/1822#discussion_r1693991644


class Fooable2(Protocol):

def foo(self) -> None: ...


class Concrete:

@deprecated("Deprecated")
def foo(self) -> None: ...


def take_fooable(f: Fooable2) -> None: ...


def caller(c: Concrete) -> None:
take_fooable(c) # E?: Concrete is a Fooable2, but only because of a deprecated method
34 changes: 0 additions & 34 deletions conformance/tests/directives_deprecated_protocol.py

This file was deleted.

20 changes: 0 additions & 20 deletions conformance/tests/directives_deprecated_same_module.py

This file was deleted.

0 comments on commit 902f681

Please sign in to comment.