PokeAPI / pokebase

Python 3 wrapper for Pokéapi v2
BSD 3-Clause "New" or "Revised" License
286 stars 53 forks source link

Feature Request: Empty Resource IDs #39

Closed ImperialSquid closed 2 years ago

ImperialSquid commented 2 years ago

Problem

PokeAPI gives a resource list if you access an endpoint but don't give a resource ID (https://pokeapi.co/docs/v2#resource-listspagination-section) however this library doesn't allow for that since resource IDs are validated as being either strings or ints

Why It's Useful

There are a fair few endpoints where the valid ids are not continuous so scanning through one by one until you get a 404 will end up missing some resources and doing an exhaustive search is unfeasible since there's no way to know what the last one might be (hard coding is also not an option since it'll inevitably need updating each game)

Suggested Fix

It's not my library so obviously your call but a simple fix by just be to allow Nones as resource IDs to specify that you want the list instead? This should work for every endpoint already anyway

ImperialSquid commented 2 years ago

Scratch that, just spotted that this is already a thing by calling APIResourceList instead!

ImperialSquid commented 2 years ago

Though maybe adding in that using None as the ID does the same thing would be a nice pythonic addition "simple is better than complex" and all that, having to use an entirely separate method to get the resource list seems a little obtuse