Skip to content

Option to always warn#128

Merged
hadley merged 4 commits into
mainfrom
always-warn
Aug 16, 2022
Merged

Option to always warn#128
hadley merged 4 commits into
mainfrom
always-warn

Conversation

@hadley
Copy link
Copy Markdown
Member

@hadley hadley commented Aug 14, 2022

Fixes #124

@hadley hadley requested a review from lionel- August 14, 2022 13:56
Comment thread R/deprecated.R
with = NULL,
details = NULL,
id = NULL,
always = FALSE,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make this frequency = c("always", "regularly", "once") as in rlang::warn()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so — that feels too much like tying this interface to its implementation. (Not that lifecycle currently uses frequency but we could now refactor to do so).

I think the goal here is to create a hierarchy of annoyingness that we can gradually move functions along over time. I could imagine something more like annoy = c("a little", "a lot") but we'd need to think about that more, and adding one extra step seems like enough for now.

@DavisVaughan any thoughts?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with it being a boolean because I do think we just need exactly 1 more step in the process:

soft (in tests) -> warn (8 hours) -> warn (always) -> error

Comment thread R/deprecated.R
if (always || needs_warning(id)) {
# Prevent warning from being displayed again
env_poke(deprecation_env, id, Sys.time())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning message that gets thrown when always = TRUE isn't exactly right, right? i.e. we don't want the footer that says it is displayed once every 8 hours

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a new snapshot test that captures the tweaked message to ensure no footer is added when always = TRUE

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably best to refactor and use rlang here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do a little refactoring of the message generation, but I think refactoring to use new rlang features is out of scope. I had a go at it yesterday but the lifecycle warnings are bit too custom for me to easily see how to update.

Comment thread R/deprecated.R
with = NULL,
details = NULL,
id = NULL,
always = FALSE,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with it being a boolean because I do think we just need exactly 1 more step in the process:

soft (in tests) -> warn (8 hours) -> warn (always) -> error

@hadley hadley merged commit 45a6801 into main Aug 16, 2022
@hadley hadley deleted the always-warn branch August 16, 2022 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variant of deprecate_warn() that always warns

3 participants