Add unified deprecation system and @deprecated attribute#15770
Add unified deprecation system and @deprecated attribute#15770cptpiepmatz merged 28 commits intonushell:mainfrom
Conversation
|
This only shows the warnings when deprecated commands' definitions are parsed and not on calls to the deprecated commands right? I like the idea of I looked around a bit to see what's usually done when built-in commands are deprecated and they just throw a warning each time they are called and then run as usual. # aaa.nu
@deprecated
export def foo [] { ... }# bbb.nu
use aaa.nu
export def bar [] {
foo
}# repl
❯ use aaa.nu
# no warning
❯ use bbb.nu
# warning is thrown since |
whoops, not sure how that slipped my mind. this definitely needs to happen when parsing a call, not when parsing the definition
this is definitely needed, we discussed this before in the context of
i think we need something more complex than this so we can have a message still. maybe |
|
Yeah, a normal attribute makes more sense than a category for this since it can also store a message. We can add a |
|
just updated the PR with your suggest @Bahex. also added a "report log" (thread-global, rather than in |
|
this is almost ready, just need to move the |
|
this is ready now, I moved the report log into EngineState. I investigated if it would be possible to make this available to plugins, and I think it should be possible by implementing |
|
should be good to (re-)review @cptpiepmatz and @Bahex if you'd like to take a look |
# Description - Use #15770 to - improve `get --sensitive` deprecation warning - add deprecation warning for `filter` - refactor `filter` to use `where` as its implementation - replace usages of `filter` with `where` in `std` # User-Facing Changes - `get --sensitive` will raise a warning only once, during parsing whereas before it was raised during runtime for each usage. - using `filter` will raise a deprecation warning, once # Tests + Formatting No existing test broke or required tweaking. Additional tests covering this case was added. - 🟢 toolkit fmt - 🟢 toolkit clippy - 🟢 toolkit test - 🟢 toolkit test stdlib # After Submitting N/A --------- Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>


Description
This PR adds the ability for users to mark commands as deprecated with a
@deprecatedattribute. The attribute can be invoked with or without an extra explanation message.Without a message:

With a message:

I also changed the deprecated warnings a bit to make them look a bit nicer in my opinion:
Warning:text)Here's what a previous deprecation warning looked like, for reference
User-Facing Changes
@deprecatedattribute, which can be used to mark a custom command as deprecated. You can optionally supply a message to suggest a new command.Tests + Formatting
Changed the attributes completions test to not be hard-coded (so if we add any more attributes they don't need to be manually added) and added a test for
@deprecated.toolkit fmttoolkit clippytoolkit testtoolkit test stdlibAfter Submitting
N/A