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

[Git][ftp-team/dak][master] 2 commits: add `__hash__` where a custom `__eq__` is provided



Title: GitLab

Ansgar pushed to branch master at Debian FTP Team / dak

Commits:

2 changed files:

Changes:

  • daklib/database/architecture.py
    ... ... @@ -14,6 +14,8 @@
    14 14
     
    
    15 15
     ################################################################################
    
    16 16
     
    
    17
    +import warnings
    
    18
    +
    
    17 19
     from sqlalchemy import Column, Integer, Text
    
    18 20
     from sqlalchemy.schema import Index
    
    19 21
     
    
    ... ... @@ -45,12 +47,16 @@ class Architecture(BaseTimestamp):
    45 47
     
    
    46 48
         def __eq__(self, val):
    
    47 49
             if isinstance(val, str):
    
    50
    +            warnings.warn("comparison with a `str` is deprecated", DeprecationWarning)
    
    48 51
                 return (self.arch_string == val)
    
    49 52
             # This signals to use the normal comparison operator
    
    50 53
             return NotImplemented
    
    51 54
     
    
    52 55
         def __ne__(self, val):
    
    53 56
             if isinstance(val, str):
    
    57
    +            warnings.warn("comparison with a `str` is deprecated", DeprecationWarning)
    
    54 58
                 return (self.arch_string != val)
    
    55 59
             # This signals to use the normal comparison operator
    
    56 60
             return NotImplemented
    
    61
    +
    
    62
    +    __hash__ = BaseTimestamp.__hash__

  • daklib/database/section.py
    ... ... @@ -14,6 +14,8 @@
    14 14
     
    
    15 15
     ################################################################################
    
    16 16
     
    
    17
    +import warnings
    
    18
    +
    
    17 19
     from sqlalchemy import Column, Integer, Text
    
    18 20
     from sqlalchemy.schema import Index
    
    19 21
     
    
    ... ... @@ -43,12 +45,16 @@ class Section(BaseTimestamp):
    43 45
     
    
    44 46
         def __eq__(self, val):
    
    45 47
             if isinstance(val, str):
    
    48
    +            warnings.warn("comparison with a `str` is deprecated", DeprecationWarning)
    
    46 49
                 return (self.section == val)
    
    47 50
             # This signals to use the normal comparison operator
    
    48 51
             return NotImplemented
    
    49 52
     
    
    50 53
         def __ne__(self, val):
    
    51 54
             if isinstance(val, str):
    
    55
    +            warnings.warn("comparison with a `str` is deprecated", DeprecationWarning)
    
    52 56
                 return (self.section != val)
    
    53 57
             # This signals to use the normal comparison operator
    
    54 58
             return NotImplemented
    
    59
    +
    
    60
    +    __hash__ = BaseTimestamp.__hash__


  • Reply to: