From bd5fc817f119a0c46712bb8922af7a057623c03a Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Thu, 30 May 2024 09:30:15 -0700 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Carlos Cordoba --- spyder_kernels/console/kernel.py | 12 ++++++++++-- spyder_kernels/console/start.py | 5 ++--- spyder_kernels/console/tests/test_console_kernel.py | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/spyder_kernels/console/kernel.py b/spyder_kernels/console/kernel.py index 43c4975d..7ad23585 100644 --- a/spyder_kernels/console/kernel.py +++ b/spyder_kernels/console/kernel.py @@ -742,9 +742,17 @@ def update_syspath(self, new_path, prioritize): """ Update the PYTHONPATH of the kernel. - `new_path` corresponds to the new state of the PYTHONPATH. - `prioritize` determines whether to prioritize PYTHONPATH in sys.path. + Parameters + ---------- + new_path: list of str + List of PYTHONPATH paths. + prioritize: bool + Whether to place PYTHONPATH paths at the front (True) or + back (False) of sys.path. + + Notes + ----- A copy of sys.path is made at instantiation, which should be clean, so we can just prepend/append to the copy without having to explicitly remove old user paths. PYTHONPATH can just be overwritten. diff --git a/spyder_kernels/console/start.py b/spyder_kernels/console/start.py index 34634838..ce1440e2 100644 --- a/spyder_kernels/console/start.py +++ b/spyder_kernels/console/start.py @@ -16,9 +16,8 @@ import sys import site -# Remove current directory from sys.path to prevent kernel -# crashes when people name Python files or modules with -# the same name as standard library modules. +# Remove current directory from sys.path to prevent kernel crashes when people +# name Python files or modules with the same name as standard library modules. # See spyder-ide/spyder#8007 # Inject it back into sys.path after all imports in this module but # before the kernel is initialized diff --git a/spyder_kernels/console/tests/test_console_kernel.py b/spyder_kernels/console/tests/test_console_kernel.py index d12d1dc6..a68f2c6d 100644 --- a/spyder_kernels/console/tests/test_console_kernel.py +++ b/spyder_kernels/console/tests/test_console_kernel.py @@ -747,8 +747,8 @@ def test_runfile(tmpdir): sys.platform == 'darwin' and sys.version_info[:2] == (3, 8), reason="Fails on Mac with Python 3.8") def test_np_threshold(kernel): - """Test that setting Numpy threshold doesn't make the Variable Explorer - slow. + """ + Test that setting Numpy threshold doesn't make the Variable Explorer slow. """ cmd = "from spyder_kernels.console import start; start.main()"