Skip to content

WIP: explore auto-labelling with values #2142

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

WIP: explore auto-labelling with values #2142

wants to merge 6 commits into from

Conversation

hadley
Copy link
Member

@hadley hadley commented Jul 30, 2025

No description provided.

Comment on lines +70 to +77
label <- expr_label(expr)
if (can_inline(value)) {
paste0(label, " (", as_label(value), ")")
} else {
label
}
} else {
expr_label(expr)
Copy link
Member

Choose a reason for hiding this comment

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

I'd avoid expr_label() as it's a remnant from lazyeval. Do you get good results if you use as_label() instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried that and it introduced a bunch of small changes that were largely for the worse. I think this must have deviated from as_label at some time in the past.

}
}

can_inline <- function(x) {
Copy link
Member

Choose a reason for hiding this comment

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

rlang::is_syntactic_literal() might also be useful here? Would still need the nchar check.

@@ -1,34 +1,34 @@
# logical tests act as expected

FALSE (`actual`) is not equal to TRUE (`expected`).
FALSE is not equal to TRUE.
Copy link
Member

Choose a reason for hiding this comment

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

Should we quote the expressions?

Suggested change
FALSE is not equal to TRUE.
`FALSE` is not equal to `TRUE`.

I guess this becomes too heavy in the parenthetised/string-quoted cases

    x` (`1`) is not identical to `"a"`.

Comment on lines -42 to -44
`x1` (`actual`) doesn't fully contain all the values in `x2` (`expected`).
* Missing from `actual`: "d"
* Present in `actual`: "a", "b", "c"
Copy link
Member

Choose a reason for hiding this comment

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

That's actually a case where the parameter names are useful and add context (as opposed to e.g. object).

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.

2 participants