Skip to content
3 changes: 1 addition & 2 deletions .lintr
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
linters: linters_with_defaults(
line_length_linter = line_length_linter(120),
object_usage_linter = NULL,
cyclocomp_linter = NULL
object_usage_linter = NULL
)
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ URL: https://insightsengineering.github.io/teal.data/,
BugReports: https://github.com/insightsengineering/teal.data/issues
Depends:
R (>= 4.0),
teal.code (>= 0.6.0)
teal.code (>= 0.6.1.9002),
Imports:
checkmate (>= 2.1.0),
lifecycle (>= 0.2.0),
Expand All @@ -45,6 +45,8 @@ Suggests:
VignetteBuilder:
knitr,
rmarkdown
Remotes:
insightsengineering/teal.code@teal_reportable
RdMacros:
lifecycle
Config/Needs/verdepcheck: insightsengineering/teal.code, mllg/checkmate,
Expand Down
3 changes: 1 addition & 2 deletions R/join_keys-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ assert_compatible_keys <- function(join_key_1, join_key_2) {
}
}

# otherwise they are compatible
return(TRUE)
TRUE # otherwise they are compatible
}

#' Validate parent-child key
Expand Down
25 changes: 9 additions & 16 deletions R/teal_data-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ setOldClass("join_keys")
#' Access or modify with [join_keys()].
#' @slot verified (`logical(1)`) flag signifying that code in `@code` has been
#' proven to yield contents of `@.xData`.
#' Used internally. See [`verify()`] for more details.
#' Used internally. See [`teal.data::verify()`] for more details.
#'
#' @inheritSection teal.code::`qenv-class` Code
#'
Expand All @@ -35,11 +35,7 @@ setOldClass("join_keys")
setClass(
Class = "teal_data",
contains = "qenv",
slots = c(join_keys = "join_keys", verified = "logical"),
prototype = list(
join_keys = join_keys(),
verified = logical(0)
)
slots = c(join_keys = "join_keys", verified = "logical")
)

#' It initializes the `teal_data` class
Expand All @@ -50,13 +46,12 @@ setClass(
setMethod(
"initialize",
"teal_data",
function(.Object, .xData = list(), join_keys = join_keys(), code = list(), ...) { # nolint: object_name.
# Allow .xData to be a list and convert it to an environment
if (!missing(.xData) && inherits(.xData, "list")) {
.xData <- rlang::env_clone(list2env(.xData), parent = parent.env(.GlobalEnv)) # nolint: object_name.
lockEnvironment(.xData, bindings = TRUE)
}
function(.Object, .xData, join_keys, code, ...) { # nolint: object_name.
if (missing(.xData)) .xData <- new.env() # nolint: object_name.
if (missing(join_keys)) join_keys <- teal.data::join_keys()
if (missing(code)) code <- character(0L)
args <- list(...)

checkmate::assert_environment(.xData)
checkmate::assert_class(join_keys, "join_keys")
checkmate::assert_list(args, names = "named")
Expand All @@ -67,15 +62,12 @@ setMethod(
if (is.language(code)) {
code <- paste(lang2calls(code), collapse = "\n")
}
if (length(code)) {
code <- paste(code, collapse = "\n")
}

methods::callNextMethod(
.Object,
.xData,
join_keys = join_keys,
verified = (length(args$code) == 0L && length(.xData) == 0L),
verified = (length(code) == 0L && length(.xData) == 0L),
code = code2list(code),
...
)
Expand All @@ -97,6 +89,7 @@ code2list <- function(code) {
if (length(code) == 0) {
return(list())
}
code <- paste(code, collapse = "\n")

parsed_code <- parse(text = code, keep.source = TRUE)

Expand Down
3 changes: 1 addition & 2 deletions R/teal_data-constructor.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@ teal_data <- function(...,
if (inherits(join_keys, "join_key_set")) {
join_keys <- teal.data::join_keys(join_keys)
}

if (length(data_objects) > 0 && !checkmate::test_names(names(data_objects), type = "named")) {
stop("Dot (`...`) arguments on `teal_data()` must be named.")
}
methods::new(
"teal_data",
.xData = data_objects,
.xData = list2env(data_objects),
code = code,
join_keys = join_keys
)
Expand Down
4 changes: 2 additions & 2 deletions R/teal_data-show.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#' @export
setMethod("show", signature = "teal_data", function(object) {
if (object@verified) {
cat("\u2705\ufe0e", "verified teal_data object\n")
cat("\u2705\ufe0e", "code verified\n")
} else {
cat("\u2716", "unverified teal_data object\n")
cat("\u2716", "code unverified\n")
}
methods::callNextMethod(object)
invisible(object)
Expand Down
2 changes: 1 addition & 1 deletion R/topological_sort.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ topological_sort <- function(graph) {
paste0(setdiff(names(in_degrees), sorted), collapse = " ")
)
} else {
return(sorted)
sorted
}
}

Expand Down
Loading