Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 2895 configure isort #217

Merged
merged 3 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Fixes spine-tools/Spine-Toolbox# (issue)
- [ ] Documentation (also in Toolbox repo) is up-to-date
- [ ] Release notes in Toolbox repo have been updated
- [ ] Unit tests have been added/updated accordingly
- [ ] Code has been formatted by black
- [ ] Code has been formatted by black & isort
- [ ] Unit tests pass
2 changes: 1 addition & 1 deletion bin/build_ui.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

import os.path
import argparse
import os.path
from append_license import append_license


Expand Down
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-whitelist=
extension-pkg-whitelist=PySide6

# Add files or directories to the blacklist. They should be base names, not
# paths.
Expand Down
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,12 @@ ignore_errors = true
[tool.black]
line-length = 120
exclude = '\.git|ui|resources_icons_rc.py|version.py'

[tool.isort]
profile = "black"
lines_between_sections = 0
force_sort_within_sections = true
honor_case_in_force_sorted_sections = true
skip_glob = ["spine_items/ui/*", "spine_items/*/ui/*", "spine_items/version.py"]
line_length = 120
known_first_party = ["spine_engine", "spinedb_api", "spinetoolbox"]
17 changes: 5 additions & 12 deletions spine_items/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,18 @@


def _factories_and_executable_items():
from . import data_connection
from . import data_connection, data_store, data_transformer, exporter, importer, merger, tool, view
from .data_connection.data_connection_factory import DataConnectionFactory
from . import data_store
from .data_store.data_store_factory import DataStoreFactory
from . import data_transformer
from .data_transformer.data_transformer_factory import DataTransformerFactory
from .data_transformer import specification_factory
from . import exporter
from .exporter.exporter_factory import ExporterFactory
from .data_transformer.data_transformer_factory import DataTransformerFactory
from .exporter import specification_factory
from . import importer
from .importer.importer_factory import ImporterFactory
from .exporter.exporter_factory import ExporterFactory
from .importer import specification_factory
from . import merger
from .importer.importer_factory import ImporterFactory
from .merger.merger_factory import MergerFactory
from . import tool
from .tool.tool_factory import ToolFactory
from .tool import specification_factory
from . import view
from .tool.tool_factory import ToolFactory
from .view.view_factory import ViewFactory

modules = (data_connection, data_store, data_transformer, exporter, importer, merger, tool, view)
Expand Down
4 changes: 2 additions & 2 deletions spine_items/animations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
######################################################################################################################

"""Animation class for importers and exporters."""
from PySide6.QtGui import QPainterPath, QFont, QFontMetrics
from PySide6.QtCore import Qt, Signal, Slot, QObject, QTimeLine, QRectF, QPointF, QLineF
from PySide6.QtCore import QLineF, QObject, QPointF, QRectF, Qt, QTimeLine, Signal, Slot
from PySide6.QtGui import QFont, QFontMetrics, QPainterPath
from PySide6.QtWidgets import QGraphicsPathItem
from spinetoolbox.helpers import color_from_index

Expand Down
20 changes: 10 additions & 10 deletions spine_items/data_connection/data_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@
######################################################################################################################

"""Module for data connection class."""
import logging
import os
import shutil
import logging
from PySide6.QtCore import Slot, Qt, QFileInfo, QModelIndex, QItemSelection, QTimer
from PySide6.QtGui import QStandardItem, QStandardItemModel, QBrush
from PySide6.QtWidgets import QFileDialog, QGraphicsItem, QFileIconProvider, QInputDialog, QMessageBox
from PySide6.QtCore import QFileInfo, QItemSelection, QModelIndex, Qt, QTimer, Slot
from PySide6.QtGui import QBrush, QStandardItem, QStandardItemModel
from PySide6.QtWidgets import QFileDialog, QFileIconProvider, QGraphicsItem, QInputDialog, QMessageBox
from spine_engine.utils.serialization import deserialize_path, serialize_path
from spinedb_api.helpers import remove_credentials_from_url
from spinetoolbox.config import INVALID_FILENAME_CHARS
from spinetoolbox.helpers import open_url, same_path
from spinetoolbox.project_item.project_item import ProjectItem
from spinetoolbox.widgets.custom_qwidgets import ToolBarWidget
from spinetoolbox.helpers import open_url, same_path
from spinetoolbox.config import INVALID_FILENAME_CHARS
from .commands import AddDCReferencesCommand, RemoveDCReferencesCommand, MoveReferenceToData
from ..database_validation import DatabaseConnectionValidator
from ..utils import convert_to_sqlalchemy_url, convert_url_to_safe_string
from ..widgets import UrlSelectorDialog
from .commands import AddDCReferencesCommand, MoveReferenceToData, RemoveDCReferencesCommand
from .custom_file_system_watcher import CustomFileSystemWatcher
from .executable_item import ExecutableItem
from .item_info import ItemInfo
from .output_resources import scan_for_resources
from .utils import restore_database_references
from ..database_validation import DatabaseConnectionValidator
from ..widgets import UrlSelectorDialog
from ..utils import convert_to_sqlalchemy_url, convert_url_to_safe_string


