[Feature] warn on @deprecated
Describe the Bug
https://typing.python.org/en/latest/spec/directives.html#deprecated
warn on the following:
- import deprecated class/function
- call deprecated function
For now, this can be a regular type error since we don't support different error levels yet. It should have its own error code(s) and be disabled by default to avoid causing false positives. Once we support warnings, we'll turn it on.
Sandbox Link
No response
(Only applicable for extension issues) IDE Information
No response
Hey, I am happy to do 1 or 2, which one are you looking into doing?
@Alex-Aron I haven't started working on either of them so you're free to take your pick. I've split this into sub-issues. Please let us know which one you'd like to look at and if you have any questions :)
I can work on #402 . What files would you recommend looking at first? I was looking into modifying lib/binding/function.rs and binding.rs first. Just want to make sure I am looking in the right direction. Thanks :)
@Alex-Aron
Function decoration info & other metadata is stored in this FuncFlags struct: https://github.com/facebook/pyrefly/blob/main/pyrefly/lib/types/callable.rs#L172
It would be a good starting point to see how that's populated & add a new is_deprecated field, then check the field and raise an error whenever it's called.
There's a few places that implicitly call functions under the hood and there's some nuances for overloads and such, but I was thinking maybe we can just start with the simple case where it's straightforward call expression: https://github.com/facebook/pyrefly/blob/bcc4ac7e7be208dd5234ee59b06a024115431c8f/pyrefly/lib/alt/expr.rs#L1388
Hey! I got an error up if @deprecated is above a function. Let me know how the pull request looks + any other general criticisms so I can improve future open source contributions.
All the warnings should now be implemented. We might want to consider whether to show the deprecation message in the warning as the next step, or maybe just call it done.
Thanks for your work on this! I think if it's easy to show the message we could add it, but otherwise I'm happy to consider this done until someone specifically requests it
Are we good to close this issue?