From 2b9ce78fd02eb770bb789b0b1ffbd16f066ed2f2 2014-10-07 14:04:21 From: Boris Egorov Date: 2014-10-07 14:04:21 Subject: [PATCH] Use 'is' to compare with None Issues were detected by PyCharm Community Edition 3.4. --- diff --git a/IPython/lib/display.py b/IPython/lib/display.py index a100a5d..30494b0 100644 --- a/IPython/lib/display.py +++ b/IPython/lib/display.py @@ -450,7 +450,7 @@ class FileLinks(FileLink): display_fnames = [] for fname in fnames: if (isfile(join(dirname,fname)) and - (included_suffixes == None or + (included_suffixes is None or splitext(fname)[1] in included_suffixes)): display_fnames.append(fname) diff --git a/IPython/qt/console/magic_helper.py b/IPython/qt/console/magic_helper.py index 7b83b7a..d599b50 100644 --- a/IPython/qt/console/magic_helper.py +++ b/IPython/qt/console/magic_helper.py @@ -116,7 +116,7 @@ class MagicHelper(QtGui.QDockWidget): instance is expected to invoke populate_magic_helper() when magic info is available. """ - if not visible or self.data != None: + if not visible or self.data is not None: return self.data = {} self.search_class.clear() @@ -178,14 +178,14 @@ class MagicHelper(QtGui.QDockWidget): """Emit pasteRequested signal with currently selected item text """ text = self._get_current_search_item(item) - if text != None: + if text is not None: self.pasteRequested.emit(text) def run_requested(self, item = None): """Emit runRequested signal with currently selected item text """ text = self._get_current_search_item(item) - if text != None: + if text is not None: self.runRequested.emit(text) def filter_magic_helper(self, regex, cls): @@ -193,9 +193,9 @@ class MagicHelper(QtGui.QDockWidget): regex and class match cls. If cls equals 'any' - any class matches. """ - if regex == "" or regex == None: + if regex == "" or regex is None: regex = '.' - if cls == None: + if cls is None: cls = 'any' self.search_list.clear() diff --git a/IPython/qt/console/mainwindow.py b/IPython/qt/console/mainwindow.py index b48a492..1cb8878 100644 --- a/IPython/qt/console/mainwindow.py +++ b/IPython/qt/console/mainwindow.py @@ -144,7 +144,7 @@ class MainWindow(QtGui.QMainWindow): # of this is when 'exit' is sent in a slave tab. 'exit' will be # re-sent by this function on the master widget, which ask all slave # widgets to exit - if closing_widget==None: + if closing_widget is None: return #get a list of all slave widgets on the same kernel. @@ -719,12 +719,12 @@ class MainWindow(QtGui.QMainWindow): QtCore.QTimer.singleShot(200, self.active_frontend._control.setFocus) def magic_helper_paste_requested(self, text = None): - if text != None: + if text is not None: self.active_frontend.input_buffer = text self._set_active_frontend_focus() def magic_helper_run_requested(self, text = None): - if text != None: + if text is not None: self.active_frontend.execute(text) self._set_active_frontend_focus() diff --git a/IPython/utils/_process_win32_controller.py b/IPython/utils/_process_win32_controller.py index aa508cb..555eec2 100644 --- a/IPython/utils/_process_win32_controller.py +++ b/IPython/utils/_process_win32_controller.py @@ -296,7 +296,7 @@ class Win32ShellCommandController(object): c_hstdin = None CloseHandle(c_hstdout) c_hstdout = None - if c_hstderr != None: + if c_hstderr is not None: CloseHandle(c_hstderr) c_hstderr = None @@ -403,10 +403,10 @@ class Win32ShellCommandController(object): These functions are called from different threads (but not concurrently, because of the GIL). """ - if stdout_func == None and stdin_func == None and stderr_func == None: + if stdout_func is None and stdin_func is None and stderr_func is None: return self._run_stdio() - if stderr_func != None and self.mergeout: + if stderr_func is not None and self.mergeout: raise RuntimeError("Shell command was initiated with " "merged stdin/stdout, but a separate stderr_func " "was provided to the run() method") @@ -421,7 +421,7 @@ class Win32ShellCommandController(object): threads.append(threading.Thread(target=self._stdout_thread, args=(self.hstdout, stdout_func))) if not self.mergeout: - if stderr_func == None: + if stderr_func is None: stderr_func = stdout_func threads.append(threading.Thread(target=self._stdout_thread, args=(self.hstderr, stderr_func))) @@ -541,7 +541,7 @@ class Win32ShellCommandController(object): if self.hstderr: CloseHandle(self.hstderr) self.hstderr = None - if self.piProcInfo != None: + if self.piProcInfo is not None: CloseHandle(self.piProcInfo.hProcess) CloseHandle(self.piProcInfo.hThread) self.piProcInfo = None