Skip to content

Commit

Permalink
chore: remove unused ignores
Browse files Browse the repository at this point in the history
  • Loading branch information
jvansanten committed Jan 6, 2025
1 parent 0592e83 commit f8573e3
Show file tree
Hide file tree
Showing 22 changed files with 30 additions and 33 deletions.
2 changes: 1 addition & 1 deletion ampel/template/ZTFLegacyChannelTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
2 changes: 1 addition & 1 deletion ampel/ztf/alert/BTSForcedPhotometryAlertSupplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ampel/ztf/alert/ZTFForcedPhotometryAlertSupplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
6 changes: 3 additions & 3 deletions ampel/ztf/alert/ZTFGeneralActiveAlertRegister.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ZTFGeneralActiveAlertRegister(ZTFGeneralAlertRegister):

__slots__: ClassVar[tuple[str, ...]] = (
"_write",
"alert_max", # type: ignore
"alert_max",
"alert_min",
"stock_max",
"stock_min",
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion ampel/ztf/alert/ZTFGeneralAlertRegister.py
Original file line number Diff line number Diff line change
Expand Up @@ -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["<QB5s"] = "<QB5s"

def file(self, alert: AmpelAlertProtocol, filter_res: int = 0) -> None:
Expand Down
8 changes: 4 additions & 4 deletions ampel/ztf/alert/ZTFIPACForcedPhotometryAlertSupplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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:
Expand All @@ -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(
Expand Down
4 changes: 1 addition & 3 deletions ampel/ztf/alert/ZiAlertSupplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion ampel/ztf/alert/ZiHealpixAlertSupplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion ampel/ztf/alert/load/ZTFHealpixAlertLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion ampel/ztf/dev/DevAlertConsumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Last Modified By: valery brinnel <firstname.lastname@gmail.com>


import logging # type: ignore[import]
import logging
import sys
import tarfile
import time
Expand Down
2 changes: 1 addition & 1 deletion ampel/ztf/ingest/ZiArchiveMuxer.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion ampel/ztf/ingest/ZiDataPointShaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion ampel/ztf/t0/ZTFAlertStreamController.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion ampel/ztf/t0/load/fetcherutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions ampel/ztf/t3/T3LegacyExtJournalAppender.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down
2 changes: 1 addition & 1 deletion ampel/ztf/t3/complement/GROWTHMarshalReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ampel/ztf/t3/complement/ZTFCutoutImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ampel/ztf/t3/skyportal/SkyPortalClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions ampel/ztf/t4/T4ZTFArchiveTokenGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ampel/ztf/util/ZTFIdMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ampel/ztf/util/ZTFNoisifiedIdMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ filterwarnings = [
[tool.mypy]
namespace_packages = true
show_error_codes = true
warn_unused_ignores = true

[[tool.mypy.overrides]]
module = [
Expand Down

0 comments on commit f8573e3

Please sign in to comment.