Skip to content

Commit

Permalink
Merge pull request #8173 from CAM-Gerlach/fix-deprecation-varexp
Browse files Browse the repository at this point in the history
PR: Fix various DeprecationWarnings and FutureWarnings
  • Loading branch information
ccordoba12 authored Oct 31, 2018
2 parents 4a0e2db + 85c25d5 commit 47c0020
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
4 changes: 2 additions & 2 deletions spyder/app/tests/test_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,12 @@ def test_single_instance_and_edit_magic(main_window, qtbot, tmpdir):

spy_dir = osp.dirname(get_module_path('spyder'))
lock_code = ("import sys\n"
"sys.path.append('{}')\n"
"sys.path.append(r'{spy_dir_str}')\n"
"from spyder.config.base import get_conf_path\n"
"from spyder.utils.external import lockfile\n"
"lock_file = get_conf_path('spyder.lock')\n"
"lock = lockfile.FilesystemLock(lock_file)\n"
"lock_created = lock.lock()".format(spy_dir))
"lock_created = lock.lock()".format(spy_dir_str=spy_dir))

# Test single instance
with qtbot.waitSignal(shell.executed):
Expand Down
8 changes: 4 additions & 4 deletions spyder/widgets/github/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ def send_report(self, title, body, application_log=None):
repo = gh.repos(self.gh_owner)(self.gh_repo)
ret = repo.issues.post(title=title, body=body)
except github.ApiError as e:
_logger().warn('failed to send bug report on github. response=%r' %
e.response)
_logger().warning('Failed to send bug report on Github. '
'response=%r', e.response)
# invalid credentials
if e.response.code == 401:
if self._show_msgbox:
Expand Down Expand Up @@ -287,7 +287,7 @@ def upload_log_file(self, log_content):
files={'SpyderIDE.log': {"content": log_content}})
qApp.restoreOverrideCursor()
except github.ApiError:
_logger().warn('failed to upload log report as a gist')
return '"failed to upload log file as a gist"'
_logger().warning('Failed to upload log report as a gist')
return '"Failed to upload log file as a gist"'
else:
return ret['html_url']
4 changes: 3 additions & 1 deletion spyder/widgets/tests/test_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ def test_replace_enter_press(editor_find_replace_bot):
qtbot.keyPress(finder.search_text, Qt.Key_Return, modifier=Qt.ShiftModifier)
assert editor.get_cursor_line_column() == (3,4)


def test_replace_plain_regex(editor_find_replace_bot):
"""Test that regex reserved characters are displayed as plain text."""
editor_stack, editor, finder, qtbot = editor_find_replace_bot
Expand All @@ -332,10 +333,11 @@ def test_replace_plain_regex(editor_find_replace_bot):
finder.show()
finder.show_replace()
qtbot.keyClicks(finder.search_text, 'spam')
qtbot.keyClicks(finder.replace_text, '.\[()]*test')
qtbot.keyClicks(finder.replace_text, r'.\[()]*test')
qtbot.keyPress(finder.replace_text, Qt.Key_Return)
assert editor.toPlainText()[0:-1] == expected_new_text


def test_replace_invalid_regex(editor_find_replace_bot):
"""Assert that replacing an invalid regexp does nothing."""
editor_stack, editor, finder, qtbot = editor_find_replace_bot
Expand Down
6 changes: 3 additions & 3 deletions spyder/widgets/variableexplorer/arrayeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,11 +780,11 @@ def change_active_widget(self, index):
slice_index[self.last_dim] = data_index

stack_index = self.dim_indexes[self.last_dim].get(data_index)
if stack_index == None:
if stack_index is None:
stack_index = self.stack.count()
try:
self.stack.addWidget(ArrayEditorWidget(self,
self.data[slice_index]))
self.stack.addWidget(ArrayEditorWidget(
self, self.data[tuple(slice_index)]))
except IndexError: # Handle arrays of size 0 in one axis
self.stack.addWidget(ArrayEditorWidget(self, self.data))
self.dim_indexes[self.last_dim][data_index] = stack_index
Expand Down
28 changes: 17 additions & 11 deletions spyder/widgets/variableexplorer/collectionseditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,23 @@ def set_size_and_type(self, start=None, stop=None):
fetch_more = False
else:
fetch_more = True

if self.remote:
sizes = [ data[self.keys[index]]['size']
for index in range(start, stop) ]
types = [ data[self.keys[index]]['type']
for index in range(start, stop) ]
else:
sizes = [ get_size(data[self.keys[index]])
for index in range(start, stop) ]
types = [ get_human_readable_type(data[self.keys[index]])
for index in range(start, stop) ]

# Ignore pandas warnings that certain attributes are deprecated
# and will be removed, since they will only be accessed if they exist.
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore", message=(r"^\w+\.\w+ is deprecated and "
"will be removed in a future version"))
if self.remote:
sizes = [data[self.keys[index]]['size']
for index in range(start, stop)]
types = [data[self.keys[index]]['type']
for index in range(start, stop)]
else:
sizes = [get_size(data[self.keys[index]])
for index in range(start, stop)]
types = [get_human_readable_type(data[self.keys[index]])
for index in range(start, stop)]

if fetch_more:
self.sizes = self.sizes + sizes
Expand Down

0 comments on commit 47c0020

Please sign in to comment.