Skip to content

Commit

Permalink
Use option readr.show_col_types to match the argument name
Browse files Browse the repository at this point in the history
Fixes #1250
  • Loading branch information
jimhester committed Jul 28, 2021
1 parent 3c46de1 commit 5ca3257
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# readr (development version)

* `options(readr.show_col_types = FALSE)` now works as intended (#1250)

* Avoid spurious byte compilation errors due to the programatically generated `spec_*()` functions.

* `read_delim_chunked()` now again correctly respects the `chunk_size` parameter (#1248)
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ show_progress <- function() {
#' Determine whether column types should be shown
#'
#' Column types are shown unless
#' - They are disabled by setting `options(readr.show_types = FALSE)`
#' - They are disabled by setting `options(readr.show_col_types = FALSE)`
#' - The column types are supplied with the `col_types` argument.
#' @export
should_show_types <- function() {
if (identical(getOption("readr.show_types", TRUE), FALSE)) {
if (identical(getOption("readr.show_col_types", TRUE), FALSE)) {
FALSE
} else {
NULL
Expand Down
2 changes: 1 addition & 1 deletion man/should_show_types.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/setup.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pre_test_options <- options(
readr.show_types = FALSE,
readr.show_col_types = FALSE,
readr.show_progress = FALSE
)
14 changes: 14 additions & 0 deletions tests/testthat/test-col-spec.R
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,17 @@ test_that("as.character() works on col_spec objects", {
spec <- as.col_spec(iris)
expect_equal(as.character(spec), "ddddf")
})

test_that("options(readr.show_col_spec) can turn off showing column specifications", {
options(readr.show_col_types = NULL)
expect_message(
expect_message(
expect_message(
read_csv(readr_example("mtcars.csv"))
)
)
)

options(readr.show_col_types = FALSE)
expect_silent(read_csv(readr_example("mtcars.csv")))
})

0 comments on commit 5ca3257

Please sign in to comment.