Skip to content

Commit

Permalink
Merge branch 'main' into patch-8
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy authored Aug 18, 2024
2 parents 8906c8b + 69659c4 commit 2d54171
Show file tree
Hide file tree
Showing 23 changed files with 48 additions and 80 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
^\.cache$
^\.vscode$
^compile_commands\.json$
.*\.clangd$
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* `env_unlock()` is now defunct because recent versions of R no long
make it possible to unlock an environment (#1705). Make sure to use an
up-to-date version of pkgload (>= 1.4.0) following this change.

* `is_dictionaryish()` now will return TRUE for NULL (@ilovemane, #1712).


# rlang 1.1.4
Expand Down
7 changes: 6 additions & 1 deletion R/attr.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#' a logical vector as long as the input.
#'
#' @details
#' `is_named()` always returns `TRUE` for empty vectors because
#' `is_named()` always returns `TRUE` for empty vectors because
#'
#' @examples
#' # is_named() is a scalar predicate about the whole vector of names:
Expand Down Expand Up @@ -110,6 +110,10 @@ detect_void_name <- function(x) {
is_dictionaryish <- function(x) {
# 2022-01: Used in many packages. Don't deprecate without a
# replacement.
if (is.null(x)) {
return(TRUE)
}

if (!length(x)) {
return(!is.null(x))
}
Expand All @@ -118,6 +122,7 @@ is_dictionaryish <- function(x) {
}



#' Does an object have an element with this name?
#'
#' This function returns a logical value that indicates if a data
Expand Down
3 changes: 0 additions & 3 deletions R/rlang-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,3 @@ compiled_by_gcc <- function() {
#' @rawNamespace export(ffi_standalone_is_bool_1.0.7)
#' @rawNamespace export(ffi_standalone_check_number_1.0.7)
NULL

# Enable pkgload to hotpatch `::` in detached namespaces
on_load(`::` <- base::`::`)
21 changes: 18 additions & 3 deletions R/standalone-types-check.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# ---
# repo: r-lib/rlang
# file: standalone-types-check.R
# last-updated: 2024-07-14
# last-updated: 2024-08-18
# license: https://unlicense.org
# dependencies: standalone-obj-type.R
# imports: rlang (>= 1.1.0)
# ---
#
# ## Changelog
# 2024-07-14:
# 2024-08-18:
# - `check_character()` gains `min_length` to allow prohibiting `character(0)` (@olivroy)
#
# 2024-08-15:
# - `check_character()` gains an `allow_na` argument (@martaalcalde, #1724)
#
# 2023-03-13:
# - Improved error messages of number checkers (@teunbrand)
# - Added `allow_infinite` argument to `check_number_whole()` (@mgirlich).
Expand Down Expand Up @@ -459,16 +462,29 @@ check_formula <- function(x,

# Vectors -----------------------------------------------------------------

# TODO: Figure out what to do with logical `NA` and `allow_na = TRUE`

check_character <- function(x,
...,
allow_na = TRUE,
allow_null = FALSE,
min_length = 0,
arg = caller_arg(x),
call = caller_env()) {

if (!missing(x)) {
if (is_character(x) && (length(x) >= min_length)) {
if (!allow_na && any(is.na(x))) {
abort(
sprintf("`%s` can't contain NA values.", arg),
arg = arg,
call = call
)
}

return(invisible(NULL))
}

if (allow_null && is_null(x)) {
return(invisible(NULL))
}
Expand All @@ -483,7 +499,6 @@ check_character <- function(x,
x,
what,
...,
allow_na = FALSE,
allow_null = allow_null,
arg = arg,
call = call
Expand Down
8 changes: 2 additions & 6 deletions man/cnd_inherits.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/friendly_type.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions man/glue-operators.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions man/missing_arg.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions man/qq_show.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions man/splice-operator.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions man/topic-data-mask-ambiguity.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions man/topic-data-mask-programming.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions man/topic-data-mask.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions man/topic-defuse.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/topic-error-call.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2d54171

Please sign in to comment.