Skip to content

Commit

Permalink
pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Jan 19, 2025
1 parent c77b094 commit 04e615f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Orange/widgets/data/owfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
QStyle, QComboBox, QMessageBox, QGridLayout, QLabel, \
QLineEdit, QSizePolicy as Policy, QCompleter
from AnyQt.QtCore import Qt, QTimer, QSize, QUrl
from AnyQt.QtGui import QBrush

from orangewidget.utils.filedialogs import format_filter
from orangewidget.workflow.drophandler import SingleUrlDropHandler
Expand Down Expand Up @@ -327,6 +326,7 @@ def select_file(self, n):
self.set_file_list()

def select_sheet(self):
# pylint: disable=unsubscriptable-object
self.recent_paths[0].sheet = self.sheet_combo.currentText()
self.load_data()

Expand All @@ -339,7 +339,7 @@ def select_reader(self, n):
return # ignore for URL's

if self.recent_paths:
path = self.recent_paths[0]
path = self.recent_paths[0] # pylint: disable=unsubscriptable-object
if n == 0: # default
path.file_format = None
elif n <= len(self.available_readers):
Expand Down Expand Up @@ -384,6 +384,7 @@ def browse_file(self, in_demos=False):
return
self.add_path(filename)
if reader is not None:
# pylint: disable=unsubscriptable-object
self.recent_paths[0].file_format = reader.qualified_name()

self.source = self.LOCAL_FILE
Expand Down Expand Up @@ -480,6 +481,7 @@ def _get_reader(self) -> FileFormat:
self.reader_combo.setEnabled(True)

if self.recent_paths and self.recent_paths[0].file_format:
# pylint: disable=unsubscriptable-object
qname = self.recent_paths[0].file_format
qname_index = {r.qualified_name(): i for i, r in enumerate(self.available_readers)}
if qname in qname_index:
Expand Down Expand Up @@ -508,6 +510,7 @@ def _get_reader(self) -> FileFormat:
self.select_reader(old_idx)
return self._get_reader()

# pylint: disable=unsubscriptable-object
if self.recent_paths and self.recent_paths[0].sheet:
reader.select_sheet(self.recent_paths[0].sheet)
return reader
Expand Down Expand Up @@ -597,6 +600,7 @@ def _describe(table):
return text

def storeSpecificSettings(self):
# pylint: disable=unsubscriptable-object
self.current_context.modified_variables = self.variables[:]

def retrieveSpecificSettings(self):
Expand Down
10 changes: 7 additions & 3 deletions Orange/widgets/data/tests/test_owfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Test methods with long descriptive names can omit docstrings
# pylint: disable=missing-docstring,protected-access
# pylint: disable=missing-docstring,protected-access,too-many-public-methods
from os import path, remove, getcwd
from os.path import dirname
import unittest
Expand All @@ -23,7 +23,7 @@
Domain, DiscreteVariable, ContinuousVariable
from Orange.util import OrangeDeprecationWarning

from Orange.data.io import TabReader, XlsReader
from Orange.data.io import TabReader
from Orange.tests import named_file
from Orange.widgets.data.owfile import OWFile, OWFileDropHandler, DEFAULT_READER_TEXT
from Orange.widgets.utils.filedialogs import dialog_formats, format_filter, RecentPath
Expand All @@ -42,6 +42,7 @@ def read(self):
pass

def sheets(self):
# pylint: disable=broad-exception-raised
raise Exception("Not working")


Expand Down Expand Up @@ -137,6 +138,7 @@ def _drop_event(self, url):
def test_check_file_size(self):
self.assertFalse(self.widget.Warning.file_too_big.is_shown())
self.widget.SIZE_LIMIT = 4000
# We're avoiding __new__, pylint: disable=unnecessary-dunder-call
self.widget.__init__()
self.assertTrue(self.widget.Warning.file_too_big.is_shown())

Expand Down Expand Up @@ -337,7 +339,9 @@ def test_check_datetime_disabled(self):
with named_file(dat, suffix=".tab") as filename:
self.open_dataset(filename)
domain_editor = self.widget.domain_editor
idx = lambda x: self.widget.domain_editor.model().createIndex(x, 1)

def idx(x):
return self.widget.domain_editor.model().createIndex(x, 1)

qcombobox = QComboBox()
combo = ComboDelegate(domain_editor,
Expand Down

0 comments on commit 04e615f

Please sign in to comment.