Skip to content

Ignore empty arguments in theme() - #5604

Merged
teunbrand merged 1 commit into
tidyverse:rc/3.5.0from
teunbrand:theme_trailing_comma
Dec 22, 2023
Merged

teunbrand merged 1 commit into
tidyverse:rc/3.5.0from
teunbrand:theme_trailing_comma

Conversation

@teunbrand

Copy link
Copy Markdown
Collaborator

This PR to the RC aims to fix a bug uncovered in revdepchecks affecting ~32 packages.

One such example is this:
https://github.com/tidyverse/ggplot2/blob/rc/3.5.0/revdep/problems.md#newly-broken-126

Briefly, due to allowing splicing in theme(), we're no longer ignoring trailing arguments.
The fix is to explicitly ignore empty arguments using dots_list() instead of list2().

A reprex to reproduce the issue:

library(ggplot2) # RC branch

theme(axis.title = element_text(), )
#> Error in `list2()` at ggplot2/R/utilities.R:323:3:
#> ! Argument 1 can't be empty.

Fixed behaviour:

devtools::load_all("~/packages/ggplot2/") # This PR
#> ℹ Loading ggplot2

theme(axis.title = element_text(), )
#> List of 1
#>  $ axis.title:List of 11
#>   ..$ family       : NULL
#>   ..$ face         : NULL
#>   ..$ colour       : NULL
#>   ..$ size         : NULL
#>   ..$ hjust        : NULL
#>   ..$ vjust        : NULL
#>   ..$ angle        : NULL
#>   ..$ lineheight   : NULL
#>   ..$ margin       : NULL
#>   ..$ debug        : NULL
#>   ..$ inherit.blank: logi FALSE
#>   ..- attr(*, "class")= chr [1:2] "element_text" "element"
#>  - attr(*, "class")= chr [1:2] "theme" "gg"
#>  - attr(*, "complete")= logi FALSE
#>  - attr(*, "validate")= logi TRUE

Created on 2023-12-21 with reprex v2.0.2

@teunbrand teunbrand added this to the ggplot2 3.5.0 milestone Dec 21, 2023
@teunbrand
teunbrand requested a review from thomasp85 December 21, 2023 09:45

@thomasp85 thomasp85 left a comment

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.

LGTM - surprised this causes any revdep failures though

@teunbrand

Copy link
Copy Markdown
Collaborator Author

You see the darndest things in revdep failures 🙃

@teunbrand
teunbrand merged commit f15a332 into tidyverse:rc/3.5.0 Dec 22, 2023
@teunbrand
teunbrand deleted the theme_trailing_comma branch December 22, 2023 09:03
thomasp85 pushed a commit that referenced this pull request Feb 23, 2024
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