From 4556649fd3e29672bb70912a8a547b1a35d0e468 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 29 Oct 2024 12:45:54 +0100 Subject: [PATCH 1/2] [pylint consider-using-any-or-all] Avoid constructing a list of names --- src/_pytest/mark/__init__.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/_pytest/mark/__init__.py b/src/_pytest/mark/__init__.py index f76e5212057..99ad3cfcee4 100644 --- a/src/_pytest/mark/__init__.py +++ b/src/_pytest/mark/__init__.py @@ -193,12 +193,7 @@ def __call__(self, subname: str, /, **kwargs: str | int | bool | None) -> bool: if kwargs: raise UsageError("Keyword expressions do not support call parameters.") subname = subname.lower() - names = (name.lower() for name in self._names) - - for name in names: - if subname in name: - return True - return False + return any(subname in name.lower() for name in self._names) def deselect_by_keyword(items: list[Item], config: Config) -> None: From a02d2005b7e5cbfd4b78eeda1f6f45d9dc3df645 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 29 Oct 2024 14:04:51 +0100 Subject: [PATCH 2/2] [pylint consider-using-any-or-all] noqa a a suggestion in already nested for --- pyproject.toml | 1 - src/_pytest/mark/__init__.py | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ad0bca4374b..be99392a85f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -213,7 +213,6 @@ disable = [ "condition-evals-to-constant", "consider-alternative-union-syntax", "confusing-consecutive-elif", - "consider-using-any-or-all", "consider-using-assignment-expr", "consider-using-dict-items", "consider-using-from-import", diff --git a/src/_pytest/mark/__init__.py b/src/_pytest/mark/__init__.py index 99ad3cfcee4..a6f0155751a 100644 --- a/src/_pytest/mark/__init__.py +++ b/src/_pytest/mark/__init__.py @@ -238,10 +238,9 @@ def __call__(self, name: str, /, **kwargs: str | int | bool | None) -> bool: if not (matches := self.own_mark_name_mapping.get(name, [])): return False - for mark in matches: + for mark in matches: # pylint: disable=consider-using-any-or-all if all(mark.kwargs.get(k, NOT_SET) == v for k, v in kwargs.items()): return True - return False