Skip to content

Commit

Permalink
Run isort on code to remove unused imports and blank lines
Browse files Browse the repository at this point in the history
Execute isort on the whole projet cleaning up and sorting imports
in both tests and code.

References: bar-429

Signed-off-by: Giulio Calacoci <[email protected]>
  • Loading branch information
gcalacoci committed Oct 29, 2024
1 parent 01e7230 commit d7a03e4
Show file tree
Hide file tree
Showing 67 changed files with 242 additions and 267 deletions.
1 change: 0 additions & 1 deletion barman/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import errno
import io
import os

from abc import ABCMeta, abstractmethod

from barman.exceptions import ArchivalBackupException
Expand Down
10 changes: 5 additions & 5 deletions barman/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,36 @@
RsyncBackupExecutor,
SnapshotBackupExecutor,
)
from barman.backup_manifest import BackupManifest
from barman.cloud_providers import get_snapshot_interface_from_backup_info
from barman.command_wrappers import PgVerifyBackup
from barman.compression import CompressionManager
from barman.config import BackupOptions
from barman.exceptions import (
AbortedRetryHookScript,
BackupException,
CommandFailedException,
CompressionIncompatibility,
LockFileBusy,
SshCommandException,
UnknownBackupIdException,
CommandFailedException,
)
from barman.fs import unix_command_factory
from barman.hooks import HookScriptRunner, RetryHookScriptRunner
from barman.infofile import BackupInfo, LocalBackupInfo, WalFileInfo
from barman.lockfile import ServerBackupIdLock, ServerBackupSyncLock
from barman.recovery_executor import recovery_executor_factory
from barman.remote_status import RemoteStatusMixin
from barman.storage.local_file_manager import LocalFileManager
from barman.utils import (
SHA256,
force_str,
fsync_dir,
fsync_file,
get_backup_info_from_name,
human_readable_timedelta,
pretty_size,
SHA256,
)
from barman.command_wrappers import PgVerifyBackup
from barman.storage.local_file_manager import LocalFileManager
from barman.backup_manifest import BackupManifest

_logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions barman/backup_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
import shutil
from abc import ABCMeta, abstractmethod
from contextlib import closing
from distutils.version import LooseVersion as Version
from functools import partial

import dateutil.parser
from distutils.version import LooseVersion as Version

from barman import output, xlog
from barman.cloud_providers import get_snapshot_interface_from_server_config
Expand All @@ -49,13 +49,13 @@
BackupException,
CommandFailedException,
DataTransferFailure,
FileNotFoundException,
FsOperationFailed,
PostgresConnectionError,
PostgresConnectionLost,
PostgresIsInRecovery,
SnapshotBackupException,
SshCommandException,
FileNotFoundException,
)
from barman.fs import UnixLocalCommand, UnixRemoteCommand, unix_command_factory
from barman.infofile import BackupInfo
Expand Down
2 changes: 1 addition & 1 deletion barman/backup_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with Barman. If not, see <http://www.gnu.org/licenses/>.

import os
import json
import os

from barman.exceptions import BackupManifestException

Expand Down
42 changes: 16 additions & 26 deletions barman/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,17 @@
import logging
import os
import sys
from argparse import (
SUPPRESS,
ArgumentTypeError,
ArgumentParser,
HelpFormatter,
)

from barman.lockfile import ConfigUpdateLock

if sys.version_info.major < 3:
from argparse import Action, _SubParsersAction, _ActionsContainer
try:
import argcomplete
except ImportError:
argcomplete = None
from argparse import SUPPRESS, ArgumentParser, ArgumentTypeError, HelpFormatter
from collections import OrderedDict
from contextlib import closing


