Skip to content

Commit

Permalink
Use exportS3Method for suggests and enhances packages (#2693)
Browse files Browse the repository at this point in the history
* Use exportS3Method for suggest methods and move data.table to Suggests

* move back to enhances

---------

Co-authored-by: Michael Chirico <[email protected]>
  • Loading branch information
olivroy and MichaelChirico authored Dec 4, 2024
1 parent 0de1d6d commit c3d2935
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
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
7 changes: 0 additions & 7 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,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 c3d2935

Please sign in to comment.