class _Role:
Expand Down
4 changes: 2 additions & 2 deletions spine_items/data_connection/data_connection_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"""The DataConnectionFactory class."""
from PySide6.QtGui import QColor
from spinetoolbox.project_item.project_item_factory import ProjectItemFactory
from .data_connection_icon import DataConnectionIcon
from .data_connection import DataConnection
from .widgets.data_connection_properties_widget import DataConnectionPropertiesWidget
from .data_connection_icon import DataConnectionIcon
from .widgets.add_data_connection_widget import AddDataConnectionWidget
from .widgets.data_connection_properties_widget import DataConnectionPropertiesWidget


class DataConnectionFactory(ProjectItemFactory):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

"""Data connection properties widget."""
import os
from PySide6.QtCore import QPoint, Qt, Slot, QUrl
from PySide6.QtCore import QPoint, Qt, QUrl, Slot
from spinetoolbox.widgets.properties_widget import PropertiesWidgetBase
from .custom_menus import DcRefContextMenu, DcDataContextMenu
from .custom_menus import DcDataContextMenu, DcRefContextMenu


class DataConnectionPropertiesWidget(PropertiesWidgetBase):
Expand Down
15 changes: 7 additions & 8 deletions spine_items/data_store/data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@
######################################################################################################################

""" Module for data store class. """
import os
from dataclasses import dataclass
import os
from shutil import copyfile
from PySide6.QtCore import Slot
from PySide6.QtWidgets import QFileDialog, QApplication, QMenu
from PySide6.QtGui import QAction
from PySide6.QtWidgets import QApplication, QFileDialog, QMenu
from spine_engine.project_item.project_item_resource import ProjectItemResource, database_resource
from spine_engine.utils.serialization import deserialize_path, serialize_path
from spinedb_api.helpers import remove_credentials_from_url, vacuum
from spine_engine.project_item.project_item_resource import database_resource, ProjectItemResource
from spinetoolbox.project_item.project_item import ProjectItem
from spinetoolbox.helpers import create_dir
from spinetoolbox.spine_db_editor.widgets.multi_spine_db_editor import MultiSpineDBEditor
from spine_engine.utils.serialization import serialize_path, deserialize_path
from spinetoolbox.project_item.project_item import ProjectItem
from spinetoolbox.widgets.custom_qwidgets import SelectDatabaseItemsDialog
from ..database_validation import DatabaseConnectionValidator
from ..utils import convert_to_sqlalchemy_url, database_label
from .commands import UpdateDSURLCommand
from .executable_item import ExecutableItem
from .item_info import ItemInfo
from .output_resources import scan_for_resources
from ..database_validation import DatabaseConnectionValidator
from ..utils import database_label, convert_to_sqlalchemy_url


@dataclass(frozen=True)
Expand Down
2 changes: 1 addition & 1 deletion spine_items/data_store/data_store_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from spinetoolbox.project_item.project_item_factory import ProjectItemFactory
from .data_store import DataStore
from .data_store_icon import DataStoreIcon
from .widgets.data_store_properties_widget import DataStorePropertiesWidget
from .widgets.add_data_store_widget import AddDataStoreWidget
from .widgets.data_store_properties_widget import DataStorePropertiesWidget


class DataStoreFactory(ProjectItemFactory):
Expand Down
6 changes: 3 additions & 3 deletions spine_items/data_store/executable_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

