pseudonym117 / Riot-Watcher

Simple Python wrapper for the Riot Games API for League of Legends
MIT License
532 stars 150 forks source link

Can 'region' be removed? #211

Closed ughstudios closed 2 years ago

ughstudios commented 2 years ago

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

pseudonym117 commented 2 years ago

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

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

Will not do.

ughstudios commented 2 years ago

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?

pseudonym117 commented 2 years ago

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.