diff --git a/barman/compression.py b/barman/compression.py index 7f63859ba..bb4f63ac3 100644 --- a/barman/compression.py +++ b/barman/compression.py @@ -63,7 +63,7 @@ def __init__(self, config, path): # If custom_compression_magic is set then we should not assume # unidentified files are custom compressed and should rely on the # magic for identification instead. - elif type(config.custom_compression_magic) == str: + elif isinstance(config.custom_compression_magic, str): # Since we know the custom compression magic we can now add it # to the class property. compression_registry["custom"].MAGIC = binascii.unhexlify( @@ -419,14 +419,12 @@ def __init__(self, config, compression, path=None): :param compression: str compression name :param path: str|None """ - if ( - config.custom_compression_filter is None - or type(config.custom_compression_filter) != str + if config.custom_compression_filter is None or not isinstance( + config.custom_compression_filter, str ): raise CompressionIncompatibility("custom_compression_filter") - if ( - config.custom_decompression_filter is None - or type(config.custom_decompression_filter) != str + if config.custom_decompression_filter is None or not isinstance( + config.custom_decompression_filter, str ): raise CompressionIncompatibility("custom_decompression_filter") diff --git a/tests/test_compressor.py b/tests/test_compressor.py index 814b1fffa..2a836cf64 100644 --- a/tests/test_compressor.py +++ b/tests/test_compressor.py @@ -454,11 +454,11 @@ def test_get_pg_basebackup_compression( ) base_backup_compression = get_pg_basebackup_compression(server) - assert type(base_backup_compression) == expected_class + assert type(base_backup_compression) is expected_class if base_backup_compression is not None: - assert type(base_backup_compression.options) == expected_option_class + assert type(base_backup_compression.options) is expected_option_class assert ( - type(base_backup_compression.compression) == expected_compression_class + type(base_backup_compression.compression) is expected_compression_class ) def test_get_pg_basebackup_compression_not_supported(self):