Repository navigation
expect_s3_class_linter and expect_s4_class_linter - #943
Conversation
|
BTW, one thing to consider -- with this linter active, it becomes somewhat cumbersome to test for the exact sequence of S3 classes, e.g. before you might write this linter wants The thinking is that it's usually preferable to check inheritance as opposed to an exact sequence of classes. One thing we could do is offer an option (I'm indifferent to the default) At Google, we've really aligned on |
|
What is wrong with library(testthat)
expect_s3_class(data.table::data.table(), c("data.frame", "data.table"))
expect_s3_class(data.table::data.table(), c("data.table", "data.frame"))Created on 2022-03-15 by the reprex package (v2.0.1) |
|
Oh actually I forgot how inherits works, it actually just returns true if any of the input classes are found, not all of them, so separate calls to |
|
Right, e.g. |
|
Another BTW, I have been running the new linters on |
|
I think minor de-lints are fine if they don't make the PR too large. |
|
|
||
| # (1) expect_{equal,identical}(class(x), C) | ||
| # (2) expect_true(is.<class>(x)) and expect_true(inherits(x, C)) | ||
| is_class_call <- xp_text_in_table(c(is_s3_class_calls, "inherits")) |
There was a problem hiding this comment.
false positive lint caused by glue: local variable ‘is_class_call’ assigned but may not be used.
Part of #884
Close cousin of
expect_type_linter()