From ff8ba98b9ba6f4aca715d1bee5a32c69d9e0be2e 2021-12-09 19:33:27 From: Matthias Bussonnier Date: 2021-12-09 19:33:27 Subject: [PATCH] reformat all of IPython.core --- diff --git a/IPython/core/magics/basic.py b/IPython/core/magics/basic.py index b44b4a3..c52e2c9 100644 --- a/IPython/core/magics/basic.py +++ b/IPython/core/magics/basic.py @@ -45,7 +45,7 @@ class MagicsDisplay(object): def _jsonable(self): """turn magics dict into jsonable dict of the same structure - + replaces object instances with their class names as strings """ magic_dict = {} @@ -123,7 +123,7 @@ class BasicMagics(Magics): In [6]: %whereami Out[6]: u'/home/testuser' - + In [7]: %alias_magic h history "-p -l 30" --line Created `%h` as an alias for `%history -l 30`. """ @@ -367,7 +367,7 @@ Currently the magic system has the following functions:""", If called without arguments, acts as a toggle. - When in verbose mode the value --show (and --hide) + When in verbose mode the value --show (and --hide) will respectively show (or hide) frames with ``__tracebackhide__ = True`` value set. """ @@ -616,12 +616,11 @@ class AsyncMagics(BasicMagics): If the passed parameter does not match any of the above and is a python identifier, get said object from user namespace and set it as the - runner, and activate autoawait. + runner, and activate autoawait. If the object is a fully qualified object name, attempt to import it and set it as the runner, and activate autoawait. - - + The exact behavior of autoawait is experimental and subject to change across version of IPython and Python. """ diff --git a/IPython/core/magics/execution.py b/IPython/core/magics/execution.py index 1b1c7b7..419eb32 100644 --- a/IPython/core/magics/execution.py +++ b/IPython/core/magics/execution.py @@ -1067,7 +1067,6 @@ class ExecutionMagics(Magics): In [6]: %timeit -n1 time.sleep(2) - The times reported by %timeit will be slightly higher than those reported by the timeit.py script when variables are accessed. This is due to the fact that %timeit executes the statement in the namespace @@ -1201,7 +1200,7 @@ class ExecutionMagics(Magics): The CPU and wall clock times are printed, and the value of the expression (if any) is returned. Note that under Win32, system time is always reported as 0, since it can not be measured. - + This function can be used both as a line and cell magic: - In line mode you can time a single-line statement (though multiple @@ -1238,7 +1237,6 @@ class ExecutionMagics(Magics): CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s Wall time: 0.00 - .. note:: The time needed by Python to compile the given expression will be reported if it is more than 0.1s. diff --git a/IPython/core/magics/extension.py b/IPython/core/magics/extension.py index ba93b3b..2bc76b2 100644 --- a/IPython/core/magics/extension.py +++ b/IPython/core/magics/extension.py @@ -41,7 +41,7 @@ class ExtensionMagics(Magics): @line_magic def unload_ext(self, module_str): """Unload an IPython extension by its module name. - + Not all extensions can be unloaded, only those which define an ``unload_ipython_extension`` function. """ diff --git a/IPython/core/magics/history.py b/IPython/core/magics/history.py index ad58b33..ec08030 100644 --- a/IPython/core/magics/history.py +++ b/IPython/core/magics/history.py @@ -105,7 +105,7 @@ class HistoryMagics(Magics): By default, all input history from the current session is displayed. Ranges of history can be indicated using the syntax: - + ``4`` Line 4, current session ``4-6`` @@ -117,7 +117,7 @@ class HistoryMagics(Magics): ``~8/1-~6/5`` From the first line of 8 sessions ago, to the fifth line of 6 sessions ago. - + Multiple ranges can be entered, separated by spaces The same syntax is used by %macro, %save, %edit, %rerun diff --git a/IPython/core/magics/namespace.py b/IPython/core/magics/namespace.py index 2118d8f..57a05d7 100644 --- a/IPython/core/magics/namespace.py +++ b/IPython/core/magics/namespace.py @@ -173,7 +173,7 @@ class NamespaceMagics(Magics): 'builtin', 'user', 'user_global','internal', 'alias', where 'builtin' and 'user' are the search defaults. Note that you should not use quotes when specifying namespaces. - + -l: List all available object types for object matching. This function can be used without arguments. @@ -203,9 +203,9 @@ class NamespaceMagics(Magics): Show objects beginning with a single _:: %psearch -a _* list objects beginning with a single underscore - + List available objects:: - + %psearch -l list all available object types """ # default namespaces to be searched @@ -252,7 +252,6 @@ class NamespaceMagics(Magics): Examples -------- - Define two variables and list them with who_ls:: In [1]: alpha = 123 @@ -367,7 +366,6 @@ class NamespaceMagics(Magics): Examples -------- - Define two variables and list them with whos:: In [1]: alpha = 123 @@ -485,22 +483,16 @@ class NamespaceMagics(Magics): Parameters ---------- -f : force reset without asking for confirmation. - -s : 'Soft' reset: Only clears your namespace, leaving history intact. References to objects may be kept. By default (without this option), we do a 'hard' reset, giving you a new session and removing all references to objects from the current session. - - --aggressive: Try to aggressively remove modules from sys.modules ; this + --aggressive : Try to aggressively remove modules from sys.modules ; this may allow you to reimport Python modules that have been updated and pick up changes, but can have unattended consequences. - in : reset input history - out : reset output history - dhist : reset directory history - array : reset only variables that are NumPy arrays See Also @@ -624,7 +616,6 @@ class NamespaceMagics(Magics): Examples -------- - We first fully reset the namespace so your output looks identical to this example for pedagogical reasons; in practice you do not need a full reset:: diff --git a/IPython/core/magics/osm.py b/IPython/core/magics/osm.py index 0940df3..11fec81 100644 --- a/IPython/core/magics/osm.py +++ b/IPython/core/magics/osm.py @@ -65,7 +65,7 @@ class OSMagics(Magics): def _isexec_POSIX(self, file): """ - Test for executable on a POSIX system + Test for executable on a POSIX system """ if os.access(file.path, os.X_OK): # will fail on maxOS if access is not X_OK @@ -76,13 +76,13 @@ class OSMagics(Magics): def _isexec_WIN(self, file): """ - Test for executable file on non POSIX system + Test for executable file on non POSIX system """ return file.is_file() and self.execre.match(file.name) is not None def isexec(self, file): """ - Test for executable file on non POSIX system + Test for executable file on non POSIX system """ if self.is_posix: return self._isexec_POSIX(file) @@ -316,7 +316,6 @@ class OSMagics(Magics): ``cd `` is enough if there is no directory ````, but a bookmark with the name exists. - Options: -q Be quiet. Do not print the working directory after the @@ -329,7 +328,6 @@ class OSMagics(Magics): where ``!command`` runs is immediately discarded after executing 'command'. - Examples -------- :: @@ -834,7 +832,7 @@ class OSMagics(Magics): @cell_magic def writefile(self, line, cell): """Write the contents of the cell to a file. - + The file will be overwritten unless the -a (--append) flag is specified. """ args = magic_arguments.parse_argstring(self.writefile, line) diff --git a/IPython/core/magics/script.py b/IPython/core/magics/script.py index dab63e7..59f27c2 100644 --- a/IPython/core/magics/script.py +++ b/IPython/core/magics/script.py @@ -202,16 +202,16 @@ class ScriptMagics(Magics): @dec_safe_watcher def shebang(self, line, cell): """Run a cell via a shell command - + The `%%script` line is like the #! line of script, specifying a program (bash, perl, ruby, etc.) with which to run. - + The rest of the cell is run by that program. - + Examples -------- :: - + In [1]: %%script bash ...: for i in 1 2 3; do ...: echo $i diff --git a/setup.cfg b/setup.cfg index 837dca3..b011a7e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -101,7 +101,7 @@ pygments.lexers = [velin] ignore_patterns = - IPython/core/tests, + IPython/core/tests IPython/testing [tool.black]