import barman.config
import barman.diagnose
import barman.utils
from barman import output
from barman.annotations import KeepManager
from barman.config import (
ConfigChangesProcessor,
RecoveryOptions,
parse_staging_path,
)
from barman.backup_manifest import BackupManifest
from barman.config import ConfigChangesProcessor, RecoveryOptions, parse_staging_path
from barman.exceptions import (
BadXlogSegmentName,
LockFileBusy,
Expand All @@ -62,8 +44,12 @@
WalArchiveContentError,
)
from barman.infofile import BackupInfo, WalFileInfo
from barman.lockfile import ConfigUpdateLock
from barman.server import Server
from barman.storage.local_file_manager import LocalFileManager
from barman.utils import (
RESERVED_BACKUP_IDS,
SHA256,
BarmanEncoder,
check_backup_name,
check_non_negative,
Expand All @@ -72,15 +58,19 @@
configure_logging,
drop_privileges,
force_str,
get_log_levels,
get_backup_id_using_shortcut,
get_log_levels,
parse_log_level,
RESERVED_BACKUP_IDS,
SHA256,
)
from barman.xlog import check_archive_usable
from barman.backup_manifest import BackupManifest
from barman.storage.local_file_manager import LocalFileManager

if sys.version_info.major < 3:
from argparse import Action, _ActionsContainer, _SubParsersAction
try:
import argcomplete
except ImportError:
argcomplete = None


_logger = logging.getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions barman/clients/cloud_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
from shutil import rmtree

from barman.clients.cloud_cli import (
add_tag_argument,
create_argument_parser,
GeneralErrorExit,
NetworkErrorExit,
OperationErrorExit,
UrlArgumentType,
add_tag_argument,
create_argument_parser,
)
from barman.cloud import (
CloudBackupSnapshot,
CloudBackupUploaderBarman,
CloudBackupUploader,
CloudBackupUploaderBarman,
configure_logging,
)
from barman.cloud_providers import get_cloud_interface, get_snapshot_interface
Expand Down
4 changes: 2 additions & 2 deletions barman/clients/cloud_backup_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
from contextlib import closing
from operator import attrgetter

