Skip to content

Commit

Permalink
Fix cache method usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed Nov 2, 2023
1 parent 4f6a03e commit 52cb619
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions gitblame.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self, repo: str, branch: str, access_token: str) -> None:
self.timeout = 30
if os.getenv("DEBUG"):
self.session.hooks["response"].append(debugme)
self.blame_file = cache(self._blame_file)

def __enter__(self):
return self
Expand All @@ -65,14 +66,11 @@ def __exit__(self, exc_type, exc_value, traceback):
self.session.close()
except RequestException:
pass
self.blame_file.cache_clear()
if exc_type is not None:
logging.error("GitBlame: %s: %s: %s", exc_type, exc_value, traceback)

@cache # pylint: disable=method-cache-max-size-none
def blame_file(self, file: str) -> dict | None:
"""
Blame file
"""
def _blame_file(self, file: str) -> dict | None:
variables = {
"owner": self.owner,
"repositoryName": self.repo,
Expand Down

0 comments on commit 52cb619

Please sign in to comment.