From 54eb979d95fae0a435552f42efa93d03f23da9a3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 24 Aug 2024 13:18:34 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- jira/client.py | 25 ++++++++++++------------- tests/resources/test_board.py | 2 +- tests/resources/test_epic.py | 2 +- tests/resources/test_sprint.py | 2 +- tests/test_exceptions.py | 16 ++++++++++------ 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/jira/client.py b/jira/client.py index b090db913..bdd189668 100644 --- a/jira/client.py +++ b/jira/client.py @@ -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, @@ -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" @@ -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") @@ -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). @@ -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") @@ -4819,7 +4818,7 @@ def issuesecurityschemes(self): return data["issueSecuritySchemes"] - @lru_cache(maxsize=None) + @cache def projectcategories(self): url = self._get_url("projectCategory") @@ -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") @@ -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") @@ -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") @@ -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") @@ -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") diff --git a/tests/resources/test_board.py b/tests/resources/test_board.py index 8393d43cf..183d84fe2 100644 --- a/tests/resources/test_board.py +++ b/tests/resources/test_board.py @@ -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 diff --git a/tests/resources/test_epic.py b/tests/resources/test_epic.py index e38e42c07..8d82c2b86 100644 --- a/tests/resources/test_epic.py +++ b/tests/resources/test_epic.py @@ -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 diff --git a/tests/resources/test_sprint.py b/tests/resources/test_sprint.py index 83c0d43b1..2ccb14837 100644 --- a/tests/resources/test_sprint.py +++ b/tests/resources/test_sprint.py @@ -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 diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index 191c6614b..088ff6dc1 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -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))) @@ -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)))