Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-44751: Add mypy check as required GHA before merging #111

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/mypy_check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Run mypy

on:
push:
branches:
- main
pull_request:

jobs:
call-workflow:
uses: lsst/rubin_workflows/.github/workflows/mypy.yaml@main
with:
# https://github.com/python/mypy/issues/17002
mypy_package: mypy!=1.9.0
21 changes: 10 additions & 11 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ warn_unused_configs = False
warn_redundant_casts = False
plugins = pydantic.mypy

[mypy-requests.*]
ignore_missing_imports = True

[mypy-astropy.*]
ignore_missing_imports = True

[mypy-erfa.*]
ignore_missing_imports = True

[mypy-numpy.*]
ignore_missing_imports = True
ignore_missing_imports = False

[mypy-pandas.*]
ignore_missing_imports = True
Expand All @@ -38,7 +41,10 @@ ignore_missing_imports = True
ignore_missing_imports = True
[mypy-tqdm.*]
ignore_missing_imports = True

[mypy-dateutil.*]
ignore_missing_imports = True
[mypy-deprecated.sphinx.*]
ignore_missing_imports = True
# Don't check LSST packages generally or even try to import them, since most
# don't have type annotations.

Expand All @@ -51,31 +57,24 @@ ignore_errors = True
# files with their own exceptions.

[mypy-lsst.utils.*]
ignore_missing_imports = False
ignore_errors = True

[mypy-lsst.resources.*]
ignore_missing_imports = False
ignore_errors = True

[mypy-lsst.daf.relation.*]
ignore_missing_imports = False
ignore_errors = True

[mypy-lsst.daf.butler.*]
ignore_missing_imports = False
ignore_errors = True

[mypy-lsst.obs.base.*]
ignore_missing_imports = False
ignore_errors = True

[mypy-lsst.pipe.base.*]
ignore_missing_imports = False
ignore_errors = True

[mypy-lsst.pex.config.*]
ignore_missing_imports = False
ignore_errors = True

[mypy-config.*]
Expand All @@ -86,11 +85,11 @@ ignore_errors = True

# Check all of summit_utils...
[mypy-lsst.summit.utils.*]
ignore_missing_imports = False
ignore_missing_imports = True
ignore_errors = False
disallow_untyped_defs = False
disallow_incomplete_defs = False
strict_equality = False
strict_equality = True
warn_unreachable = False
warn_unused_ignores = False
allow_untyped_globals = True
Expand Down
7 changes: 3 additions & 4 deletions python/lsst/summit/utils/nightReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import datetime
import logging
import pickle
from collections.abc import Callable, Iterable
from collections.abc import Iterable
from dataclasses import dataclass
from typing import Any

Expand All @@ -40,15 +40,14 @@
from .utils import getFieldNameAndTileNumber, obsInfoToDict

try: # TODO: Remove post RFC-896: add humanize to rubin-env
precisedelta: "Callable[[Any], str]"
from humanize.time import precisedelta

HAVE_HUMANIZE = True
except ImportError:
# log a python warning about the lack of humanize
logging.warning("humanize not available, install it to get better time printing")
HAVE_HUMANIZE = False
precisedelta = repr
precisedelta = repr # type: ignore


__all__ = ["NightReport"]
Expand Down Expand Up @@ -453,7 +452,7 @@ def printShutterTimes(self) -> None:
sciEff = 100 * (timings["scienceTimeTotal"] / timings["nightLength"])
print(f"Science shutter efficiency = {sciEff:.1f}%")

def getTimeDeltas(self) -> dict[int, float]:
def getTimeDeltas(self) -> dict[int, int]:
"""Returns a dict, keyed by seqNum, of the time since the end of the
last integration. The time since does include the readout, so is always
greater than or equal to the readout time.
Expand Down
4 changes: 3 additions & 1 deletion python/lsst/summit/utils/quickLook.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ def __init__(self, *, config: Any = None):
self.outputExposure = exposure


class QuickLookIsrTaskConfig(pipeBase.PipelineTaskConfig, pipelineConnections=QuickLookIsrTaskConnections):
class QuickLookIsrTaskConfig(
pipeBase.PipelineTaskConfig, pipelineConnections=QuickLookIsrTaskConnections # type: ignore
):
"""Configuration parameters for QuickLookIsrTask."""

doRepairCosmics: pexConfig.Field[bool] = pexConfig.Field(
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/summit/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ def bboxToMatplotlibRectanle(bbox: geom.Box2I | geom.Box2D) -> matplotlib.patche
return Rectangle(ll, width, height)


def computeExposureId(instrument: str, controller: str, dayObs: int, seqNum) -> int:
def computeExposureId(instrument: str, controller: str, dayObs: int, seqNum: int) -> int:
instrument = instrument.lower()
if instrument == "latiss":
return lsst.obs.lsst.translators.LatissTranslator.compute_exposure_id(dayObs, seqNum, controller)
Expand Down
5 changes: 5 additions & 0 deletions types.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pydantic
numpy
matplotlib
astro-metadata-translator
humanize
Loading