From 30a5d7e5044fb17612008ea3c00f1e48a944c9bf Mon Sep 17 00:00:00 2001 From: Robin <167366979+allrob23@users.noreply.github.com> Date: Tue, 4 Mar 2025 13:11:28 +0000 Subject: [PATCH 1/2] feat(performance): improve warning suppression lookup by using set --- coverage/control.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coverage/control.py b/coverage/control.py index bce5f0a17..032c36485 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -258,7 +258,7 @@ def __init__( # pylint: disable=too-many-arguments self._warn_no_data = True self._warn_unimported_source = True self._warn_preimported_source = check_preimported - self._no_warn_slugs: list[str] = [] + self._no_warn_slugs: set[str] = [] self._messages = messages # A record of all the warnings that have been issued. @@ -438,7 +438,7 @@ def _warn(self, msg: str, slug: str | None = None, once: bool = False) -> None: """ if not self._no_warn_slugs: - self._no_warn_slugs = list(self.config.disable_warnings) + self._no_warn_slugs = set(self.config.disable_warnings) if slug in self._no_warn_slugs: # Don't issue the warning @@ -453,7 +453,7 @@ def _warn(self, msg: str, slug: str | None = None, once: bool = False) -> None: if once: assert slug is not None - self._no_warn_slugs.append(slug) + self._no_warn_slugs.add(slug) def _message(self, msg: str) -> None: """Write a message to the user, if configured to do so.""" From e58baa149502a86ad0613abfe26cb6ba5b168078 Mon Sep 17 00:00:00 2001 From: Robin <167366979+allrob23@users.noreply.github.com> Date: Tue, 4 Mar 2025 12:21:56 -0300 Subject: [PATCH 2/2] fix: initialize _no_warn_slugs as a empty set --- coverage/control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coverage/control.py b/coverage/control.py index 032c36485..e051de828 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -258,7 +258,7 @@ def __init__( # pylint: disable=too-many-arguments self._warn_no_data = True self._warn_unimported_source = True self._warn_preimported_source = check_preimported - self._no_warn_slugs: set[str] = [] + self._no_warn_slugs: set[str] = set() self._messages = messages # A record of all the warnings that have been issued.