Ensure github module is installed before running PR commands (#1777)

* Ensure github module is installed before running PR commands

* move go and elastic-package assertions to top of command

* update error msg for missing pkg

* remove redundant github assertion

Co-authored-by: Colson Wilhoit <48036388+DefSecSentinel@users.noreply.github.com>
This commit is contained in:
Justin Ibarra
2022-02-24 14:49:01 -09:00
committed by GitHub
parent aa7d79cc53
commit d373db7659
2 changed files with 22 additions and 12 deletions
+6 -3
View File
@@ -103,14 +103,17 @@ class GithubClient:
def __init__(self, token: Optional[str] = None):
"""Get an unauthenticated client, verified authenticated client, or a default client."""
if not Github:
raise ModuleNotFoundError('Missing PyGithub - try running `pip install -r requirements-dev.txt`')
self.assert_github()
self.client: Github = Github(token)
self.unauthenticated_client = Github()
self.__token = token
self.__authenticated_client = None
@classmethod
def assert_github(cls):
if not Github:
raise ModuleNotFoundError('Missing PyGithub - try running `pip install -r requirements-dev.txt`')
@property
def authenticated_client(self) -> Github:
if not self.__token: