Skip to content

Conversation

@tanho63
Copy link
Contributor

@tanho63 tanho63 commented Sep 19, 2025

Closes #161, resurrects #201 (got closed accidentally) as part of tidy dev day:

Adds vctrs methods provided by @DavisVaughan to help gh_response play more nicely with vctrs rectangling toolkit.

Test instructions:

pkgload::load_all()
x <- gh("/users", .limit = 2)
Sys.sleep(1)
y <- gh("/users", .limit = 2)

str(vctrs::vec_c(x, y), list.len = 3)
# List of 4
#  $ :List of 19
#   ..$ login              : chr "mojombo"
#   ..$ id                 : int 1
#   ..$ node_id            : chr "MDQ6VXNlcjE="
#   .. [list output truncated]
#  $ :List of 19
#   ..$ login              : chr "defunkt"
#   ..$ id                 : int 2
#   ..$ node_id            : chr "MDQ6VXNlcjI="
#   .. [list output truncated]
#  $ :List of 19
#   ..$ login              : chr "mojombo"
#   ..$ id                 : int 1
#   ..$ node_id            : chr "MDQ6VXNlcjE="
#   .. [list output truncated]
#   [list output truncated]

list(x, y) |> 
  tibble::tibble() |> 
  tidyr::unnest_longer(1)
# # A tibble: 4 × 1
#   `list(x, y)`     
#   <list>           
# 1 <named list [19]>
# 2 <named list [19]>
# 3 <named list [19]>
# 4 <named list [19]>

})


test_that("gh_response objects can be combined via vctrs #161", {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

# Add vctrs methods that strip attributes from gh_response when combining,
# enabling rectangling via unnesting etc
# See <https://github.com/r-lib/gh/issues/161> for more details
#' @exportS3Method vctrs::vec_ptype2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below: exportS3Method uses delayed method registration. I think we need a regular export here: @export.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks!

Copy link
Contributor Author

@tanho63 tanho63 Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lionel- I'm getting an error here with a normal @export because we don't import the generic vec_ptype2 (or maybe because we don't export it?). I think delayed might be better (and make vctrs a suggests)?

https://github.com/r-lib/gh/actions/runs/17863952750/job/50801557570?pr=226#step:6:181

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh you're right!

Copy link
Member

@lionel- lionel- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please revert the air formatting commit? PRs should be focused on one thing so they are easier to evaluate by the reviewer. An air format commit should be its own PR.

@tanho63 tanho63 force-pushed the tan/rectangling-gh-resp/161 branch from 15ca523 to 3a6d520 Compare September 19, 2025 16:16
@tanho63 tanho63 force-pushed the tan/rectangling-gh-resp/161 branch from 4595042 to 323affe Compare September 19, 2025 16:18
@tanho63 tanho63 requested a review from lionel- September 19, 2025 16:20
@lionel- lionel- merged commit 16497b8 into r-lib:main Sep 19, 2025
13 checks passed
@lionel-
Copy link
Member

lionel- commented Sep 19, 2025

Thank you!

@tanho63 tanho63 deleted the tan/rectangling-gh-resp/161 branch September 20, 2025 21:27
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

Successfully merging this pull request may close these issues.

Make gh_response play more nicely with vctrs / tidyr's rectangling toolkit

2 participants