from barman import xlog
from barman.backup import BackupManager
from barman.clients.cloud_cli import (
create_argument_parser,
CLIErrorExit,
GeneralErrorExit,
NetworkErrorExit,
OperationErrorExit,
create_argument_parser,
)
from barman.cloud import CloudBackupCatalog, configure_logging
from barman.cloud_providers import (
Expand All @@ -37,7 +38,6 @@
from barman.exceptions import BadXlogPrefix, InvalidRetentionPolicy
from barman.retention_policies import RetentionPolicyFactory
from barman.utils import check_non_negative, force_str
from barman import xlog


def _get_files_for_backup(catalog, backup_info):
Expand Down
2 changes: 1 addition & 1 deletion barman/clients/cloud_backup_keep.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

from barman.annotations import KeepManager
from barman.clients.cloud_cli import (
create_argument_parser,
GeneralErrorExit,
NetworkErrorExit,
OperationErrorExit,
create_argument_parser,
)
from barman.cloud import CloudBackupCatalog, configure_logging
from barman.cloud_providers import get_cloud_interface
Expand Down
2 changes: 1 addition & 1 deletion barman/clients/cloud_backup_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
from contextlib import closing

from barman.clients.cloud_cli import (
create_argument_parser,
GeneralErrorExit,
NetworkErrorExit,
OperationErrorExit,
create_argument_parser,
)
from barman.cloud import CloudBackupCatalog, configure_logging
from barman.cloud_providers import get_cloud_interface
Expand Down
2 changes: 1 addition & 1 deletion barman/clients/cloud_backup_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
from contextlib import closing

from barman.clients.cloud_cli import (
create_argument_parser,
GeneralErrorExit,
NetworkErrorExit,
OperationErrorExit,
create_argument_parser,
)
from barman.cloud import CloudBackupCatalog, configure_logging
from barman.cloud_providers import get_cloud_interface
Expand Down
8 changes: 4 additions & 4 deletions barman/clients/cloud_check_wal_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
import logging

from barman.clients.cloud_cli import (
create_argument_parser,
GeneralErrorExit,
OperationErrorExit,
NetworkErrorExit,
OperationErrorExit,
UrlArgumentType,
create_argument_parser,
)
from barman.cloud import configure_logging, CloudBackupCatalog
from barman.cloud import CloudBackupCatalog, configure_logging
from barman.cloud_providers import get_cloud_interface
from barman.exceptions import WalArchiveContentError
from barman.utils import force_str, check_positive
from barman.utils import check_positive, force_str
from barman.xlog import check_archive_usable


Expand Down
1 change: 0 additions & 1 deletion barman/clients/cloud_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# along with Barman. If not, see <http://www.gnu.org/licenses/>.

import argparse

import csv
import logging

Expand Down
4 changes: 2 additions & 2 deletions barman/clients/cloud_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
#
# You should have received a copy of the GNU General Public License
# along with Barman. If not, see <http://www.gnu.org/licenses/>.
from abc import ABCMeta, abstractmethod
import logging
import os
from abc import ABCMeta, abstractmethod
from contextlib import closing

from barman.clients.cloud_cli import (
CLIErrorExit,
create_argument_parser,
GeneralErrorExit,
NetworkErrorExit,
OperationErrorExit,
create_argument_parser,
)
from barman.cloud import CloudBackupCatalog, configure_logging
from barman.cloud_providers import (
Expand Down
6 changes: 3 additions & 3 deletions barman/clients/cloud_walarchive.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
from contextlib import closing

from barman.clients.cloud_cli import (
add_tag_argument,
create_argument_parser,
CLIErrorExit,
GeneralErrorExit,
NetworkErrorExit,
UrlArgumentType,
add_tag_argument,
create_argument_parser,
)
from barman.cloud import configure_logging
from barman.clients.cloud_compression import compress
from barman.cloud import configure_logging
from barman.cloud_providers import get_cloud_interface
from barman.exceptions import BarmanException
from barman.utils import check_positive, check_size, force_str
Expand Down
4 changes: 2 additions & 2 deletions barman/clients/cloud_walrestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
from contextlib import closing

from barman.clients.cloud_cli import (
create_argument_parser,
CLIErrorExit,
GeneralErrorExit,
NetworkErrorExit,
OperationErrorExit,
create_argument_parser,
)
from barman.cloud import configure_logging, ALLOWED_COMPRESSIONS
from barman.cloud import ALLOWED_COMPRESSIONS, configure_logging
from barman.cloud_providers import get_cloud_interface
from barman.exceptions import BarmanException
from barman.utils import force_str
Expand Down
4 changes: 2 additions & 2 deletions barman/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@
from io import BytesIO, RawIOBase
from tempfile import NamedTemporaryFile

from barman import xlog
from barman.annotations import KeepManagerMixinCloud
from barman.backup_executor import ConcurrentBackupStrategy, SnapshotBackupExecutor
from barman.clients import cloud_compression
from barman.clients.cloud_cli import get_missing_attrs
from barman.exceptions import (
BackupException,
BackupPreconditionException,
BarmanException,
BackupException,
ConfigurationException,
)
from barman.fs import UnixLocalCommand, path_allowed
Expand All @@ -58,7 +59,6 @@
total_seconds,
with_metaclass,
)
from barman import xlog

try:
# Python 3.x
Expand Down
8 changes: 2 additions & 6 deletions barman/cloud_providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,15 +350,11 @@ def snapshots_info_from_dict(snapshots_info):

return GcpSnapshotsInfo.from_dict(snapshots_info)
elif "provider" in snapshots_info and snapshots_info["provider"] == "azure":
from barman.cloud_providers.azure_blob_storage import (
AzureSnapshotsInfo,
)
from barman.cloud_providers.azure_blob_storage import AzureSnapshotsInfo

return AzureSnapshotsInfo.from_dict(snapshots_info)
elif "provider" in snapshots_info and snapshots_info["provider"] == "aws":
from barman.cloud_providers.aws_s3 import (
AwsSnapshotsInfo,
)
from barman.cloud_providers.aws_s3 import AwsSnapshotsInfo

return AwsSnapshotsInfo.from_dict(snapshots_info)
else:
Expand Down
Loading

0 comments on commit d7a03e4

Please sign in to comment.