pseudonym117/Riot-Watcher

Can 'region' be removed?

ughstudios opened this issue · 3 comments

Can we remove the region from all of the api calls? It's really annoying having to constantly pass region in each call. Can this be instead changed to a global variable within the api? Ideally, you have something like this:

__region__

def set_region(region: str) -> None:
    global __region__
    __region__ = region

def get_region() -> str:
    return __region__

I think this would be a lot cleaner

global variables are rarely clean and introduce quite a few failure scenarios. For example:

  • using 2 regions in the same process
  • using 2 instances of a Watcher object in the same process
  • regions not being uniform (na1 vs americas vs na for most apis, matchv5, and ddragon respectively)
  • regions not being uniform between games (na1 in LoL, americas in Valorant)

On top of this, this would be extremely difficult to do while maintaining backwards compatibility.

Will not do.

It does not need to be "global" but it can be based on the instance of the object. Why not make things easier for people to use?

Because it's a breaking change for any existing users that choose to use it, messes up the type hints on all existing functions, and forces all users to use kwargs if they want to opt in for some code but not all.

And it makes documentation significantly more difficult, as the region parameter only sometimes exists.