Skip to content

Commit

Permalink
ruff: simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
jvansanten committed Nov 27, 2024
1 parent e9a2855 commit 19a6947
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ampel/ztf/base/CatalogMatchFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,6 @@ def process(self, alert: AmpelAlertProtocol) -> bool:
dec = latest["dec"]
if self.accept and not self._evaluate_match(ra, dec, self.accept):
return False
if self.reject and self._evaluate_match(ra, dec, self.reject):
if self.reject and self._evaluate_match(ra, dec, self.reject): # noqa: SIM103
return False
return True
2 changes: 1 addition & 1 deletion ampel/ztf/dev/DevAlertConsumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_rejected_alerts(self):

def process_tar(self, tar_file_path, tar_mode="r:gz", iter_max=5000, iter_offset=0):
"""For each alert: load, filter, ingest"""
self.tar_file = tarfile.open(tar_file_path, mode=tar_mode)
self.tar_file = tarfile.open(tar_file_path, mode=tar_mode) # noqa: SIM115
return self._run(
self.tar_file, self._unpack, iter_max=iter_max, iter_offset=iter_offset
)
Expand Down
3 changes: 1 addition & 2 deletions ampel/ztf/t0/load/fetcherutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def trim_alert(payload):
t0 = time.time()
num = 0
num_bytes = 0
for message in consumer:
for num, message in enumerate(consumer, 1):
candid, payload = trim_alert(message.value())
ti = tarfile.TarInfo(f"{opts.topic}/{candid}.avro")
ti.size = len(payload)
Expand All @@ -69,7 +69,6 @@ def trim_alert(payload):
ti.gid = os.getegid()
ti.gname = gid
archive.addfile(ti, io.BytesIO(payload))
num += 1
num_bytes += len(message.value())
if num % 1000 == 0:
# consumer.commit_offsets()
Expand Down

0 comments on commit 19a6947

Please sign in to comment.