From f8573e35b1effe219f0638f74f8e57de8e698958 Mon Sep 17 00:00:00 2001 From: Jakob van Santen Date: Mon, 6 Jan 2025 10:23:59 +0100 Subject: [PATCH] chore: remove unused ignores --- ampel/template/ZTFLegacyChannelTemplate.py | 2 +- ampel/ztf/alert/BTSForcedPhotometryAlertSupplier.py | 2 +- ampel/ztf/alert/ZTFForcedPhotometryAlertSupplier.py | 2 +- ampel/ztf/alert/ZTFGeneralActiveAlertRegister.py | 6 +++--- ampel/ztf/alert/ZTFGeneralAlertRegister.py | 2 +- ampel/ztf/alert/ZTFIPACForcedPhotometryAlertSupplier.py | 8 ++++---- ampel/ztf/alert/ZiAlertSupplier.py | 4 +--- ampel/ztf/alert/ZiHealpixAlertSupplier.py | 2 +- ampel/ztf/alert/load/ZTFHealpixAlertLoader.py | 2 +- ampel/ztf/dev/DevAlertConsumer.py | 2 +- ampel/ztf/ingest/ZiArchiveMuxer.py | 2 +- ampel/ztf/ingest/ZiDataPointShaper.py | 2 +- ampel/ztf/t0/ZTFAlertStreamController.py | 2 +- ampel/ztf/t0/load/fetcherutils.py | 2 +- ampel/ztf/t3/T3LegacyExtJournalAppender.py | 4 +--- ampel/ztf/t3/complement/GROWTHMarshalReport.py | 2 +- ampel/ztf/t3/complement/ZTFCutoutImages.py | 4 ++-- ampel/ztf/t3/skyportal/SkyPortalClient.py | 2 +- ampel/ztf/t4/T4ZTFArchiveTokenGenerator.py | 4 ++-- ampel/ztf/util/ZTFIdMapper.py | 4 ++-- ampel/ztf/util/ZTFNoisifiedIdMapper.py | 2 +- pyproject.toml | 1 + 22 files changed, 30 insertions(+), 33 deletions(-) diff --git a/ampel/template/ZTFLegacyChannelTemplate.py b/ampel/template/ZTFLegacyChannelTemplate.py index 94b1e85f..7d58b0e1 100755 --- a/ampel/template/ZTFLegacyChannelTemplate.py +++ b/ampel/template/ZTFLegacyChannelTemplate.py @@ -66,7 +66,7 @@ def get_processes( ) if not any(model.unit == "T2LightCurveSummary" for model in self.t2_compute): - self.t2_compute.append(T2Compute(unit="T2LightCurveSummary")) # type: ignore[arg-type] + self.t2_compute.append(T2Compute(unit="T2LightCurveSummary")) mongo_muxer = {"unit": "ZiMongoMuxer"} if self.live_history else None archive_muxer = ( diff --git a/ampel/ztf/alert/BTSForcedPhotometryAlertSupplier.py b/ampel/ztf/alert/BTSForcedPhotometryAlertSupplier.py index f5fef6c7..746a3654 100644 --- a/ampel/ztf/alert/BTSForcedPhotometryAlertSupplier.py +++ b/ampel/ztf/alert/BTSForcedPhotometryAlertSupplier.py @@ -146,7 +146,7 @@ def _load_pps(self, fpath: str) -> bool: allpeaks = {} for obs_group, df_group in df.groupby("fcqfid"): # Skip secondary grid - if obs_group > 10000000: # type: ignore + if obs_group > 10000000: continue if not self.allow_iband_peak and str(obs_group)[-1] == "3": continue diff --git a/ampel/ztf/alert/ZTFForcedPhotometryAlertSupplier.py b/ampel/ztf/alert/ZTFForcedPhotometryAlertSupplier.py index 24e4e675..76d40292 100755 --- a/ampel/ztf/alert/ZTFForcedPhotometryAlertSupplier.py +++ b/ampel/ztf/alert/ZTFForcedPhotometryAlertSupplier.py @@ -80,7 +80,7 @@ def __next__(self) -> AmpelAlertProtocol: :raises AttributeError: if alert_loader was not set properly before this method is called """ - fpath = next(self.alert_loader) # type: ignore + fpath = next(self.alert_loader) with open(fpath) as fd: # type: ignore # Convert first line comment "# key1: val1, key2: val2" into dict (requires loader binary_mode=False) cdict = { diff --git a/ampel/ztf/alert/ZTFGeneralActiveAlertRegister.py b/ampel/ztf/alert/ZTFGeneralActiveAlertRegister.py index 54d7fa24..c097b31c 100755 --- a/ampel/ztf/alert/ZTFGeneralActiveAlertRegister.py +++ b/ampel/ztf/alert/ZTFGeneralActiveAlertRegister.py @@ -26,7 +26,7 @@ class ZTFGeneralActiveAlertRegister(ZTFGeneralAlertRegister): __slots__: ClassVar[tuple[str, ...]] = ( "_write", - "alert_max", # type: ignore + "alert_max", "alert_min", "stock_max", "stock_min", @@ -40,14 +40,14 @@ class ZTFGeneralActiveAlertRegister(ZTFGeneralAlertRegister): } new_header_size: int | str = "+4096" - header_hints: ClassVar[Sequence[str]] = ("alert", "stock") # type: ignore + header_hints: ClassVar[Sequence[str]] = ("alert", "stock") alert_min: int alert_max: int stock_min: int stock_max: int ztf_years: set[int] - def __init__(self, **kwargs) -> None: # type: ignore[override] + def __init__(self, **kwargs) -> None: super().__init__(**kwargs) hdr = self.header["payload"] if "ztf_years" in hdr: diff --git a/ampel/ztf/alert/ZTFGeneralAlertRegister.py b/ampel/ztf/alert/ZTFGeneralAlertRegister.py index b79fa1e5..bc97d303 100755 --- a/ampel/ztf/alert/ZTFGeneralAlertRegister.py +++ b/ampel/ztf/alert/ZTFGeneralAlertRegister.py @@ -24,7 +24,7 @@ class ZTFGeneralAlertRegister(BaseAlertRegister): Logs: alert_id, filter_res, stock """ - __slots__: ClassVar[tuple[str, ...]] = ("_write",) # type: ignore + __slots__: ClassVar[tuple[str, ...]] = ("_write",) struct: Literal[" None: diff --git a/ampel/ztf/alert/ZTFIPACForcedPhotometryAlertSupplier.py b/ampel/ztf/alert/ZTFIPACForcedPhotometryAlertSupplier.py index b71adc2c..9931349c 100644 --- a/ampel/ztf/alert/ZTFIPACForcedPhotometryAlertSupplier.py +++ b/ampel/ztf/alert/ZTFIPACForcedPhotometryAlertSupplier.py @@ -23,7 +23,7 @@ # from ampel.plot.create import create_plot_record from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol from ampel.view.ReadOnlyDict import ReadOnlyDict -from ampel.ztf.alert.calibrate_fps_fork import get_baseline # type: ignore[import] +from ampel.ztf.alert.calibrate_fps_fork import get_baseline from ampel.ztf.util.ZTFIdMapper import to_ampel_id dcast = { @@ -166,7 +166,7 @@ def _load_pps(self, fpath: str) -> bool: ) self.name_values = df[self.name_key] - with open(fpath) as f: # type: ignore + with open(fpath) as f: li = iter(f) for line in li: if "# Requested input R.A." in line: @@ -175,8 +175,8 @@ def _load_pps(self, fpath: str) -> bool: break # Parse filename for info - tags = basename(fpath).split(".")[1:-1] or None # type: ignore - sn_name: str | int = basename(fpath).split(".")[0] # type: ignore + tags = basename(fpath).split(".")[1:-1] or None + sn_name: str | int = basename(fpath).split(".")[0] df = pd.DataFrame() d = get_baseline( diff --git a/ampel/ztf/alert/ZiAlertSupplier.py b/ampel/ztf/alert/ZiAlertSupplier.py index e8ff1c0d..41e4cc96 100755 --- a/ampel/ztf/alert/ZiAlertSupplier.py +++ b/ampel/ztf/alert/ZiAlertSupplier.py @@ -28,9 +28,7 @@ def __next__(self) -> AmpelAlert: :raises StopIteration: when alert_loader dries out. :raises AttributeError: if alert_loader was not set properly before this method is called """ - d = self._deserialize( - next(self.alert_loader) # type: ignore - ) + d = self._deserialize(next(self.alert_loader)) return self.shape_alert_dict(d) diff --git a/ampel/ztf/alert/ZiHealpixAlertSupplier.py b/ampel/ztf/alert/ZiHealpixAlertSupplier.py index 232e678b..d75766ab 100644 --- a/ampel/ztf/alert/ZiHealpixAlertSupplier.py +++ b/ampel/ztf/alert/ZiHealpixAlertSupplier.py @@ -53,5 +53,5 @@ def __next__(self) -> AmpelAlertProtocol: :raises AttributeError: if alert_loader was not set properly before this method is called """ - d = self._deserialize(next(self.alert_loader)) # type: ignore + d = self._deserialize(next(self.alert_loader)) return ZiAlertSupplier.shape_alert_dict(d) diff --git a/ampel/ztf/alert/load/ZTFHealpixAlertLoader.py b/ampel/ztf/alert/load/ZTFHealpixAlertLoader.py index 707e1c00..00d7defd 100644 --- a/ampel/ztf/alert/load/ZTFHealpixAlertLoader.py +++ b/ampel/ztf/alert/load/ZTFHealpixAlertLoader.py @@ -93,7 +93,7 @@ def __next__(self) -> dict[str, Any]: def _get_alerts(self) -> Generator[dict[str, Any], None, None]: assert self.source is not None - while self.query_start < len(self.source.pixels): # type: ignore[union-attr] + while self.query_start < len(self.source.pixels): chunk = self._get_chunk() if self.stream is None: self.stream = chunk["resume_token"] diff --git a/ampel/ztf/dev/DevAlertConsumer.py b/ampel/ztf/dev/DevAlertConsumer.py index a1c51659..ca1bca75 100755 --- a/ampel/ztf/dev/DevAlertConsumer.py +++ b/ampel/ztf/dev/DevAlertConsumer.py @@ -7,7 +7,7 @@ # Last Modified By: valery brinnel -import logging # type: ignore[import] +import logging import sys import tarfile import time diff --git a/ampel/ztf/ingest/ZiArchiveMuxer.py b/ampel/ztf/ingest/ZiArchiveMuxer.py index 031b8e99..5c5c04c6 100644 --- a/ampel/ztf/ingest/ZiArchiveMuxer.py +++ b/ampel/ztf/ingest/ZiArchiveMuxer.py @@ -1,7 +1,7 @@ from collections.abc import Sequence from typing import Any -import backoff # type: ignore +import backoff import requests from ampel.abstract.AbsT0Muxer import AbsT0Muxer diff --git a/ampel/ztf/ingest/ZiDataPointShaper.py b/ampel/ztf/ingest/ZiDataPointShaper.py index a7bf53b9..c2ba3ede 100755 --- a/ampel/ztf/ingest/ZiDataPointShaper.py +++ b/ampel/ztf/ingest/ZiDataPointShaper.py @@ -31,7 +31,7 @@ class ZiDataPointShaperBase(AmpelUnit): digest_size: int = 8 # Mandatory implementation - def process(self, arg: Iterable[dict[str, Any]], stock: StockId) -> list[DataPoint]: # type: ignore[override] + def process(self, arg: Iterable[dict[str, Any]], stock: StockId) -> list[DataPoint]: """ :param arg: sequence of unshaped pps IMPORTANT: diff --git a/ampel/ztf/t0/ZTFAlertStreamController.py b/ampel/ztf/t0/ZTFAlertStreamController.py index e62266fc..b3b1da1d 100755 --- a/ampel/ztf/t0/ZTFAlertStreamController.py +++ b/ampel/ztf/t0/ZTFAlertStreamController.py @@ -138,7 +138,7 @@ def launch() -> asyncio.Task: try: while self._process.active and len(pending) > 1: try: - done, pending = await asyncio.wait( # type: ignore[assignment] + done, pending = await asyncio.wait( pending, return_when="FIRST_COMPLETED" ) for task in list(done): diff --git a/ampel/ztf/t0/load/fetcherutils.py b/ampel/ztf/t0/load/fetcherutils.py index 1ead8fd5..ae8811ae 100755 --- a/ampel/ztf/t0/load/fetcherutils.py +++ b/ampel/ztf/t0/load/fetcherutils.py @@ -81,7 +81,7 @@ def trim_alert(payload): def list_kafka(): from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser - from pykafka import KafkaClient # type: ignore[import] + from pykafka import KafkaClient # type: ignore[import-not-found] parser = ArgumentParser( description=__doc__, formatter_class=ArgumentDefaultsHelpFormatter diff --git a/ampel/ztf/t3/T3LegacyExtJournalAppender.py b/ampel/ztf/t3/T3LegacyExtJournalAppender.py index f14ef12d..9957dd58 100755 --- a/ampel/ztf/t3/T3LegacyExtJournalAppender.py +++ b/ampel/ztf/t3/T3LegacyExtJournalAppender.py @@ -24,9 +24,7 @@ def get_ext_journal(self, stock_id: StockId) -> None | list[JournalRecord]: """ if ext_stock := next( - self.col.find( - {"_id": legacy_to_ampel_id(to_ztf_id(stock_id))} # type: ignore[arg-type] - ), + self.col.find({"_id": legacy_to_ampel_id(to_ztf_id(stock_id))}), None, ): for j in ext_stock["journal"]: diff --git a/ampel/ztf/t3/complement/GROWTHMarshalReport.py b/ampel/ztf/t3/complement/GROWTHMarshalReport.py index 332d0a6e..cd63c795 100755 --- a/ampel/ztf/t3/complement/GROWTHMarshalReport.py +++ b/ampel/ztf/t3/complement/GROWTHMarshalReport.py @@ -9,7 +9,7 @@ from collections.abc import Iterable, Sequence from typing import Any -import backoff # type: ignore[import] +import backoff import requests from ampel.abstract.AbsBufferComplement import AbsBufferComplement diff --git a/ampel/ztf/t3/complement/ZTFCutoutImages.py b/ampel/ztf/t3/complement/ZTFCutoutImages.py index 64a1e2b0..fd87f942 100755 --- a/ampel/ztf/t3/complement/ZTFCutoutImages.py +++ b/ampel/ztf/t3/complement/ZTFCutoutImages.py @@ -9,8 +9,8 @@ from collections.abc import Iterable from typing import Literal -import backoff # type: ignore[import] -import requests # type: ignore[import] +import backoff +import requests from requests_toolbelt.sessions import BaseUrlSession from ampel.abstract.AbsBufferComplement import AbsBufferComplement diff --git a/ampel/ztf/t3/skyportal/SkyPortalClient.py b/ampel/ztf/t3/skyportal/SkyPortalClient.py index aaa4a4fe..f050c45f 100755 --- a/ampel/ztf/t3/skyportal/SkyPortalClient.py +++ b/ampel/ztf/t3/skyportal/SkyPortalClient.py @@ -241,7 +241,7 @@ def request( with ( stat_http_time.labels(*labels).time(), stat_http_errors.labels(*labels).count_exceptions( - ( # type: ignore[arg-type] + ( requests.exceptions.HTTPError, requests.exceptions.ConnectionError, requests.exceptions.Timeout, diff --git a/ampel/ztf/t4/T4ZTFArchiveTokenGenerator.py b/ampel/ztf/t4/T4ZTFArchiveTokenGenerator.py index 9f1a9dfa..cecf530c 100644 --- a/ampel/ztf/t4/T4ZTFArchiveTokenGenerator.py +++ b/ampel/ztf/t4/T4ZTFArchiveTokenGenerator.py @@ -11,8 +11,8 @@ from datetime import datetime from typing import Any -from astropy.time import Time # type: ignore[import] -from requests_toolbelt.sessions import BaseUrlSession # type: ignore[import] +from astropy.time import Time +from requests_toolbelt.sessions import BaseUrlSession from ampel.abstract.AbsT4Unit import AbsT4Unit from ampel.secret.NamedSecret import NamedSecret diff --git a/ampel/ztf/util/ZTFIdMapper.py b/ampel/ztf/util/ZTFIdMapper.py index c45fc920..a1b0c908 100755 --- a/ampel/ztf/util/ZTFIdMapper.py +++ b/ampel/ztf/util/ZTFIdMapper.py @@ -31,7 +31,7 @@ def to_ampel_id(cls, ztf_id: str) -> int: ... def to_ampel_id(cls, ztf_id: StrictIterable[str]) -> list[int]: ... @classmethod - def to_ampel_id(cls, ztf_id: str | StrictIterable[str]) -> int | list[int]: # type: ignore[override] + def to_ampel_id(cls, ztf_id: str | StrictIterable[str]) -> int | list[int]: """ :returns: ampel id (positive integer). @@ -113,7 +113,7 @@ def to_ext_id(cls, ampel_id: StockId) -> str: ... def to_ext_id(cls, ampel_id: StrictIterable[StockId]) -> list[str]: ... @classmethod - def to_ext_id(cls, ampel_id: StockId | StrictIterable[StockId]) -> str | list[str]: # type: ignore[override] + def to_ext_id(cls, ampel_id: StockId | StrictIterable[StockId]) -> str | list[str]: """ %timeit to_ext_id(274878346346) 1.54 µs ± 77.9 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each) diff --git a/ampel/ztf/util/ZTFNoisifiedIdMapper.py b/ampel/ztf/util/ZTFNoisifiedIdMapper.py index 13fc92a4..b4089247 100644 --- a/ampel/ztf/util/ZTFNoisifiedIdMapper.py +++ b/ampel/ztf/util/ZTFNoisifiedIdMapper.py @@ -54,7 +54,7 @@ def to_ext_id(cls, ampel_id: StockId) -> str: ... def to_ext_id(cls, ampel_id: StrictIterable[StockId]) -> list[str]: ... @classmethod - def to_ext_id(cls, ampel_id: StockId | StrictIterable[StockId]) -> str | list[str]: # type: ignore[override] + def to_ext_id(cls, ampel_id: StockId | StrictIterable[StockId]) -> str | list[str]: """ Return the original name of the noisified lightcurve """ diff --git a/pyproject.toml b/pyproject.toml index 933d6bc7..bf2e9631 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -106,6 +106,7 @@ filterwarnings = [ [tool.mypy] namespace_packages = true show_error_codes = true +warn_unused_ignores = true [[tool.mypy.overrides]] module = [