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

"Overwriting method ..." noise from devtools::load_all() #474

Open
t-kalinowski opened this issue Oct 21, 2024 · 4 comments
Open

"Overwriting method ..." noise from devtools::load_all() #474

t-kalinowski opened this issue Oct 21, 2024 · 4 comments

Comments

@t-kalinowski
Copy link
Member

t-kalinowski commented Oct 21, 2024

This might be better as a pkgload specific issue, but I'm raising it here first. In a package that exports methods, load_all() gets annoyingly noisy.

> devtools::load_all(".")
ℹ Loading r2f
Overwriting method convert(<double>, <integer>)
Overwriting method convert(<logical>, <integer>)
Overwriting method convert(<name>, <character>)
Overwriting method convert(<logical>, <character>)
Overwriting method convert(<double>, <integer>)
Overwriting method convert(<logical>, <integer>)
Overwriting method convert(<name>, <character>)
Overwriting method convert(<logical>, <character>)

Note that each method is overwritten twice: once when sourcing the package code, and then again in .onLoad/S7::methods_register().

@hadley
Copy link
Member

hadley commented Oct 21, 2024

I thought I noticed that too, but it turned out that I was accidentally duplicating method definitions.

@t-kalinowski
Copy link
Member Author

t-kalinowski commented Oct 21, 2024

I don't think I'm defining the method twice. A minimal package with just this is enough to show the warning twice:

#' @import S7
NULL

method(convert, list(class_double, class_integer)) <- 
  function(from, to, ...) as.integer(from)

.onLoad <- function(...) {
  S7::methods_register()
}
> devtools::load_all(".")
ℹ Loading r2f
Overwriting method convert(<double>, <integer>)
Overwriting method convert(<double>, <integer>)

@hadley
Copy link
Member

hadley commented Oct 22, 2024

Ooh, hmmmm, maybe it only occurs in the dev version?

@lawremi
Copy link
Collaborator

lawremi commented Oct 24, 2024

I've noticed this too when redefining methods at runtime during debugging, like with ESS's developer mode. It's a bit distracting.

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

No branches or pull requests

3 participants