Repository navigation
feat: Import rlang types-check standalone and implement improvements - #433
Conversation
… improvements Import comprehensive type checking functions from rlang standalone and apply them throughout the DBItest codebase to improve argument validation and error handling. ## Changes ### New Files - Add `R/import-standalone-types-check.R` with 20+ type checking functions - Add `R/import-standalone-obj-type.R` with supporting object type utilities ### Enhanced Type Validation - `context.R`: Add validation for `set_as_default` (bool), `name` (string, nullable), `default_skip` (character vector, nullable) - `run.R`: Add validation for `skip` (character, nullable), `run_only` (character, nullable), `test_suite` (string) - `spec-meta-bind-.R`: Add validation for `requires_names` (bool, nullable), `placeholder_fun` (character/function) - `utils.R`: Enhanced `check_df()` to use `check_data_frame()` for better error messages ## Benefits - More informative error messages with automatic argument context - Consistent validation patterns and error handling - Built-in flexibility with `allow_null`, `allow_na` options - Enhanced user experience with clearer type guidance 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Kirill Müller <[email protected]>
|
CC @moodymudskipper. |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7ccM8Y4Gr9rgiWjgH
Update `R/import-standalone-types-check.R` and `R/import-standalone-obj-type.R` to the current rlang main branch, in the format `usethis::use_standalone()` writes. The current standalones no longer define `check_bool()`, `check_string()`, `check_data_frame()`, and `stop_input_type()`, which rlang exports since 1.2.0, so the rlang floor rises to 1.2.0. `check_formula()` in the standalone calls `cli::cli_abort()`, so cli joins the imports; testthat already depends on it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7ccM8Y4Gr9rgiWjgH
`check_data_frame()` aborts, which turns a backend's non-data-frame result into a test error and stops the remaining expectations of that test. `check_df()` now records a failed expectation, as on main, with a message that names the type it got. The `check_character()` and `check_function()` calls in `get_placeholder_funs()` sat inside branches that had already tested the type, so they are dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7ccM8Y4Gr9rgiWjgH
The development version of lintr crashes in `duplicate_argument_linter()` on `R/import-standalone-obj-type.R`, and the vendored files are edited upstream in rlang, not here. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7ccM8Y4Gr9rgiWjgH
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7ccM8Y4Gr9rgiWjgH
The regenerated bind specs only reformatted a blob literal, and the removed comments described the new checks without adding to them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7ccM8Y4Gr9rgiWjgH
Resolved: Raise the rlang floor to 1.2.0 and import cliThe refreshed standalones come from rlang's current The alternative is to vendor an older standalone that still defines these functions, which keeps the old floor but freezes the vendored code. If nobody decides, the PR keeps rlang >= 1.2.0 and cli.
Generated by Claude Code |
Superseded: Accepted limitationsSee the current copy. From the clean review of 16dbe73, which found nothing above Low. Two Low findings were fixed in 6a37f45: the regenerated bind specs are back to
Generated by Claude Code |
|
Update standalone file, raise the floor. |
|
Both changes are already on the branch, in df62107, at head 6a37f45:
Generated by Claude Code |
Accepted limitationsFrom the clean review of 16dbe73, which found nothing above Low. Two Low findings were fixed in 6a37f45: the regenerated bind specs are back to
Generated by Claude Code |
Imports rlang's
types-checkandobj-typestandalones and uses them to validate the arguments of the user-facing entry points, without making DBItest stricter for any existing backend.Changes
R/import-standalone-types-check.RandR/import-standalone-obj-type.R, vendored from rlang's currentmain. Both are excluded from lintr in.lintr.R, because the development version of lintr crashes on one of them.rlang (>= 1.2.0), sincecheck_bool(),check_string()andstop_input_type()now come from rlang itself, andcli, which the vendoredcheck_formula()uses (question).make_context()checksset_as_default(bool),name(string orNULL) anddefault_skip(character orNULL).run_tests()checksskipandrun_only(character orNULL) andtest_suite(string).get_placeholder_funs()checksrequires_names(bool orNULL).check_df()still records a failed expectation rather than aborting, so one bad result does not stop the rest of a spec. It now says "Expected a data frame, not ."Backend safety
Each check was compared with the actual calls in the test suites of RSQLite, RMariaDB, RPostgres, odbc, duckdb, adbi and RKazam. All of them pass: names are single strings, and
skip/default_skipare character vectors built withc(if ...)orNULL. Only invalid values such asset_as_default = 1now abort.devtools::test()gives FAIL 0 | SKIP 64 | PASS 9639, and lint is clean.A clean review found nothing above Low; see Accepted limitations. A failure of
test_stress()that already exists onmainis #593.Closes #432.
https://claude.ai/code/session_01Hr1rd7ccM8Y4Gr9rgiWjgH
Generated by Claude Code