diff --git a/python/lsst/pipe/base/_datasetQueryConstraints.py b/python/lsst/pipe/base/_datasetQueryConstraints.py index 0390c8b04..7bf8cc2e0 100644 --- a/python/lsst/pipe/base/_datasetQueryConstraints.py +++ b/python/lsst/pipe/base/_datasetQueryConstraints.py @@ -31,6 +31,8 @@ from collections.abc import Iterable, Iterator from typing import Protocol +from lsst.utils.introspection import find_outside_stacklevel + class DatasetQueryConstraintVariant(Iterable, Protocol): """Base for all the valid variants for controlling @@ -83,7 +85,11 @@ def fromExpression(cls, expression: str) -> "DatasetQueryConstraintVariant": return cls.OFF else: if " " in expression: - warnings.warn("Whitespace found in expression will be trimmed", RuntimeWarning) + warnings.warn( + "Whitespace found in expression will be trimmed", + RuntimeWarning, + stacklevel=find_outside_stacklevel("lsst.pipe.base"), + ) expression = expression.replace(" ", "") members = expression.split(",") return cls.LIST(members) diff --git a/python/lsst/pipe/base/pipelineIR.py b/python/lsst/pipe/base/pipelineIR.py index f8a57dd81..ed9b82d7a 100644 --- a/python/lsst/pipe/base/pipelineIR.py +++ b/python/lsst/pipe/base/pipelineIR.py @@ -43,6 +43,7 @@ import yaml from lsst.resources import ResourcePath, ResourcePathExpression +from lsst.utils.introspection import find_outside_stacklevel class _Tags(enum.Enum): @@ -315,7 +316,8 @@ def formatted(self, parameters: ParametersIR) -> ConfigIR: warnings.warn( f"config {key} contains value {match.group(0)} which is formatted like a " "Pipeline parameter but was not found within the Pipeline, if this was not " - "intentional, check for a typo" + "intentional, check for a typo", + stacklevel=find_outside_stacklevel("lsst.pipe.base"), ) return new_config