From f76bc6a407edbe105ba2b04da348b2ec6550a022 Mon Sep 17 00:00:00 2001 From: Sadra Yahyapour Date: Mon, 15 Apr 2024 09:40:51 +0330 Subject: [PATCH] authenticate() method refactored --- docs/tutorial.md | 2 -- pyaction/auth.py | 20 +------------------- pyaction/exceptions.py | 4 ---- 3 files changed, 1 insertion(+), 25 deletions(-) diff --git a/docs/tutorial.md b/docs/tutorial.md index 12a83da..c663a49 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -175,7 +175,6 @@ steps: Now, to serialize the issue data coming from the workflow, we have to use `Auth` and `IssueForm` classes. ```py title="your-action/main.py" - from pyaction.auth import Auth from pyaction.issues import IssueForm @@ -185,7 +184,6 @@ from pyaction import io def main(): auth = Auth(token=io.read("github_token")) - auth.authenticate() repo = auth.github.get_repo(io.read("repository")) user_input = IssueForm(repo=repo, number=int(io.read("issue_number"))).render() diff --git a/pyaction/auth.py b/pyaction/auth.py index 369bb9b..358c40b 100644 --- a/pyaction/auth.py +++ b/pyaction/auth.py @@ -1,8 +1,5 @@ import github.Auth from github import Github -from github.GithubException import BadCredentialsException - -from pyaction.exceptions import BrokenToken class Auth: @@ -12,21 +9,6 @@ def __init__(self, token: str) -> None: Args: token (str): the `GITHUB_TOKEN` value """ - self.auth: github.Auth = github.Auth.Token(token) + self.auth: github.Auth = github.Auth.Token(token) self.github: Github = Github(auth=self.auth) - self.is_authenticated: bool = False - - def authenticate(self) -> None: - """authenticator - - Raises: - BrokenToken: if the `token` is broken or not valid - """ - try: - # _ = self.github.get_user().login - self.is_authenticated = True - except BadCredentialsException: - raise BrokenToken( - "`GITHUB_TOKEN` value is either not defiend in `action.yml` or not valid." - ) diff --git a/pyaction/exceptions.py b/pyaction/exceptions.py index a6eee69..bd42259 100644 --- a/pyaction/exceptions.py +++ b/pyaction/exceptions.py @@ -1,6 +1,2 @@ class WorkflowParameterNotFound(Exception): pass - - -class BrokenToken(Exception): - pass