Skip to content

Commit

Permalink
Fix type annotations for profiler
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Dec 13, 2023
1 parent fea2f20 commit 451cdb3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions python/lsst/pipe/base/cmdLineTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,22 @@

import contextlib
import logging
from collections.abc import Generator
from typing import TYPE_CHECKING

from deprecated.sphinx import deprecated

if TYPE_CHECKING:
import cProfile


@deprecated(
reason="Replaced by lsst.utils.timer.profile(). Will be removed after v26.0",
version="v25.0",
category=FutureWarning,
)
@contextlib.contextmanager
def profile(filename: str, log: logging.Logger | None = None):
def profile(filename: str, log: logging.Logger | None = None) -> Generator[cProfile.Profile, None, None]:
"""Context manager for profiling with cProfile.
Parameters
Expand Down Expand Up @@ -71,7 +76,7 @@ def profile(filename: str, log: logging.Logger | None = None):
"""
if not filename:
# Nothing to do
yield
yield None # type: ignore
return
from cProfile import Profile

Expand Down

0 comments on commit 451cdb3

Please sign in to comment.