From 38e9d7c5bbcff760ffa5d5457782d5de0d04f8fc Mon Sep 17 00:00:00 2001 From: Rafael Irgolic Date: Thu, 5 Aug 2021 01:58:53 +0100 Subject: [PATCH] pylint --- Orange/widgets/data/owcsvimport.py | 32 +++++++++++++++--------------- Orange/widgets/utils/textimport.py | 6 ++---- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Orange/widgets/data/owcsvimport.py b/Orange/widgets/data/owcsvimport.py index adcd1982328..ab5e9a841f7 100644 --- a/Orange/widgets/data/owcsvimport.py +++ b/Orange/widgets/data/owcsvimport.py @@ -20,9 +20,6 @@ import lzma import bz2 import zipfile - -from Orange.widgets.settings import PerfectDomainContextHandler -from Orange.widgets.utils.itemdelegates import TableDataDelegate from itertools import chain from xml.sax.saxutils import escape @@ -39,10 +36,10 @@ Qt, QFileInfo, QTimer, QSettings, QObject, QSize, QMimeDatabase, QMimeType ) from AnyQt.QtGui import ( - QStandardItem, QStandardItemModel, QPalette, QColor, QIcon, QTextOption + QStandardItem, QStandardItemModel, QPalette, QColor, QIcon, ) from AnyQt.QtWidgets import ( - QLabel, QComboBox, QPushButton, QDialog, QDialogButtonBox, QGridLayout, + QLabel, QComboBox, QPushButton, QDialog, QDialogButtonBox, QVBoxLayout, QSizePolicy, QFileIconProvider, QFileDialog, QApplication, QMessageBox, QTextBrowser, QStyle, QMenu, QHBoxLayout, QTableView, QHeaderView @@ -55,12 +52,18 @@ from pandas.api import types as pdtypes +from orangewidget.settings import Setting, SettingProvider, widget_settings_dir + import Orange.data from Orange.data import Table, ContinuousVariable, StringVariable from Orange.misc.collections import natural_sorted -from Orange.widgets import widget, gui, settings +from Orange.widgets import widget, gui from Orange.widgets.data.owtable import DataTableView, RichTableModel, is_sortable, TableSliceProxy +from Orange.widgets.settings import PerfectDomainContextHandler +from Orange.widgets.utils.settings import ( + QSettings_readArray, QSettings_writeArray +) from Orange.widgets.utils.concurrent import PyOwned from Orange.widgets.utils import ( textimport, concurrent as qconcurrent, unique_everseen, enum_get, qname @@ -71,10 +74,7 @@ PathItem, VarPath, AbsPath, samepath, prettyfypath, isprefixed, ) from Orange.widgets.utils.overlay import OverlayWidget -from Orange.widgets.utils.settings import ( - QSettings_readArray, QSettings_writeArray -) -from orangewidget.settings import Setting, ContextSetting, SettingProvider +from Orange.widgets.utils.itemdelegates import TableDataDelegate if typing.TYPE_CHECKING: # pylint: disable=invalid-name @@ -658,13 +658,13 @@ class Warning(widget.OWWidget.Warning): 'the Import Options to avoid this.') #: Paths and options of files accessed in a 'session' - _session_items = settings.Setting( + _session_items = Setting( [], schema_only=True) # type: List[Tuple[str, dict]] - _session_items_v2 = settings.Setting( + _session_items_v2 = Setting( [], schema_only=True) # type: List[Tuple[Dict[str, str], dict]] #: Saved dialog state (last directory and selected filter) - dialog_state = settings.Setting({ + dialog_state = Setting({ "directory": "", "filter": "" }) # type: Dict[str, str] @@ -678,7 +678,7 @@ class Warning(widget.OWWidget.Warning): # with older saved workflows, where types not guessed differently, when # compatibility_mode=True widget have older guessing behaviour settings_version = 3 - compatibility_mode = settings.Setting(False, schema_only=True) + compatibility_mode = Setting(False, schema_only=True) MaxHistorySize = 50 @@ -968,7 +968,7 @@ def _path_must_be_relative_mb(self, prefix: str) -> QMessageBox: return mb @Slot() - def browse(self, prefixname=None, directory=None): + def browse(self): """ Open a file dialog and select a user specified file. """ @@ -1089,7 +1089,7 @@ def _local_settings(cls): # type: () -> QSettings """Return a QSettings instance with local persistent settings.""" filename = "{}.ini".format(qname(cls)) - fname = os.path.join(settings.widget_settings_dir(), filename) + fname = os.path.join(widget_settings_dir(), filename) return QSettings(fname, QSettings.IniFormat) def _add_recent(self, filename, options=None): diff --git a/Orange/widgets/utils/textimport.py b/Orange/widgets/utils/textimport.py index 9e42cbf8f42..a4d0ab0a52c 100644 --- a/Orange/widgets/utils/textimport.py +++ b/Orange/widgets/utils/textimport.py @@ -37,7 +37,7 @@ ) from AnyQt.QtCore import ( - Qt, QSize, QPoint, QRect, QRectF, QRegularExpression, QAbstractTableModel, + Qt, QSize, QRect, QRectF, QRegularExpression, QAbstractTableModel, QModelIndex, QItemSelectionModel, QTextBoundaryFinder, QTimer, QEvent ) from AnyQt.QtCore import pyqtSignal as Signal, pyqtSlot as Slot @@ -1123,7 +1123,6 @@ def __generate_type_columns_menu(self, columns, menu=None): current = None cb = self.column_type_edit_cb g = QActionGroup(menu) - current_action = None # 'Copy' the column types model into a menu for i in range(cb.count()): if cb.itemData(i, Qt.AccessibleDescriptionRole) == "separator": @@ -1135,7 +1134,6 @@ def __generate_type_columns_menu(self, columns, menu=None): ac.setCheckable(True) if ac.data() == current: ac.setChecked(True) - current_action = ac g.addAction(ac) def update_types(action): @@ -1736,7 +1734,7 @@ def format_exception_csv(err): def parse_datetime(text): global _to_datetime if _to_datetime is None: - from pandas import to_datetime as _to_datetime + from pandas import to_datetime as _to_datetime # pylint: disable=redefined-outer-name return _to_datetime(text)