diff --git a/python/lsst/daf/butler/_named.py b/python/lsst/daf/butler/_named.py index ab1eca68da..4e20e369e6 100644 --- a/python/lsst/daf/butler/_named.py +++ b/python/lsst/daf/butler/_named.py @@ -272,7 +272,7 @@ def freeze(self) -> NamedKeyMapping[K, V]: to a new variable (and considering any previous references invalidated) should allow for more accurate static type checking. """ - if not isinstance(self._dict, MappingProxyType): + if not isinstance(self._dict, MappingProxyType): # type: ignore self._dict = MappingProxyType(self._dict) # type: ignore return self @@ -592,7 +592,7 @@ def freeze(self) -> NamedValueAbstractSet[K]: to a new variable (and considering any previous references invalidated) should allow for more accurate static type checking. """ - if not isinstance(self._mapping, MappingProxyType): + if not isinstance(self._mapping, MappingProxyType): # type: ignore self._mapping = MappingProxyType(self._mapping) # type: ignore return self diff --git a/python/lsst/daf/butler/persistence_context.py b/python/lsst/daf/butler/persistence_context.py index b366564d45..a703636603 100644 --- a/python/lsst/daf/butler/persistence_context.py +++ b/python/lsst/daf/butler/persistence_context.py @@ -33,7 +33,7 @@ import uuid from collections.abc import Callable, Hashable from contextvars import Context, ContextVar, Token, copy_context -from typing import TYPE_CHECKING, ParamSpec, TypeVar, cast +from typing import TYPE_CHECKING, ParamSpec, TypeVar if TYPE_CHECKING: from ._dataset_ref import DatasetRef @@ -194,8 +194,6 @@ def run(self, function: Callable[_Q, _T], *args: _Q.args, **kwargs: _Q.kwargs) - """ self._ctx = copy_context() # Type checkers seem to have trouble with a second layer nesting of - # parameter specs in callables, so ignore the call here and explicitly - # cast the result as we know this is exactly what the return type will - # be. + # parameter specs in callables, so ignore the call here. result = self._ctx.run(self._functionRunner, function, *args, **kwargs) # type: ignore - return cast(_T, result) + return result