[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Git][ftp-team/dak][master] fix(archive_dedup_pool): add missing `.mappings()` call



Title: GitLab

Ansgar pushed to branch master at Debian FTP Team / dak

Commits:

  • 55bc13bd
    by Ansgar at 2025-12-30T20:34:40+01:00
    fix(archive_dedup_pool): add missing `.mappings()` call
    
    Otherwise the columns cannot be accessed by name.
    
    Also add enough type annotations for Mypy to report the error and
    confirm the fix.
    

1 changed file:

Changes:

  • dak/archive_dedup_pool.py
    ... ... @@ -26,6 +26,7 @@
    26 26
     import errno
    
    27 27
     import os
    
    28 28
     import sys
    
    29
    +from typing import TYPE_CHECKING
    
    29 30
     
    
    30 31
     import apt_pkg
    
    31 32
     from sqlalchemy import sql
    
    ... ... @@ -34,6 +35,9 @@ from daklib import daklog
    34 35
     from daklib.config import Config
    
    35 36
     from daklib.dbconn import DBConn
    
    36 37
     
    
    38
    +if TYPE_CHECKING:
    
    39
    +    from sqlalchemy.orm import Session
    
    40
    +
    
    37 41
     Options: apt_pkg.Configuration
    
    38 42
     Logger: daklog.Logger
    
    39 43
     
    
    ... ... @@ -55,7 +59,7 @@ def usage(exit_code=0):
    55 59
     ################################################################################
    
    56 60
     
    
    57 61
     
    
    58
    -def dedup_one(size, reference, *filenames):
    
    62
    +def dedup_one(size: int, reference: str, *filenames: str) -> None:
    
    59 63
         stat_reference = os.stat(reference)
    
    60 64
     
    
    61 65
         # safety net
    
    ... ... @@ -97,7 +101,7 @@ def dedup_one(size, reference, *filenames):
    97 101
     ################################################################################
    
    98 102
     
    
    99 103
     
    
    100
    -def dedup(session):
    
    104
    +def dedup(session: "Session") -> None:
    
    101 105
         results = session.execute(
    
    102 106
             sql.text(
    
    103 107
                 """
    
    ... ... @@ -124,7 +128,7 @@ SELECT DISTINCT *
    124 128
         WHERE array_length(filenames, 1) > 1
    
    125 129
         """
    
    126 130
             )
    
    127
    -    )
    
    131
    +    ).mappings()
    
    128 132
     
    
    129 133
         for i in results:
    
    130 134
             dedup_one(i["size"], *i["filenames"])
    


  • Reply to: