From 47af34d73b1299a9e94d6dadd46f6033ba49732e Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 29 Sep 2025 13:41:28 -0500 Subject: [PATCH 1/3] Remove deprecated `LoggingContext` methods These were added for backwards compatibility in https://github.com/matrix-org/synapse/pull/7408 --- synapse/logging/context.py | 41 -------------------------------------- 1 file changed, 41 deletions(-) diff --git a/synapse/logging/context.py b/synapse/logging/context.py index 119d3be7bf4..1489a654a90 100644 --- a/synapse/logging/context.py +++ b/synapse/logging/context.py @@ -347,47 +347,6 @@ def __init__( def __str__(self) -> str: return self.name - @classmethod - def current_context(cls) -> LoggingContextOrSentinel: - """Get the current logging context from thread local storage - - This exists for backwards compatibility. ``current_context()`` should be - called directly. - - Returns: - The current logging context - """ - warnings.warn( - "synapse.logging.context.LoggingContext.current_context() is deprecated " - "in favor of synapse.logging.context.current_context().", - DeprecationWarning, - stacklevel=2, - ) - return current_context() - - @classmethod - def set_current_context( - cls, context: LoggingContextOrSentinel - ) -> LoggingContextOrSentinel: - """Set the current logging context in thread local storage - - This exists for backwards compatibility. ``set_current_context()`` should be - called directly. - - Args: - context: The context to activate. - - Returns: - The context that was previously active - """ - warnings.warn( - "synapse.logging.context.LoggingContext.set_current_context() is deprecated " - "in favor of synapse.logging.context.set_current_context().", - DeprecationWarning, - stacklevel=2, - ) - return set_current_context(context) - def __enter__(self) -> "LoggingContext": """Enters this logging context into thread local storage""" old_context = set_current_context(self) From ee3f9a9adcbad54af7c80e669a8e58c8ff269588 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 29 Sep 2025 13:48:33 -0500 Subject: [PATCH 2/3] Add changelog --- changelog.d/18989.removal | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/18989.removal diff --git a/changelog.d/18989.removal b/changelog.d/18989.removal new file mode 100644 index 00000000000..356b9ffe3ac --- /dev/null +++ b/changelog.d/18989.removal @@ -0,0 +1 @@ +Remove deprecated `LoggingContext.set_current_context`/`LoggingContext.current_context` methods which already have equivalent bare methods in `synapse.logging.context`. From 5f59fefa3b37b760ab3a03fcaa64c1a830146580 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 29 Sep 2025 14:06:00 -0500 Subject: [PATCH 3/3] Fix lints --- synapse/logging/context.py | 1 - 1 file changed, 1 deletion(-) diff --git a/synapse/logging/context.py b/synapse/logging/context.py index 1489a654a90..cc402de1afa 100644 --- a/synapse/logging/context.py +++ b/synapse/logging/context.py @@ -33,7 +33,6 @@ import logging import threading import typing -import warnings from types import TracebackType from typing import ( TYPE_CHECKING,