Skip to content

Commit

Permalink
Use exportS3Method for suggest methods and move data.table to Suggests
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Dec 4, 2024
1 parent 13c7682 commit 5a210e2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Imports:
Suggests:
bookdown,
cyclocomp,
data.table,
jsonlite,
patrick (>= 0.2.0),
rlang,
Expand All @@ -46,8 +47,6 @@ Suggests:
tibble,
tufte,
withr (>= 2.5.0)
Enhances:
data.table
VignetteBuilder:
knitr
Config/Needs/website: tidyverse/tidytemplate
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

S3method("[",lints)
S3method(as.data.frame,lints)
S3method(data.table::as.data.table,lints)
S3method(format,lint)
S3method(format,lints)
S3method(names,lints)
S3method(print,lint)
S3method(print,lints)
S3method(split,lints)
S3method(summary,lints)
S3method(tibble::as_tibble,lints)
export(Lint)
export(Linter)
export(T_and_F_symbol_linter)
Expand Down
2 changes: 2 additions & 0 deletions R/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ as.data.frame.lints <- function(x, row.names = NULL, optional = FALSE, ...) { #
)
}

#' @exportS3Method tibble::as_tibble
as_tibble.lints <- function(x, ..., # nolint: object_name_linter.
.rows = NULL,
.name_repair = c("check_unique", "unique", "universal", "minimal"),
Expand All @@ -181,6 +182,7 @@ as_tibble.lints <- function(x, ..., # nolint: object_name_linter.
tibble::as_tibble(as.data.frame(x), ..., .rows = .rows, .name_repair = .name_repair, rownames = rownames)
}

#' @exportS3Method data.table::as.data.table
as.data.table.lints <- function(x, keep.rownames = FALSE, ...) { # nolint: object_name_linter.
stopifnot(requireNamespace("data.table", quietly = TRUE))
data.table::setDT(as.data.frame(x), keep.rownames = keep.rownames, ...)
Expand Down
6 changes: 0 additions & 6 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,5 @@ settings <- new.env(parent = emptyenv())

reset_settings()

if (requireNamespace("tibble", quietly = TRUE)) {
registerS3method("as_tibble", "lints", as_tibble.lints, asNamespace("tibble"))
}
if (requireNamespace("data.table", quietly = TRUE)) {
registerS3method("as.data.table", "lints", as.data.table.lints, asNamespace("data.table"))
}
}
# nocov end

0 comments on commit 5a210e2

Please sign in to comment.