Skip to content

feat: Import rlang types-check standalone and implement improvements - #433

Merged
krlmlr merged 10 commits into
mainfrom
claude/issue-432-20250619_181709
Nov 28, 2026
Merged

krlmlr merged 10 commits into
mainfrom
claude/issue-432-20250619_181709

Conversation

@krlmlr

@krlmlr krlmlr commented Jun 19, 2025 •

Copy link
Copy Markdown
Member

Imports rlang's types-check and obj-type standalones 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.R and R/import-standalone-obj-type.R, vendored from rlang's current main. Both are excluded from lintr in .lintr.R, because the development version of lintr crashes on one of them.
  • DESCRIPTION: rlang (>= 1.2.0), since check_bool(), check_string() and stop_input_type() now come from rlang itself, and cli, which the vendored check_formula() uses (question).
  • make_context() checks set_as_default (bool), name (string or NULL) and default_skip (character or NULL).
  • run_tests() checks skip and run_only (character or NULL) and test_suite (string).
  • get_placeholder_funs() checks requires_names (bool or NULL).
  • 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_skip are character vectors built with c(if ...) or NULL. Only invalid values such as set_as_default = 1 now 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 on main is #593.

Closes #432.

https://claude.ai/code/session_01Hr1rd7ccM8Y4Gr9rgiWjgH


Generated by Claude Code

… 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]>
@krlmlr

krlmlr commented Jun 19, 2025

Copy link
Copy Markdown
Member Author

CC @moodymudskipper.

claude and others added 7 commits November 28, 2026 07:27
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
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

krlmlr commented Nov 28, 2026 •

Copy link
Copy Markdown
Member Author

Resolved: Raise the rlang floor to 1.2.0 and import cli

The refreshed standalones come from rlang's current main. They no longer define check_bool(), check_string(), check_data_frame() or stop_input_type(), because rlang exports these since 1.2.0, so DBItest now takes them from rlang's namespace. That raises the floor in DESCRIPTION line 30 from rlang (>= 0.2.0) to rlang (>= 1.2.0), which has been on CRAN since 2026-04-06. The vendored check_formula() calls cli::cli_abort(), so cli joins Imports (line 21). testthat already depends on cli, so no backend gets a new install.

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.

  • Keep rlang >= 1.2.0 and cli in Imports (recommended)
  • Vendor an older standalone and keep rlang >= 0.2.0
  • Relayed from the maintainer's comment: "Update standalone file, raise the floor."

Generated by Claude Code

krlmlr commented Nov 28, 2026 •

Copy link
Copy Markdown
Member Author

Superseded: Accepted limitations

See 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 main's version, and comments that only restated the new checks are gone.


Generated by Claude Code

@krlmlr

krlmlr commented Nov 28, 2026

Copy link
Copy Markdown
Member Author

Update standalone file, raise the floor.

krlmlr commented Nov 28, 2026

Copy link
Copy Markdown
Member Author

Both changes are already on the branch, in df62107, at head 6a37f45:

  • R/import-standalone-types-check.R and R/import-standalone-obj-type.R are identical to rlang's current main, apart from the usethis import header. I re-checked them just now.
  • DESCRIPTION has rlang (>= 1.2.0), the lowest version that exports check_bool(), check_string() and stop_input_type(), which the code now takes from rlang. CRAN currently has rlang 1.3.0.

Generated by Claude Code

krlmlr commented Nov 28, 2026

Copy link
Copy Markdown
Member Author

Accepted limitations

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 main's version, and comments that only restated the new checks are gone.


Generated by Claude Code

@krlmlr
krlmlr merged commit 3d6d33e into main Nov 28, 2026
17 checks passed
@krlmlr
krlmlr deleted the claude/issue-432-20250619_181709 branch November 28, 2026 08:36
@krlmlr krlmlr mentioned this pull request Nov 28, 2026
16 of 20 tasks
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.

Use type check standalone

2 participants