SIGN IN SIGN UP

Replace `deprecated.deprecated()` with `typing_extensions.deprecated()` (#3255)

PyGitHub is using the `deprecated` Python package for deprecations until
now, but was only using the provided `deprecated()` decorator from it,
which since Python 3.13 has a stdlib equivalent with
`warnings.deprecated()`. See https://peps.python.org/pep-0702/ for
details.

Luckily `typing_extensions`, which we already use, provide the same
decorator for old Python versions (since 4.5), and just passes through
the stdlib one when using Python 3.13+.

The new decorator has multiple advantages:

* Removes the dependency on the `deprecated` package and the transitive
`wrapt` package (which is a C extension)
* Mypy can alert users of deprecated APIs since mypy 1.14 (opt-in), see
https://mypy-lang.blogspot.com/2024/12/mypy-114-released.html
* Pylance in VSCode gives visual hints and warnings when using a
deprecated function/class

There are some small differences between the decorators, which in our
case only affect one test case, where the old one would prefix a class
deprecation with "Call to deprecated class Foo" while the new one just
uses the message as is. Also with the new one a message is required, so
adjust the examples in the contribution guide.
C
Christoph Reiter committed
1ac8da700e4282cb2a3fd22cbd22861558e12f26
Parent: 29e8a96
Committed by GitHub <noreply@github.com> on 3/3/2025, 2:29:59 PM