basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

`deprecated` decorator should work with messages that are `Literal` or `LiteralString`

Open DetachHead opened this issue 1 year ago • 3 comments

Code sample in basedpyright playground

from typing import LiteralString
from warnings import deprecated

message: LiteralString = 'asdf'

@deprecated(message)
def foo(): ...

foo() # The function "foo" is deprecated (no message)

the message can be evaluated at compiletime so there's no reason it shouldn't display the message here. it's useful when you want to deprecate a bunch of stuff for the same reason

DetachHead avatar Sep 05 '24 01:09 DetachHead

in library mode/cringe mode (#539) it should report an error if you try to do this though, because it wouldn't work for downstream users if they aren't using basedpyright as well

DetachHead avatar Sep 05 '24 05:09 DetachHead

What if the consumer is using based or something that supports it?

KotlinIsland avatar Sep 05 '24 06:09 KotlinIsland

https://github.com/DetachHead/basedpyright/issues/539#issuecomment-2330663351

DetachHead avatar Sep 05 '24 06:09 DetachHead