diff --git a/spyder_kernels/console/tests/test_console_kernel.py b/spyder_kernels/console/tests/test_console_kernel.py index ceda7c3f..065b53a1 100644 --- a/spyder_kernels/console/tests/test_console_kernel.py +++ b/spyder_kernels/console/tests/test_console_kernel.py @@ -687,8 +687,8 @@ def test_runfile(tmpdir): u.write(code) # Run code file `d` to define `result` even after an error - client.execute_interactive("%runfile {}" - .format(repr(str(d))), timeout=TIMEOUT) + client.execute_interactive( + "%runfile {}".format(repr(str(d))), timeout=TIMEOUT) # Verify that `result` is defined in the current namespace client.inspect('result') @@ -699,8 +699,8 @@ def test_runfile(tmpdir): assert content['found'] # Run code file `u` without current namespace - client.execute_interactive("%runfile {}" - .format(repr(str(u))), timeout=TIMEOUT) + client.execute_interactive( + "%runfile {}".format(repr(str(u))), timeout=TIMEOUT) # Verify that the variable `result2` is defined client.inspect('result2') diff --git a/spyder_kernels/customize/code_runner.py b/spyder_kernels/customize/code_runner.py index 35cd59a6..98e57b2a 100644 --- a/spyder_kernels/customize/code_runner.py +++ b/spyder_kernels/customize/code_runner.py @@ -60,13 +60,13 @@ def runfile_arguments(func): magic_arguments.argument( "filename", help=""" - filename to run + Filename to run """, ), magic_arguments.argument( "--args", help=""" - command line arguments (string) + Command line arguments (string) """, ), magic_arguments.argument( @@ -74,27 +74,27 @@ def runfile_arguments(func): const=True, nargs="?", help=""" - working directory + Working directory """, ), magic_arguments.argument( "--post-mortem", action="store_true", help=""" - enter post-mortem mode on error + Enter post-mortem mode on errors """, ), magic_arguments.argument( "--current-namespace", action="store_true", help=""" - use current namespace + Use current namespace """, ), magic_arguments.argument( "--namespace", help=""" - namespace to run the file in + Namespace to run the file in """, ) ] @@ -123,7 +123,7 @@ def runcell_arguments(func): "filename", nargs="?", help=""" - filename + Filename """, ), magic_arguments.argument( @@ -131,7 +131,7 @@ def runcell_arguments(func): action="store_true", default=False, help=""" - Automatically enter post mortem on exception. + Enter post-mortem mode on errors """, ) ] @@ -663,11 +663,12 @@ def _post_mortem_excepthook(self, type, value, tb): def _parse_argstring(self, magic_func, argstring): """ - Parse a string of arguments for a magic function + Parse a string of arguments for a magic function. This is needed because magic_arguments.parse_argstring does - plateform-dependent things with quotes and backslahes - e.g. on windows, string are removed and backslahes are escaped + platform-dependent things with quotes and backslashes. For + example, on Windows, strings are removed and backslashes are + escaped. """ argv = shlex.split(argstring) args = magic_func.parser.parse_args(argv) @@ -677,14 +678,11 @@ def _parse_argstring(self, magic_func, argstring): return args def _parse_runfile_argstring(self, magic_func, argstring, local_ns): - """ - Parse a string for runfile - """ + """Parse an args string for runfile and debugfile.""" args = self._parse_argstring(magic_func, argstring) if args.namespace is None: args.namespace = self.shell.user_ns else: - if local_ns is not None and args.namespace in local_ns: args.namespace = local_ns[args.namespace] elif args.namespace in self.shell.user_ns: @@ -698,11 +696,9 @@ def _parse_runfile_argstring(self, magic_func, argstring, local_ns): return args, local_ns def _parse_runcell_argstring(self, magic_func, argstring): - """ - Parse a sting for runcell - """ + """Parse an args string for runcell and debugcell.""" args = self._parse_argstring(magic_func, argstring) args.cell_id = args.name if args.cell_id is None: args.cell_id = int(args.index) - return args \ No newline at end of file + return args