"""Contains Data Store's executable item as well as support utilities."""
from pathlib import Path
from spinedb_api import DatabaseMapping
from spinedb_api.exception import SpineDBAPIError
from spine_engine.project_item.executable_item_base import ExecutableItemBase
from spine_engine.utils.serialization import deserialize_path
from spinedb_api import DatabaseMapping
from spinedb_api.exception import SpineDBAPIError
from ..utils import check_database_url, convert_to_sqlalchemy_url
from .item_info import ItemInfo
from .output_resources import scan_for_resources
from ..utils import check_database_url, convert_to_sqlalchemy_url


class ExecutableItem(ExecutableItemBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
######################################################################################################################

"""Data store properties widget."""
from spinetoolbox.widgets.properties_widget import PropertiesWidgetBase
from spinedb_api import SUPPORTED_DIALECTS
from spinetoolbox.widgets.properties_widget import PropertiesWidgetBase
from ...widgets import UrlSelectorMixin


Expand Down
2 changes: 1 addition & 1 deletion spine_items/data_transformer/data_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
from PySide6.QtCore import Slot
from spinetoolbox.project_item.project_item import ProjectItem
from spinetoolbox.widgets.custom_menus import ItemSpecificationMenu
from .item_info import ItemInfo
from .executable_item import ExecutableItem
from .filter_config_path import filter_config_path
from .item_info import ItemInfo
from .output_resources import scan_for_resources


Expand Down
2 changes: 1 addition & 1 deletion spine_items/data_transformer/data_transformer_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
from spinetoolbox.widgets.custom_menus import ItemSpecificationMenu
from .data_transformer import DataTransformer
from .data_transformer_icon import DataTransformerIcon
from .widgets.add_data_transformer_widget import AddDataTransformerWidget
from .widgets.data_transformer_properties_widget import DataTransformerPropertiesWidget
from .widgets.specification_editor_window import SpecificationEditorWindow
from .widgets.add_data_transformer_widget import AddDataTransformerWidget


class DataTransformerFactory(ProjectItemFactory):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"""Contains :class:`ParameterRenamesTableModel`."""
from enum import IntEnum, unique
from PySide6.QtCore import QModelIndex, Qt
from .parameter_drop_target_table_model import ParameterDropTargetTableModel
from ..commands import SetData
from .parameter_drop_target_table_model import ParameterDropTargetTableModel


@unique
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"""Contains :class:`ValueTransformTableModel`."""
from enum import IntEnum, unique
from PySide6.QtCore import QModelIndex, Qt
from .parameter_drop_target_table_model import ParameterDropTargetTableModel
from ..commands import SetData
from .parameter_drop_target_table_model import ParameterDropTargetTableModel


@unique
Expand Down
2 changes: 1 addition & 1 deletion spine_items/data_transformer/output_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

"""Contains utilities to scan for Data Transformer's output resources."""
from spine_engine.project_item.project_item_resource import database_resource
from spine_items.utils import database_label
from spinedb_api import append_filter_config
from spinedb_api.filters.tools import store_filter
from spine_items.utils import database_label


def scan_for_resources(provider, dt_specification, db_resources, filter_config_path):
Expand Down
2 changes: 1 addition & 1 deletion spine_items/data_transformer/specification_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

"""Data transformer's specification factory."""
from spine_engine.project_item.project_item_specification_factory import ProjectItemSpecificationFactory
from .item_info import ItemInfo
from .data_transformer_specification import DataTransformerSpecification
from .item_info import ItemInfo


class SpecificationFactory(ProjectItemSpecificationFactory):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

"""Widget shown to user when a new Data transformer is created."""
from spinetoolbox.widgets.add_project_item_widget import AddProjectItemWidget
from ..item_info import ItemInfo
from ..data_transformer import DataTransformer
from ..item_info import ItemInfo


class AddDataTransformerWidget(AddProjectItemWidget):
Expand Down
4 changes: 2 additions & 2 deletions spine_items/data_transformer/widgets/class_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
######################################################################################################################

"""Contains classes to manage entity class renaming."""
from PySide6.QtCore import QObject, Qt, Slot, QSortFilterProxyModel
from ..commands import RemoveRow, InsertRow
from PySide6.QtCore import QObject, QSortFilterProxyModel, Qt, Slot
from ..commands import InsertRow, RemoveRow
from ..mvcmodels.class_renames_table_model import ClassRenamesTableModel
from ..settings import EntityClassRenamingSettings
from .copy_paste import copy_table_data, paste_table_data
Expand Down
2 changes: 1 addition & 1 deletion spine_items/data_transformer/widgets/class_tree_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""Contains :class:`ClassTreeWidget`."""
import pickle
from PySide6.QtCore import QMimeData
from PySide6.QtWidgets import QTreeWidget, QMessageBox, QTreeWidgetItem
from PySide6.QtWidgets import QMessageBox, QTreeWidget, QTreeWidgetItem

Check warning on line 16 in spine_items/data_transformer/widgets/class_tree_widget.py

View check run for this annotation

Codecov / codecov/patch

spine_items/data_transformer/widgets/class_tree_widget.py#L16

Added line #L16 was not covered by tests
from spinedb_api import DatabaseMapping, SpineDBAPIError
from .drop_target_table import DROP_MIME_TYPE

Expand Down
1 change: 0 additions & 1 deletion spine_items/data_transformer/widgets/drop_target_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QTableView


DROP_MIME_TYPE = "application/spine_items-dtdata"
"""Mime type for drag and drop actions."""

Expand Down
3 changes: 1 addition & 2 deletions spine_items/data_transformer/widgets/instructions_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@

"""Contains controller that manages value transformations editor."""
from PySide6.QtCore import QModelIndex, QObject, Slot
from PySide6.QtWidgets import QLineEdit, QFormLayout
from PySide6.QtWidgets import QFormLayout, QLineEdit
from ..commands import AppendInstruction, ChangeInstructionParameter, ChangeOperation, RemoveInstruction
from ..mvcmodels.value_transformations_table_model import TransformationsTableColumn, TransformationsTableRole


_DISPLAY_TEXT_TO_OPERATION = {
"multiply": "multiply",
"invert": "invert,",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""Contains :class:`ParameterTreeWidget`."""
import pickle
from PySide6.QtCore import QMimeData
from PySide6.QtWidgets import QTreeWidget, QMessageBox, QTreeWidgetItem
from PySide6.QtWidgets import QMessageBox, QTreeWidget, QTreeWidgetItem

Check warning on line 16 in spine_items/data_transformer/widgets/parameter_tree_widget.py

View check run for this annotation

Codecov / codecov/patch

spine_items/data_transformer/widgets/parameter_tree_widget.py#L16

Added line #L16 was not covered by tests
from spinedb_api import DatabaseMapping, SpineDBAPIError
from .drop_target_table import DROP_MIME_TYPE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@
"""Contains :class:`SpecificationEditorWindow`."""
from PySide6.QtCore import Qt, Slot
from PySide6.QtWidgets import QFileDialog, QHeaderView

from spinetoolbox.helpers import disconnect
from spinetoolbox.project_item.specification_editor_window import (
SpecificationEditorWindowBase,
ChangeSpecPropertyCommand,
SpecificationEditorWindowBase,
)
from ..data_transformer_specification import DataTransformerSpecification
from ..settings import EntityClassRenamingSettings, ParameterRenamingSettings, ValueTransformSettings
from .class_rename import ClassRename
from .parameter_rename import ParameterRename
from .value_transformation import ValueTransformation
from ..data_transformer_specification import DataTransformerSpecification
from ..settings import EntityClassRenamingSettings, ParameterRenamingSettings, ValueTransformSettings

_FILTER_NAMES = ("Rename entity classes", "Rename parameters", "Transform values")

Expand Down
4 changes: 2 additions & 2 deletions spine_items/data_transformer/widgets/value_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
from PySide6.QtCore import QObject, QSortFilterProxyModel, Qt, Slot
from ..commands import InsertRow, RemoveRow
from ..mvcmodels.value_transformations_table_model import (
ValueTransformationsTableModel,
TransformationsTableColumn,
TransformationsTableRole,
ValueTransformationsTableModel,
)
from ..settings import ValueTransformSettings
from .copy_paste import copy_table_data, paste_table_data
from .instructions_editor import InstructionsEditor
from ..settings import ValueTransformSettings


class ValueTransformation(QObject):
Expand Down
3 changes: 1 addition & 2 deletions spine_items/exporter/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
"""Contains Exporter's undo commands."""
from copy import copy, deepcopy
from enum import IntEnum, unique
from PySide6.QtCore import QModelIndex, Qt
from PySide6.QtCore import QModelIndex, Qt # pylint: disable=unused-import
from PySide6.QtGui import QUndoCommand

from spinetoolbox.helpers import SealCommand
from spinetoolbox.project_commands import SpineToolboxCommand
from .mvcmodels.mappings_table_model import MappingsTableModel
Expand Down
Loading