Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

celery: remove deprecated import of ContextManager from typing #3145

Merged
merged 6 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

import logging
from typing import ContextManager, Optional, Tuple
from typing import TYPE_CHECKING, Optional, Tuple

from celery import registry # pylint: disable=no-name-in-module
from celery.app.task import Task

from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import Span

if TYPE_CHECKING:
from contextlib import AbstractContextManager
emdneto marked this conversation as resolved.
Show resolved Hide resolved

logger = logging.getLogger(__name__)

# Celery Context key
Expand Down Expand Up @@ -123,7 +128,7 @@ def attach_context(
task: Optional[Task],
task_id: str,
span: Span,
activation: ContextManager[Span],
activation: AbstractContextManager[Span],
token: Optional[object],
is_publish: bool = False,
) -> None:
Expand Down Expand Up @@ -171,7 +176,7 @@ def detach_context(task, task_id, is_publish=False) -> None:

def retrieve_context(
task, task_id, is_publish=False
) -> Optional[Tuple[Span, ContextManager[Span], Optional[object]]]:
) -> Optional[Tuple[Span, AbstractContextManager[Span], Optional[object]]]:
"""Helper to retrieve an active `Span`, `ContextManager` and context token
stored in a `Task` instance
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
amqp==5.2.0
asgiref==3.8.1
billiard==4.2.0
billiard==4.2.1
emdneto marked this conversation as resolved.
Show resolved Hide resolved
celery==5.3.6
click==8.1.7
click-didyoumean==0.3.0
Expand Down
Loading