Skip to content

Commit

Permalink
Rearrange the pixelization class logic to appease mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Oct 7, 2021
1 parent 324c0cf commit b9f8c3e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions python/lsst/daf/butler/core/dimensions/_skypix.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,15 @@ def hasDependenciesIn(self, others: AbstractSet[str]) -> bool:

def visit(self, builder: DimensionConstructionBuilder) -> None:
# Docstring inherited from DimensionConstructionVisitor.
pixelization_class = doImportType(self._pixelizationClassName)
if not hasattr(pixelization_class, "MAX_LEVEL"):
raise TypeError(f"Skypix pixelization class {self._pixelizationClassName} does"
" not have MAX_LEVEL")
PixelizationClass = pixelization_class
maxLevel = self._maxLevel if self._maxLevel is not None else PixelizationClass.MAX_LEVEL
PixelizationClass = doImportType(self._pixelizationClassName)
assert issubclass(PixelizationClass, Pixelization)
if self._maxLevel is not None:
maxLevel = self._maxLevel
else:
maxLevel = getattr(PixelizationClass, "MAX_LEVEL", None)
if maxLevel is None:
raise TypeError(f"Skypix pixelization class {self._pixelizationClassName} does"
" not have MAX_LEVEL but no max level has been set explicitly.")
system = SkyPixSystem(
self.name,
maxLevel=maxLevel,
Expand Down

0 comments on commit b9f8c3e

Please sign in to comment.