Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for show_col_types for edition 1 parser #1332

Merged
merged 8 commits into from
Nov 30, 2021

Conversation

jimhester
Copy link
Collaborator

read_table() is one of the functions that currently doesn't have a
vroom equivalent, so is still using the first edition parser. When we
added support for show_col_types we didn't port that back to the first
edition parser, so it was missing in read_table() and the
read_delim_chunked() functions.

Fixes #1331

@jimhester
Copy link
Collaborator Author

I didn't add a test for this explicitly, but I can if you think it would be useful.

@jimhester jimhester requested a review from jennybc November 22, 2021 16:43
Copy link
Member

@jennybc jennybc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except my 1 suggestion re: a function-o.

I think it would be good to add some tests. Snapshot tests? I see readr is using testthat 3e, in terms of what DESCRIPTION says, but I haven't looked around at the actual usage.

Let me know if you want me to extend this PR with some tests.

@jimhester
Copy link
Collaborator Author

Thanks for the fixes, and sure we can add some snapshot tests, you are welcome to refactor is_testing as needed to so you can do it.

@jennybc
Copy link
Member

jennybc commented Nov 24, 2021

I will add some tests here.

@jennybc jennybc force-pushed the edition-1-show-col-types branch 3 times, most recently from 2820735 to 0bb9c72 Compare November 30, 2021 05:08
#' * `FALSE` if the option is unset and we appear to be running tests
#' * `NULL` otherwise, in which case the caller determines whether to show
#' column types based on context, e.g. whether `show_col_types` or actual
#' `col_types` were explicitly specified
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reworded this to focus more closely on what this helper does. I still include some words about downstream use, in the NULL case.

Comment on lines +41 to +42
if (isTRUE(opt)) {
TRUE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is new. But this just feels more natural and expected to me that if the option is TRUE or FALSE, that value is returned.

TRUE
} else if (identical(opt, FALSE)) {
FALSE
} else if (is.na(opt) && is_testing()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the is_testing() matter here.

@@ -1,4 +1,3 @@
pre_test_options <- options(
readr.show_col_types = FALSE,
Copy link
Member

@jennybc jennybc Nov 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to leave this unset and let should_show_types() fill in FALSE in the testing context, unless the option has been explicitly set.

jimhester and others added 8 commits November 30, 2021 12:08
`read_table()` is one of the functions that currently doesn't have a
vroom equivalent, so is still using the first edition parser. When we
added support for `show_col_types` we didn't port that back to the first
edition parser, so it was missing in `read_table()` and the
`read_delim_chunked()` functions.

Fixes #1331
This is the helper we use in vroom, but I think having it in readr would
be too confusing because we already have should_show_types
@jennybc jennybc force-pushed the edition-1-show-col-types branch from b306fb6 to 63a2da4 Compare November 30, 2021 20:09
if (
((is.null(show_col_types) && !has_col_types) || isTRUE(show_col_types)) &&
!inherits(ds, "source_string")
) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the is_testing() matter into should_show_types().

@jennybc jennybc merged commit a14f189 into main Nov 30, 2021
@jennybc jennybc deleted the edition-1-show-col-types branch December 3, 2021 01:52
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.

options(readr.show_col_types=FALSE) is not work on read_table()
2 participants