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

Feature request: bulk_postcode_lookup should accept a character vector and/or ... #18

Open
dave-lovell opened this issue Mar 5, 2024 · 2 comments

Comments

@dave-lovell
Copy link

bulk_postcode_lookup() requires postcodes to be a length-one list that contains only a character vector, as exemplified in the function's help page:

pc_list <- list(postcodes = c("PR3 0SG", "M45 6GN", "EX165BL"))
bulk_postcode_lookup(pc_list)

I'm continually caught off-guard by this counter-intuitive requirement. What is the purpose of the list?

Please implement support for accepting a character vector and/or ..., like so:

bulk_postcode_lookup(c("PR3 0SG", "M45 6GN", "EX165BL"))
bulk_postcode_lookup("PR3 0SG", "M45 6GN", "EX165BL")

Those inputs could be coerced into list form under the hood so that the functionality of old code is preserved.

@erykwalczak
Copy link
Member

Thanks for the suggestion @dave-lovell
This is a legacy issue and it can be sorted quite quickly by adjusting check_list_limit() within bulk_postcode_lookup().
Please feel from to submit a PR. If not, I might be able to fix it over the weekend.

@dave-lovell
Copy link
Author

@erzk I've requested this in #19. I've left check_list_limit() pretty much untouched (save the wording of the error messages) and instead opted to concatenate all arguments to the function before recursively unlisting them and finally wrapping them into a list:

bulk_postcode_lookup <- function(...) {
  dots <- unlist(c(...), recursive = TRUE)
  postcodes <- list(postcodes = dots)
  check_list_limit(postcodes)
#...

This should mean that legacy code still works as expected.

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

2 participants