basedpyright
basedpyright copied to clipboard
`deprecated` decorator should work with messages that are `Literal` or `LiteralString`
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
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
What if the consumer is using based or something that supports it?
https://github.com/DetachHead/basedpyright/issues/539#issuecomment-2330663351