fastai / ghapi

A delightful and complete interface to GitHub's amazing API
https://ghapi.fast.ai/
Apache License 2.0
527 stars 57 forks source link

Support passing gh_host as argument to GhApi #100

Closed rshk closed 2 years ago

rshk commented 2 years ago

This allows users to create multiple instances of GhApi, eg to communicate to both github.com and a private GitHub Enterprise instance.

gh = GhApi()
ghe = GhApi(gh_host="https://github.example.com")

It also allows scripts to define a custom GitHub Enterprise host to be used, without requiring the user to remember to pass it explicitly in the environment.

review-notebook-app[bot] commented 2 years ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

solvingj commented 2 years ago

@jph00 please merge this ASAP. It's unusable for most cases without this simple fix.

If this fix is unacceptable, please consider moving os.getenv("GH_HOST") out of global scope and into the body of the class so that callers can change the ENV VAR prior to instantiating GhApi and connect to different servers. As it stands, the env var gets checked when the module is imported and can't be changed later (without a bunch of dynamic unloading and reimporting business.

jph00 commented 2 years ago

Many thanks @rshk !