Repository navigation
Only check method/generic consistency in development contexts - #732
Merged
Merged
Conversation
check_method() now skips its consistency checks unless in_dev() detects a development context: an active pkgload::load_all(), R CMD check checking a package involved in the registration (the method's, the generic's, or a dispatch class's), or a method registered outside of a package. This means that when an upstream package changes a generic, users of already-installed downstream packages no longer see errors or warnings that they can't do anything about (#728). Additionally, while load_all() is active, incompatibility errors are demoted to warnings and the offending method is skipped rather than registered, so a package remains sourceable while its methods are out of sync with a changed generic, letting you fix them one by one (#726). Fixes #726. Fixes #728.
in_dev() now returns FALSE while testthat is running (unless load_all() is active), so method registrations inside a test suite give the same results under R CMD check (which sets _R_CHECK_PACKAGE_NAME_) as when run locally. S7's own tests mock is_testing() when simulating an R CMD check context.
t-kalinowski
approved these changes
Jul 30, 2026
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.
Fixes #726. Fixes #728.
check_method()'s consistency diagnostics are only actionable by the developer of one of the packages involved, so this PR only performs them in development contexts, detected by the newin_dev()helper. Outside these contexts — e.g. end user loading an installed downstream package whose upstream has changed a generic —check_method()skips its checks entirely, so the user doesn't see no errors or warnings they can't do anything about (#728). This moves failures from load time, to run time, thus making moreR CMD checkfixes possible.Additionally, at
load_all()time, we demote the incompatibility errors (exact-formals match for...-less generics, dispatch-argument mismatch, dispatch-argument defaults) to warnings, so you can still source the package, think fix the problem en masse (#726).Tests simulate the contexts with new descriptive helpers (
local_load_all(),local_R_CMD_check(),local_end_user()), making the existing snapshot tests deterministic regardless of how the test suite itself is run.🤖 Generated with Claude Code