Skip to content

Baffling error message if you forget to pass a deprecation message to @deprecated when it's decorating a class #295

@AlexWaygood

Description

@AlexWaygood

I stumbled across this while reviewing #294, and it took me ages to figure out what I was doing wrong:

>>> import typing_extensions as t
>>> @t.deprecated
... class Foo: ...
...
>>> class Bar(Foo): pass
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: function() argument 'code' must be code, not str

The issue, of course, is that you're meant to pass a deprecation message to @deprecated, e.g.:

import typing_extensions as t

@t.deprecated('Foo will go away soon')
class Foo: ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy