Repository navigation
Fallback for validate_subclass() - #6119
Merged
Merged
Conversation
thomasp85
reviewed
Oct 28, 2024
| name <- snakeize(name) | ||
| obj <- find_global(name, env = env, mode = "function") | ||
| if (is.function(obj)) { | ||
| obj <- obj() |
Member
There was a problem hiding this comment.
Maybe wrap in try_fetch() and rethrow the error with some additional context. We might end in situations where the constructor can't be called without arguments even though it generally should work
Merge branch 'main' into check_subclass_fallback # Conflicts: # R/layer.R
thomasp85
reviewed
Mar 25, 2025
Comment on lines
+28
to
+29
| `environment()` must be either a string or a <geom> object, not an environment. | ||
|
|
Member
There was a problem hiding this comment.
This seems like a regression in the error message?
Collaborator
Author
There was a problem hiding this comment.
I'd argue the message has become more informative. The message comes from this test:
expect_snapshot_error(validate_subclass(environment(), "geom"))And we now use caller_arg(x) for messaging, so it'd self-describes the input.
Member
There was a problem hiding this comment.
Oh - Ignore my pre-coffee eyes
thomasp85
approved these changes
Mar 25, 2025
thomasp85
left a comment
Member
There was a problem hiding this comment.
LGTM apart from the small comment
check_subclass()validate_subclass()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR aims to progress #5962 and #3798.
Taking the deprecation of GeomCol (#3798) as an example, we want users to be able to use
layer(geom = "col", ...)even after the class is deprecated. This PR ensures thatlayer(geom = "col")finds thegeom_col()constructor and returns thegeomfield from the resulting layer (even if we remove the GeomCol class).