Skip to content

Return bare lists from S7 list conversion - #6916

Merged
teunbrand merged 4 commits into
tidyverse:mainfrom
t-kalinowski:fix/s7-list-conversion-20261016
Oct 20, 2026
Merged

teunbrand merged 4 commits into
tidyverse:mainfrom
t-kalinowski:fix/s7-list-conversion-20261016

Conversation

@t-kalinowski

Copy link
Copy Markdown
Contributor

Return bare lists from as.list() and S7::convert(..., S7::class_list) for mappings, themes, and labels. Development S7 preserves their S3 parent classes in S7_data(), which prevents the list-to-mapping conversion method from dispatching and loses the mapping entries. Apply unclass() to remove those classes.

S7's built-in conversion already handles these list-backed objects. Keep the explicit method for compatibility across S7 versions and to avoid potential recursion between as.list() and convert() if conversion reaches the as.list() fallback.

For example, this roundtrip now preserves both aesthetics with development S7:

library(ggplot2)
mapping <- aes(x = 10, y = foo)
mapping <- S7::convert(as.list(mapping), to = class_mapping)
names(mapping)
# [1] "x" "y"

The element-text validation snapshot also accepts the constructor call included by S7 1.0 and omitted by earlier versions, while retaining the full validation diagnostic.

@teunbrand
teunbrand changed the base branch from main to rc/4.0.4 October 20, 2026 13:26
@teunbrand
teunbrand changed the base branch from rc/4.0.4 to main October 20, 2026 13:26

@teunbrand teunbrand left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, thanks for this!

@teunbrand
teunbrand merged commit 022119a into tidyverse:main Oct 20, 2026
13 checks passed
teunbrand pushed a commit that referenced this pull request Oct 21, 2026
* Return bare lists from S7 list conversion

* Normalize constructor context in validation snapshot

* Use built-in S7 list conversion

* Retain explicit list conversion for compatibility
@t-kalinowski

Copy link
Copy Markdown
Contributor Author

Thanks for merging these changes! I'm planning to submit the next version of S7 to CRAN on November 16 (see RConsortium/S7#786).

Would you be able to submit an updated version of ggplot2 with these compatibility updates to CRAN before then? Please let me know if you need more time or if there’s anything I can help with.

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