commit:     a4a9b5deb56783400b65ecea9fae9620a356c0cd
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Sun Dec  7 22:19:42 2025 +0000
Commit:     Brian Harring <ferringb <AT> gmail <DOT> com>
CommitDate: Sun Dec  7 22:19:42 2025 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=a4a9b5de

chore: suppress warnings while collecting deprecations.

Some of these are descriptor protocol, and poking them *will* trigger
the deprecation warning.  Thus just suppress the entire collection
block..

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>

 src/snakeoil/deprecation.py       | 10 ++++++----
 src/snakeoil/test/code_quality.py | 16 ++++++++--------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/snakeoil/deprecation.py b/src/snakeoil/deprecation.py
index 26769c0..3ea52a1 100644
--- a/src/snakeoil/deprecation.py
+++ b/src/snakeoil/deprecation.py
@@ -90,9 +90,6 @@ class Registry:
     is_enabled: typing.ClassVar[bool] = sys.version_info >= (3, 13, 0)
     _deprecated_callable: typing.Callable | None
 
-    # Certain nasty python code that is deprecated lookups up the stack to do
-    # scope manipulation; document the number of frames we add if we're 
interposed
-    # between their target scope and their execution.
     stacklevel: typing.ClassVar[int] = 1 if is_enabled else 0
 
     if is_enabled:
@@ -119,7 +116,12 @@ class Registry:
         stacklevel=1,
         **kwargs,
     ):
-        """Decorate a callable with a deprecation notice, registering it in 
the internal list of deprecations"""
+        """Decorate a callable with a deprecation notice, registering it in 
the internal list of deprecations
+
+        :param stacklevel: Unlike warnings.deprecated, we account for our own 
internal stack additions.
+           Whatever you pass for this value will be adjusted for our internal 
frames.  If you need to reach
+           one frame up, just pass 1, else 0.
+        """
 
         def f(functor):
             if not self.is_enabled:

diff --git a/src/snakeoil/test/code_quality.py 
b/src/snakeoil/test/code_quality.py
index 366b0f4..c2fd73b 100644
--- a/src/snakeoil/test/code_quality.py
+++ b/src/snakeoil/test/code_quality.py
@@ -1,6 +1,5 @@
 __all__ = ("NamespaceCollector", "Slots", "Modules")
 import inspect
-import sys
 import typing
 from types import ModuleType
 
@@ -131,10 +130,11 @@ class ExpiredDeprecations(NamespaceCollector, 
still_abstract=True):
 
     def test_has_expired_deprecations(self, subtests):
         # force full namespace load to ensure all deprecations get registry.
-        for _ in self.collect_modules():
-            pass
-        for deprecated in self.registry.expired_deprecations(
-            self.version, self.python_minimum_version
-        ):
-            with subtests.test(deprecated=str(deprecated)):
-                pytest.fail(f"deprecation has expired: {deprecated}")
+        with deprecation.suppress_deprecations():
+            for _ in self.collect_modules():
+                pass
+            for deprecated in self.registry.expired_deprecations(
+                self.version, self.python_minimum_version
+            ):
+                with subtests.test(deprecated=str(deprecated)):
+                    pytest.fail(f"deprecation has expired: {deprecated}")

Reply via email to