-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow packages to force depwarns #37296
Conversation
Is there an advantage of using |
julia> include("deprecated.jl")
[ Info: Deprecation warnings are expected
┌ Warning: `convert(Array{BGR}, img)` will soon switch to returning an array with non-concrete element type, which adds flexibility but
│ with great cost to performance. To maintain the current behavior, use `BGR.(img)` instead.
└ @ ImageCore ~/.julia/dev/ImageCore/src/deprecations.jl:6
┌ Info: It is recommended that you fix this now to avoid breakage when a new version is released and this warning is removed.
└ Tip: to see all deprecation warnings together with code locations, launch Julia with `--depwarn=yes` and rerun your code.
Whereas julia> include("deprecated.jl")
[ Info: Deprecation warnings are expected
┌ Warning: `convert(Array{BGR}, img)` will soon switch to returning an array with non-concrete element type, which adds flexibility but
│ with great cost to performance. To maintain the current behavior, use `BGR.(img)` instead.
│ caller = macro expansion at deprecated.jl:8 [inlined]
└ @ Core ~/.julia/dev/ImageCore/test/deprecated.jl:8
┌ Warning: `convert(Array{Lab}, img)` will soon switch to returning an array with non-concrete element type, which adds flexibility but
│ with great cost to performance. To maintain the current behavior, use `Lab.(img)` instead.
│ caller = macro expansion at deprecated.jl:12 [inlined]
└ @ Core ~/.julia/dev/ImageCore/test/deprecated.jl:12
... Ignore the 2-vs-1 distinction and focus on the fact that now the file & line number indicates the caller (i.e., here and here). |
Another advantage is to not show thousands of warnings for the same function call 😆 . For example, in a for loop. |
For that you can use
but yea, the wrong source of the warning is indeed annoying. |
(cherry picked from commit 405cd6f)
(cherry picked from commit 405cd6f)
(cherry picked from commit 405cd6f)
Fixes #37164 in a gentler way than proposed in the OP, by allowing packages to call
depwarn(args...; force=true)
. No macro equivalent is provided in this PR.