Skip to content

Commit

Permalink
Fixes for mypy now that Instrument has moved
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Mar 23, 2022
1 parent 68abb2c commit 60dcf91
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions python/lsst/obs/base/_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,4 +625,5 @@ def loadCamera(butler: Butler, dataId: DataId, *, collections: Any = None) -> Tu
pass
# We know an instrument data ID is a value, but MyPy doesn't.
instrument = Instrument.fromName(dataId["instrument"], butler.registry) # type: ignore
assert isinstance(instrument, Instrument) # for mypy
return instrument.getCamera(), False
14 changes: 11 additions & 3 deletions python/lsst/obs/base/defineVisits.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@
)
from lsst.geom import Box2D
from lsst.pex.config import Config, Field, makeRegistry, registerConfigurable
from lsst.pipe.base import Task
from lsst.pipe.base import Instrument, Task
from lsst.sphgeom import ConvexPolygon, Region, UnitVector3d
from lsst.utils.introspection import get_full_type_name

from ._instrument import Instrument, loadCamera
from ._fitsRawFormatterBase import FitsRawFormatterBase
from ._instrument import loadCamera


@dataclasses.dataclass
Expand Down Expand Up @@ -763,8 +765,14 @@ def computeExposureBounds(
# This allows flips to be taken into account
instrument = self.getInstrument(exposure.instrument)
rawFormatter = instrument.getRawFormatter({"detector": detectorId})
wcs = rawFormatter.makeRawSkyWcsFromBoresight(radec, orientation, wcsDetector)

try:
wcs = rawFormatter.makeRawSkyWcsFromBoresight(radec, orientation, wcsDetector) # type: ignore
except AttributeError:
raise TypeError(
f"Raw formatter is {get_full_type_name(rawFormatter)} but visit"
" definition requires it to support 'makeRawSkyWcsFromBoresight'"
) from None
else:
if self.config.detectorId is None:
wcsRefsIter = self.butler.registry.queryDatasets(
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/obs/base/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
Progress,
)
from lsst.pex.config import ChoiceField, Config, Field
from lsst.pipe.base import Task
from lsst.pipe.base import Instrument, Task
from lsst.resources import ResourcePath, ResourcePathExpression
from lsst.utils.timer import timeMethod

from ._instrument import Instrument, makeExposureRecordFromObsInfo
from ._instrument import makeExposureRecordFromObsInfo

# multiprocessing.Pool is actually a function, not a type, and the real type
# isn't exposed, so we can't used it annotations, so we'll just punt on it via
Expand Down

0 comments on commit 60dcf91

Please sign in to comment.