Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 24, 2024
1 parent a266dea commit 54eb979
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
25 changes: 12 additions & 13 deletions jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
import urllib
import warnings
from collections import OrderedDict
from collections.abc import Iterable
from functools import lru_cache, wraps
from collections.abc import Iterable, Iterator
from functools import cache, wraps
from io import BufferedReader
from numbers import Number
from typing import (
Any,
Callable,
Generic,
Iterator,
List,
Literal,
SupportsIndex,
Expand Down Expand Up @@ -4772,7 +4771,7 @@ def _gain_sudo_session(self, options, destination):
data=payload,
)

@lru_cache(maxsize=None)
@cache
def templates(self) -> dict:
url = self.server_url + "/rest/project-templates/latest/templates"

Expand All @@ -4787,7 +4786,7 @@ def templates(self) -> dict:
# pprint(templates.keys())
return templates

@lru_cache(maxsize=None)
@cache
def permissionschemes(self):
url = self._get_url("permissionscheme")

Expand All @@ -4796,7 +4795,7 @@ def permissionschemes(self):

return data["permissionSchemes"]

@lru_cache(maxsize=None)
@cache
def issue_type_schemes(self) -> list[IssueTypeScheme]:
"""Get all issue type schemes defined (Admin required).
Expand All @@ -4810,7 +4809,7 @@ def issue_type_schemes(self) -> list[IssueTypeScheme]:

return data["schemes"]

@lru_cache(maxsize=None)
@cache
def issuesecurityschemes(self):
url = self._get_url("issuesecurityschemes")

Expand All @@ -4819,7 +4818,7 @@ def issuesecurityschemes(self):

return data["issueSecuritySchemes"]

@lru_cache(maxsize=None)
@cache
def projectcategories(self):
url = self._get_url("projectCategory")

Expand All @@ -4828,7 +4827,7 @@ def projectcategories(self):

return data

@lru_cache(maxsize=None)
@cache
def avatars(self, entity="project"):
url = self._get_url(f"avatar/{entity}/system")

Expand All @@ -4837,7 +4836,7 @@ def avatars(self, entity="project"):

return data["system"]

@lru_cache(maxsize=None)
@cache
def notificationschemes(self):
# TODO(ssbarnea): implement pagination support
url = self._get_url("notificationscheme")
Expand All @@ -4846,7 +4845,7 @@ def notificationschemes(self):
data: dict[str, Any] = json_loads(r)
return data["values"]

@lru_cache(maxsize=None)
@cache
def screens(self):
# TODO(ssbarnea): implement pagination support
url = self._get_url("screens")
Expand All @@ -4855,7 +4854,7 @@ def screens(self):
data: dict[str, Any] = json_loads(r)
return data["values"]

@lru_cache(maxsize=None)
@cache
def workflowscheme(self):
# TODO(ssbarnea): implement pagination support
url = self._get_url("workflowschemes")
Expand All @@ -4864,7 +4863,7 @@ def workflowscheme(self):
data = json_loads(r)
return data # ['values']

@lru_cache(maxsize=None)
@cache
def workflows(self):
# TODO(ssbarnea): implement pagination support
url = self._get_url("workflow")
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/test_board.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from collections.abc import Iterator
from contextlib import contextmanager
from typing import Iterator

from jira.resources import Board
from tests.conftest import JiraTestCase, rndstr
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/test_epic.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

from collections.abc import Iterator
from contextlib import contextmanager
from functools import cached_property
from typing import Iterator

from parameterized import parameterized

Expand Down
2 changes: 1 addition & 1 deletion tests/resources/test_sprint.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

from collections.abc import Iterator
from contextlib import contextmanager
from functools import lru_cache
from typing import Iterator

import pytest as pytest

Expand Down
16 changes: 10 additions & 6 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ def test_jira_error_log_to_tempfile_if_env_var_set(self):

# WHEN: a JIRAError's __str__ method is called and
# log details are expected to be sent to the tempfile
with patch.dict("os.environ", env_vars), patch(
f"{PATCH_BASE}.tempfile.mkstemp", autospec=True
) as mock_mkstemp, patch(f"{PATCH_BASE}.open", mocked_open):
with (
patch.dict("os.environ", env_vars),
patch(f"{PATCH_BASE}.tempfile.mkstemp", autospec=True) as mock_mkstemp,
patch(f"{PATCH_BASE}.open", mocked_open),
):
mock_mkstemp.return_value = 0, str(test_jira_error_filename)
str(JIRAError(response=self.MockResponse(text=DUMMY_TEXT)))

Expand All @@ -137,9 +139,11 @@ def test_jira_error_log_to_tempfile_not_used_if_env_var_not_set(self):
mocked_open = mock_open()

# WHEN: a JIRAError's __str__ method is called
with patch.dict("os.environ", env_vars), patch(
f"{PATCH_BASE}.tempfile.mkstemp", autospec=True
) as mock_mkstemp, patch(f"{PATCH_BASE}.open", mocked_open):
with (
patch.dict("os.environ", env_vars),
patch(f"{PATCH_BASE}.tempfile.mkstemp", autospec=True) as mock_mkstemp,
patch(f"{PATCH_BASE}.open", mocked_open),
):
mock_mkstemp.return_value = 0, str(test_jira_error_filename)
str(JIRAError(response=self.MockResponse(text=DUMMY_TEXT)))

Expand Down

0 comments on commit 54eb979

Please sign in to comment.