Query not properly executed
Motivation
----------

While reviewing #5340, I noticed that there’s a query execution that doesn’t look right (the query is not stored in `stmt`).

https://github.com/rucio/rucio/blob/35d7ce449cfcfb895d19b0ea8d4b77065ce8eb19/lib/rucio/core/replica.py#L2136-L2146

Side note: there’s room for improvement in the coding style.

Modification
------------



diff --git a/lib/rucio/core/replica.py b/lib/rucio/core/replica.py
index 9647a1974..7d470d081 100644
--- a/lib/rucio/core/replica.py
+++ b/lib/rucio/core/replica.py
@@ -2116,7 +2116,7 @@ def __delete_replicas_without_temp_tables(rse_id, files, ignore_availability=Tru
         rowcount += result.rowcount
 
     for chunk in chunks(bad_replica_condition, 10):
-        update(models.BadReplicas).\\
+        stmt = update(models.BadReplicas).\\
             where(models.BadReplicas.rse_id == rse_id). \\
             where(or_(*chunk)). \\
             where(models.BadReplicas.state == BadFilesStatus.BAD) .\\
@@ -2126,7 +2126,7 @@ def __delete_replicas_without_temp_tables(rse_id, files, ignore_availability=Tru
                 updated_at=datetime.utcnow()
         )
 
-        result = session.execute(stmt)
+        session.execute(stmt)
 
     if rowcount != len(files):
         raise exception.ReplicaNotFound("One or several replicas don't exist.")
['lib/rucio/core/replica.py']