diff --git a/IPython/core/history.py b/IPython/core/history.py index afa05fa..ff931d2 100644 --- a/IPython/core/history.py +++ b/IPython/core/history.py @@ -862,7 +862,7 @@ def extract_hist_ranges(ranges_str): >>> list(extract_hist_ranges("~8/5-~7/4 2")) [(-8, 5, None), (-7, 1, 5), (0, 2, 3)] """ - if ranges_str == '': + if ranges_str == "": yield (0, 1, None) # Everything from current session return diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 1846b3c..499d6b7 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -3722,10 +3722,10 @@ class InteractiveShell(SingletonConfigurable): # Skip the last line, as it's probably the magic that called this if not range_str: - if '\n' not in text: - text = '' + if "\n" not in text: + text = "" else: - text = text[:text.rfind('\n')] + text = text[: text.rfind("\n")] return text diff --git a/IPython/core/magics/history.py b/IPython/core/magics/history.py index 9762e6e..28f91fa 100644 --- a/IPython/core/magics/history.py +++ b/IPython/core/magics/history.py @@ -187,8 +187,9 @@ class HistoryMagics(Magics): if args.pattern: range_pattern = "*" + " ".join(args.pattern) + "*" print_nums = True - hist = history_manager.get_range_by_str(" ".join(args.range), - raw, get_output) + hist = history_manager.get_range_by_str( + " ".join(args.range), raw, get_output + ) # We could be displaying the entire history, so let's not try to pull # it into a list in memory. Anything that needs more space will just diff --git a/IPython/core/magics/osm.py b/IPython/core/magics/osm.py index e8d1cbd..c0cb209 100644 --- a/IPython/core/magics/osm.py +++ b/IPython/core/magics/osm.py @@ -817,8 +817,7 @@ class OSMagics(Magics): %pycat http://www.example.com/myscript.py """ try: - cont = self.shell.find_user_code(parameter_s, - skip_encoding_cookie=False) + cont = self.shell.find_user_code(parameter_s, skip_encoding_cookie=False) except (ValueError, IOError): print("Error: no such file, variable, URL, history range or macro") return diff --git a/IPython/core/tests/test_history.py b/IPython/core/tests/test_history.py index 6f1d820..824ba1e 100644 --- a/IPython/core/tests/test_history.py +++ b/IPython/core/tests/test_history.py @@ -162,7 +162,7 @@ def test_extract_hist_ranges(): def test_extract_hist_ranges_empty_str(): - instr = '' + instr = "" expected = [(0, 1, None)] # 0 == current session, None == to end actual = list(extract_hist_ranges(instr)) nt.assert_equal(actual, expected) diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py index b939c99..fd5696d 100644 --- a/IPython/core/tests/test_magic.py +++ b/IPython/core/tests/test_magic.py @@ -1091,7 +1091,7 @@ def test_save(): def test_save_with_no_args(): ip = get_ipython() - ip.history_manager.reset() # Clear any existing history. + ip.history_manager.reset() # Clear any existing history. cmds = [u"a=1", u"def b():\n return a**2", u"print(a, b())", "%save"] for i, cmd in enumerate(cmds, start=1): ip.history_manager.store_inputs(i, cmd)