1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-21 23:33:13 +00:00

Run pre-commit (with newly added ruff) on code base.

Includes all changes by `pre-commit --all-files` including the changes introduced by ruff.
This commit is contained in:
real-yfprojects 2023-05-01 10:28:11 +02:00
parent f0a5a36275
commit 24e1dd5c56
No known key found for this signature in database
GPG key ID: 00F630DFDEE25747
80 changed files with 256 additions and 50 deletions

View file

@ -7,4 +7,3 @@ source_file = src/vorta/i18n/ts/vorta.en.ts
source_lang = en
type = QT
minimum_perc = 80

View file

@ -1,7 +1,9 @@
import os
import signal
import sys
from peewee import SqliteDatabase
from vorta._version import __version__
from vorta.config import SETTINGS_DIR
from vorta.i18n import trans_late, translate
@ -14,6 +16,7 @@
def main():
def exception_handler(type, value, tb):
from traceback import format_exception
from PyQt6.QtWidgets import QMessageBox
logger.critical(

View file

@ -3,8 +3,10 @@
import sys
from pathlib import Path
from typing import Any, Dict, List, Tuple
from PyQt6 import QtCore
from PyQt6.QtWidgets import QMessageBox
from vorta.borg.break_lock import BorgBreakJob
from vorta.borg.create import BorgCreateJob
from vorta.borg.jobs_manager import JobsManager

View file

@ -50,6 +50,7 @@ def open_app_at_startup(enabled=True):
elif sys.platform.startswith('linux'):
from pathlib import Path
from platformdirs import user_config_path
is_flatpak = Path('/.flatpak-info').exists()

View file

@ -11,8 +11,10 @@
from datetime import datetime as dt
from subprocess import PIPE, Popen, TimeoutExpired
from threading import Lock
from PyQt6 import QtCore
from PyQt6.QtWidgets import QApplication
from vorta import application
from vorta.borg.jobs_manager import JobInterface
from vorta.i18n import trans_late, translate

View file

@ -1,7 +1,9 @@
from typing import Any, Dict
from vorta.config import LOG_DIR
from vorta.i18n import translate
from vorta.utils import borg_compat
from .borg_job import BorgJob

View file

@ -1,7 +1,9 @@
from typing import Any, Dict
from vorta.config import LOG_DIR
from vorta.i18n import trans_late, translate
from vorta.utils import borg_compat
from .borg_job import BorgJob

View file

@ -2,10 +2,17 @@
import subprocess
import tempfile
from datetime import datetime as dt
from vorta.config import LOG_DIR
from vorta.i18n import trans_late, translate
from vorta.store.models import ArchiveModel, RepoModel, SourceFileModel, WifiSettingModel
from vorta.store.models import (
ArchiveModel,
RepoModel,
SourceFileModel,
WifiSettingModel,
)
from vorta.utils import borg_compat, format_archive_name, get_network_status_monitor
from .borg_job import BorgJob

View file

@ -1,6 +1,8 @@
from typing import List
from vorta.store.models import RepoModel
from vorta.utils import borg_compat
from .borg_job import BorgJob

View file

@ -1,4 +1,5 @@
from vorta.utils import borg_compat
from .borg_job import BorgJob

View file

@ -1,8 +1,11 @@
import tempfile
from PyQt6.QtCore import QModelIndex, Qt
from vorta.utils import borg_compat
from vorta.views.extract_dialog import ExtractTree, FileData
from vorta.views.partials.treemodel import FileSystemItem, path_to_str
from .borg_job import BorgJob

View file

@ -1,5 +1,6 @@
from vorta.store.models import ArchiveModel, RepoModel
from vorta.utils import borg_compat
from .borg_job import BorgJob

View file

@ -1,6 +1,7 @@
from vorta.i18n import trans_late
from vorta.store.models import RepoModel
from vorta.utils import borg_compat
from .borg_job import BorgJob, FakeProfile, FakeRepo

View file

@ -1,5 +1,6 @@
from vorta.store.models import RepoModel
from vorta.utils import borg_compat
from .borg_job import BorgJob, FakeProfile, FakeRepo

View file

@ -2,6 +2,7 @@
import queue
import threading
from abc import abstractmethod
from PyQt6.QtCore import QObject
logger = logging.getLogger(__name__)

View file

@ -1,4 +1,5 @@
from vorta.utils import borg_compat
from .borg_job import BorgJob

View file

@ -1,6 +1,8 @@
from datetime import datetime as dt
from vorta.store.models import ArchiveModel, RepoModel
from vorta.utils import borg_compat
from .borg_job import BorgJob

View file

@ -1,7 +1,9 @@
import logging
import os
from vorta.store.models import SettingsModel
from vorta.utils import SHELL_PATTERN_ELEMENT, borg_compat
from .borg_job import BorgJob
logger = logging.getLogger(__name__)

View file

@ -1,5 +1,6 @@
from vorta.store.models import RepoModel
from vorta.utils import borg_compat, format_archive_name
from .borg_job import BorgJob

View file

@ -1,5 +1,6 @@
from vorta.store.models import ArchiveModel, RepoModel
from vorta.utils import borg_compat
from .borg_job import BorgJob

View file

@ -1,5 +1,7 @@
import os.path
import psutil
from ..i18n import trans_late
from .borg_job import BorgJob

View file

@ -1,4 +1,5 @@
from vorta.i18n import trans_late
from .borg_job import BorgJob

View file

@ -1,4 +1,5 @@
from pathlib import Path
import platformdirs
APP_NAME = 'Vorta'

View file

@ -3,6 +3,7 @@
"""
import logging
import os
from PyQt6.QtCore import QLocale, QTranslator
logger = logging.getLogger(__name__)

View file

@ -1,5 +1,6 @@
import importlib
import logging
from vorta.i18n import trans_late
logger = logging.getLogger(__name__)

View file

@ -1,6 +1,9 @@
import logging
import peewee
from vorta.store.models import SettingsModel
from .abc import VortaKeyring
logger = logging.getLogger(__name__)

View file

@ -1,7 +1,9 @@
import logging
import os
from PyQt6 import QtDBus
from PyQt6.QtCore import QMetaType, QVariant
from vorta.keyring.abc import VortaKeyring
logger = logging.getLogger(__name__)

View file

@ -1,7 +1,9 @@
import asyncio
import logging
import os
import secretstorage
from vorta.keyring.abc import VortaKeyring
logger = logging.getLogger(__name__)

View file

@ -8,6 +8,7 @@
import logging
from logging.handlers import TimedRotatingFileHandler
from .config import LOG_DIR
logger = logging.getLogger()

View file

@ -11,7 +11,11 @@ def get_network_status_monitor(cls) -> 'NetworkStatusMonitor':
return DarwinNetworkStatus()
else:
from .network_manager import DBusException, NetworkManagerMonitor, UnsupportedException
from .network_manager import (
DBusException,
NetworkManagerMonitor,
UnsupportedException,
)
try:
return NetworkManagerMonitor()

View file

@ -1,6 +1,7 @@
import subprocess
from datetime import datetime as dt
from typing import Iterator, Optional
from vorta.log import logger
from vorta.network_status.abc import NetworkStatusMonitor, SystemWifiInfo

View file

@ -2,8 +2,10 @@
from datetime import datetime
from enum import Enum
from typing import Any, List, Mapping, NamedTuple, Optional
from PyQt6 import QtDBus
from PyQt6.QtCore import QObject, QVersionNumber
from vorta.network_status.abc import NetworkStatusMonitor, SystemWifiInfo
logger = logging.getLogger(__name__)

View file

@ -1,6 +1,8 @@
import logging
import sys
from PyQt6 import QtCore, QtDBus
from vorta.store.models import SettingsModel
try:

View file

@ -1,7 +1,9 @@
import datetime
import json
from json import JSONDecodeError
from playhouse.shortcuts import dict_to_model, model_to_dict
from vorta.keyring.abc import VortaKeyring
from vorta.store.connection import DB, SCHEMA_VERSION, init_db
from vorta.store.models import (

View file

@ -4,9 +4,11 @@
from datetime import datetime as dt
from datetime import timedelta
from typing import Dict, NamedTuple, Optional, Tuple, Union
from PyQt6 import QtCore, QtDBus
from PyQt6.QtCore import QTimer
from PyQt6.QtWidgets import QApplication
from vorta import application
from vorta.borg.check import BorgCheckJob
from vorta.borg.create import BorgCreateJob

View file

@ -1,8 +1,11 @@
import os
from datetime import datetime, timedelta
from peewee import Tuple, fn
from playhouse import signals
from vorta.autostart import open_app_at_startup
from .migrations import run_migrations
from .models import (
DB,

View file

@ -1,6 +1,8 @@
from datetime import datetime
import peewee as pw
from playhouse.migrate import SqliteMigrator, migrate
from .models import (
DB,
ArchiveModel,

View file

@ -6,8 +6,10 @@
import json
from datetime import datetime
import peewee as pw
from playhouse import signals
from vorta.utils import slugify
DB = pw.Proxy()

View file

@ -1,5 +1,6 @@
import sys
from typing import Dict, List
from vorta.i18n import trans_late

View file

@ -1,6 +1,8 @@
import os
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import QApplication, QMenu, QSystemTrayIcon
from vorta.store.models import BackupProfileModel
from vorta.utils import get_asset

View file

@ -1,5 +1,6 @@
import os
import sys
from vorta.store.models import SettingsModel

View file

@ -11,10 +11,12 @@
from datetime import datetime as dt
from functools import reduce
from typing import Any, Callable, Iterable, List, Optional, Tuple, TypeVar
import psutil
from PyQt6 import QtCore
from PyQt6.QtCore import QFileInfo, QThread, pyqtSignal
from PyQt6.QtWidgets import QApplication, QFileDialog, QSystemTrayIcon
from vorta.borg._compatibility import BorgCompatibility
from vorta.i18n import trans_late
from vorta.log import logger

View file

@ -2,6 +2,7 @@
import sys
from datetime import timedelta
from typing import Dict, Optional
from PyQt6 import QtCore, uic
from PyQt6.QtCore import QItemSelectionModel, QMimeData, QPoint, Qt, pyqtSlot
from PyQt6.QtGui import QAction, QDesktopServices, QKeySequence, QShortcut
@ -17,6 +18,7 @@
QTableWidgetItem,
QWidget,
)
from vorta.borg.check import BorgCheckJob
from vorta.borg.compact import BorgCompactJob
from vorta.borg.delete import BorgDeleteJob

View file

@ -5,10 +5,21 @@
from dataclasses import dataclass
from pathlib import PurePath
from typing import List, Optional, Tuple
from PyQt6 import uic
from PyQt6.QtCore import QDateTime, QLocale, QMimeData, QModelIndex, QPoint, Qt, QThread, QUrl
from PyQt6.QtCore import (
QDateTime,
QLocale,
QMimeData,
QModelIndex,
QPoint,
Qt,
QThread,
QUrl,
)
from PyQt6.QtGui import QColor, QKeySequence, QShortcut
from PyQt6.QtWidgets import QApplication, QHeaderView, QMenu, QTreeView
from vorta.store.models import SettingsModel
from vorta.utils import get_asset, pretty_bytes, uses_dark_mode
from vorta.views.partials.treemodel import (

View file

@ -1,12 +1,15 @@
import logging
import os
from pathlib import Path
from PyQt6 import uic
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QFileDialog, QMessageBox
from vorta.keyring.abc import VortaKeyring
from vorta.store.models import BackupProfileModel # noqa: F401
from vorta.utils import get_asset
from ..notifications import VortaNotifications
from ..profile_export import ProfileExport

View file

@ -5,14 +5,38 @@
from datetime import datetime
from pathlib import PurePath
from typing import Optional, Union
from PyQt6 import uic
from PyQt6.QtCore import QDateTime, QLocale, QMimeData, QModelIndex, QPoint, Qt, QThread, QUrl
from PyQt6.QtCore import (
QDateTime,
QLocale,
QMimeData,
QModelIndex,
QPoint,
Qt,
QThread,
QUrl,
)
from PyQt6.QtGui import QColor, QKeySequence, QShortcut
from PyQt6.QtWidgets import QApplication, QDialogButtonBox, QHeaderView, QMenu, QPushButton
from PyQt6.QtWidgets import (
QApplication,
QDialogButtonBox,
QHeaderView,
QMenu,
QPushButton,
)
from vorta.store.models import SettingsModel
from vorta.utils import borg_compat, get_asset, pretty_bytes, uses_dark_mode
from vorta.views.utils import get_colored_icon
from .partials.treemodel import FileSystemItem, FileTreeModel, FileTreeSortProxyModel, path_to_str, relative_path
from .partials.treemodel import (
FileSystemItem,
FileTreeModel,
FileTreeSortProxyModel,
path_to_str,
relative_path,
)
uifile = get_asset("UI/extractdialog.ui")
ExtractDialogUI, ExtractDialogBase = uic.loadUiType(uifile)

View file

@ -1,5 +1,6 @@
from PyQt6 import QtCore
from PyQt6.QtWidgets import QMessageBox
from vorta.keyring.abc import VortaKeyring
from vorta.profile_export import VersionException
from vorta.store.connection import SCHEMA_VERSION

View file

@ -1,14 +1,29 @@
import logging
from pathlib import Path
from PyQt6 import QtCore, uic
from PyQt6.QtCore import QPoint
from PyQt6.QtGui import QFontMetrics, QKeySequence, QShortcut
from PyQt6.QtWidgets import QApplication, QCheckBox, QFileDialog, QMenu, QMessageBox, QToolTip
from PyQt6.QtWidgets import (
QApplication,
QCheckBox,
QFileDialog,
QMenu,
QMessageBox,
QToolTip,
)
from vorta.profile_export import ImportFailedException, ProfileExport
from vorta.store.models import BackupProfileModel, SettingsModel
from vorta.utils import borg_compat, get_asset, get_network_status_monitor, is_system_tray_available
from vorta.utils import (
borg_compat,
get_asset,
get_network_status_monitor,
is_system_tray_available,
)
from vorta.views.partials.loading_button import LoadingButton
from vorta.views.utils import get_colored_icon
from .archive_tab import ArchiveTab
from .export_window import ExportWindow
from .import_window import ImportWindow

View file

@ -1,7 +1,17 @@
import logging
from PyQt6 import uic
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QApplication, QCheckBox, QFormLayout, QHBoxLayout, QLabel, QSizePolicy, QSpacerItem
from PyQt6.QtWidgets import (
QApplication,
QCheckBox,
QFormLayout,
QHBoxLayout,
QLabel,
QSizePolicy,
QSpacerItem,
)
from vorta._version import __version__
from vorta.config import LOG_DIR
from vorta.i18n import translate

View file

@ -1,4 +1,5 @@
from typing import Optional
from PyQt6.QtCore import QCoreApplication, QEvent, QSize, Qt
from PyQt6.QtGui import QHelpEvent, QIcon, QMouseEvent, QPaintEvent
from PyQt6.QtWidgets import QSizePolicy, QStyle, QStylePainter, QToolTip, QWidget

View file

@ -9,7 +9,15 @@
from functools import reduce
from pathlib import PurePath
from typing import Generic, List, Optional, Sequence, Tuple, TypeVar, Union, overload
from PyQt6.QtCore import QAbstractItemModel, QModelIndex, QObject, QSortFilterProxyModel, Qt, pyqtSignal
from PyQt6.QtCore import (
QAbstractItemModel,
QModelIndex,
QObject,
QSortFilterProxyModel,
Qt,
pyqtSignal,
)
#: A representation of a path
Path = Tuple[str, ...]

View file

@ -1,5 +1,6 @@
from PyQt6 import QtCore, uic
from PyQt6.QtWidgets import QDialogButtonBox
from vorta.i18n import trans_late, translate
from vorta.store.models import BackupProfileModel
from vorta.utils import get_asset

View file

@ -1,13 +1,21 @@
import re
from PyQt6 import QtCore, uic
from PyQt6.QtGui import QAction
from PyQt6.QtWidgets import QApplication, QDialogButtonBox, QLineEdit
from vorta.borg.info_repo import BorgInfoRepoJob
from vorta.borg.init import BorgInitJob
from vorta.i18n import translate
from vorta.keyring.abc import VortaKeyring
from vorta.store.models import RepoModel
from vorta.utils import borg_compat, choose_file_dialog, get_asset, get_private_keys, validate_passwords
from vorta.utils import (
borg_compat,
choose_file_dialog,
get_asset,
get_private_keys,
validate_passwords,
)
from vorta.views.utils import get_colored_icon
uifile = get_asset('UI/repoadd.ui')

View file

@ -1,10 +1,13 @@
import os
from pathlib import PurePath
from PyQt6 import QtCore, uic
from PyQt6.QtCore import QMimeData, QUrl
from PyQt6.QtWidgets import QApplication, QLayout, QMenu, QMessageBox
from vorta.store.models import ArchiveModel, BackupProfileMixin, RepoModel
from vorta.utils import borg_compat, get_asset, get_private_keys, pretty_bytes
from .repo_add_dialog import AddRepoWindow, ExistingRepoWindow
from .ssh_dialog import SSHAddWindow
from .utils import get_colored_icon

View file

@ -1,6 +1,13 @@
from PyQt6 import QtCore, uic
from PyQt6.QtCore import QDateTime, QLocale
from PyQt6.QtWidgets import QAbstractItemView, QApplication, QHeaderView, QListWidgetItem, QTableWidgetItem
from PyQt6.QtWidgets import (
QAbstractItemView,
QApplication,
QHeaderView,
QListWidgetItem,
QTableWidgetItem,
)
from vorta import application
from vorta.i18n import get_locale
from vorta.scheduler import ScheduleStatusType

View file

@ -1,12 +1,26 @@
import logging
import os
from pathlib import PurePath
from PyQt6 import QtCore, QtGui, uic
from PyQt6.QtCore import QFileInfo, QMimeData, QPoint, Qt, QUrl, pyqtSlot
from PyQt6.QtGui import QShortcut
from PyQt6.QtWidgets import QApplication, QHeaderView, QMenu, QMessageBox, QTableWidgetItem
from PyQt6.QtWidgets import (
QApplication,
QHeaderView,
QMenu,
QMessageBox,
QTableWidgetItem,
)
from vorta.store.models import BackupProfileMixin, SettingsModel, SourceFileModel
from vorta.utils import FilePathInfoAsync, choose_file_dialog, get_asset, pretty_bytes, sort_sizes
from vorta.utils import (
FilePathInfoAsync,
choose_file_dialog,
get_asset,
pretty_bytes,
sort_sizes,
)
from vorta.views.utils import get_colored_icon
uifile = get_asset('UI/sourcetab.ui')

View file

@ -1,7 +1,9 @@
import os
from PyQt6 import uic
from PyQt6.QtCore import QProcess, Qt
from PyQt6.QtWidgets import QApplication, QDialogButtonBox
from ..utils import get_asset
uifile = get_asset('UI/sshadd.ui')

View file

@ -1,4 +1,5 @@
from PyQt6.QtGui import QIcon, QImage, QPixmap
from vorta.utils import get_asset, uses_dark_mode

View file

@ -1,5 +1,6 @@
import os
import sys
import vorta._version
resource_file = os.path.join(os.path.dirname(vorta._version.__file__), 'assets/icons')

View file

@ -2,11 +2,12 @@
import sys
from datetime import datetime as dt
from unittest.mock import MagicMock
import pytest
from peewee import SqliteDatabase
import vorta
import vorta.application
import vorta.borg.jobs_manager
from peewee import SqliteDatabase
from vorta.store.models import (
ArchiveModel,
BackupProfileModel,

View file

@ -1,5 +1,6 @@
from datetime import datetime
from unittest.mock import MagicMock
import pytest
from vorta.network_status.abc import SystemWifiInfo
from vorta.network_status.network_manager import (

View file

@ -1,10 +1,11 @@
from collections import namedtuple
import psutil
import pytest
from PyQt6 import QtCore
import vorta.borg
import vorta.utils
import vorta.views.archive_tab
from PyQt6 import QtCore
from vorta.store.models import ArchiveModel, BackupProfileModel

View file

@ -1,10 +1,18 @@
from pathlib import PurePath
import pytest
from PyQt6.QtCore import QDateTime, QItemSelectionModel, Qt
import vorta.borg
import vorta.utils
import vorta.views.archive_tab
from vorta.views.diff_result import ChangeType, DiffData, DiffTree, FileType, parse_diff_json, parse_diff_lines
from PyQt6.QtCore import QDateTime, QItemSelectionModel, Qt
from vorta.views.diff_result import (
ChangeType,
DiffData,
DiffTree,
FileType,
parse_diff_json,
parse_diff_lines,
)
@pytest.mark.parametrize(

View file

@ -1,5 +1,5 @@
from PyQt6.QtCore import QModelIndex, Qt
import vorta.borg
from PyQt6.QtCore import QModelIndex, Qt
from vorta.views.extract_dialog import ExtractTree, FileData, FileType, parse_json_lines
from vorta.views.partials.treemodel import FileSystemItem

View file

@ -1,5 +1,6 @@
import os
from pathlib import Path
import pytest
from PyQt6 import QtCore
from PyQt6.QtWidgets import QDialogButtonBox, QFileDialog, QMessageBox

View file

@ -1,7 +1,7 @@
import pytest
from PyQt6 import QtCore
import vorta.application
import vorta.borg.borg_job
from PyQt6 import QtCore
def test_create_perm_error(qapp, borg_json_output, mocker, qtbot):

View file

@ -2,10 +2,11 @@
import sys
from pathlib import Path
from unittest.mock import Mock
import pytest
import vorta.store.models
from PyQt6 import QtCore
from PyQt6.QtWidgets import QCheckBox, QFormLayout
import vorta.store.models
def test_autostart(qapp, qtbot):

View file

@ -1,8 +1,9 @@
import sys
import pytest
from PyQt6 import QtDBus
import vorta.borg
import vorta.notifications
from PyQt6 import QtDBus
@pytest.mark.skipif(sys.platform != 'linux', reason="DBus notifications only on Linux")

View file

@ -1,9 +1,10 @@
import os
import uuid
import pytest
import vorta.borg.borg_job
from PyQt6 import QtCore
from PyQt6.QtWidgets import QMessageBox
import vorta.borg.borg_job
from vorta.keyring.abc import VortaKeyring
from vorta.store.models import ArchiveModel, EventLogModel, RepoModel

View file

@ -1,9 +1,10 @@
from datetime import datetime as dt
from datetime import timedelta
from unittest.mock import MagicMock
import pytest
from PyQt6 import QtCore
import vorta.scheduler
from PyQt6 import QtCore
from vorta.application import VortaApp
from vorta.store.models import BackupProfileModel, EventLogModel

View file

@ -2,10 +2,11 @@
from datetime import timedelta as td
from functools import wraps
from unittest.mock import MagicMock
import pytest
from pytest import mark
import vorta.borg
import vorta.scheduler
from pytest import mark
from vorta.scheduler import ScheduleStatus, ScheduleStatusType, VortaScheduler
from vorta.store.models import BackupProfileModel, EventLogModel

View file

@ -1,4 +1,5 @@
from pathlib import PurePath
import pytest
from PyQt6.QtCore import QModelIndex
from vorta.views.partials.treemodel import FileSystemItem, FileTreeModel

View file

@ -1,4 +1,5 @@
import uuid
from vorta.keyring.abc import VortaKeyring
from vorta.utils import find_best_unit_for_sizes, pretty_bytes