diff --git a/pythonFiles/completion.py b/pythonFiles/completion.py index 7a468106a2f3..fd8a15d8df28 100644 --- a/pythonFiles/completion.py +++ b/pythonFiles/completion.py @@ -86,8 +86,7 @@ def _get_top_level_module(cls, path): return path def _generate_signature(self, completion): - """Generate signature with function arguments. - """ + """Generate signature with function arguments.""" if completion.type in ["module"] or not hasattr(completion, "params"): return "" return "%s(%s)" % ( @@ -551,8 +550,8 @@ def _set_request_config(self, config): def _normalize_request_path(self, request): """Normalize any Windows paths received by a *nix build of - Python. Does not alter the reverse os.path.sep=='\\', - i.e. *nix paths received by a Windows build of Python. + Python. Does not alter the reverse os.path.sep=='\\', + i.e. *nix paths received by a Windows build of Python. """ if "path" in request: if not self.drive_mount: @@ -569,8 +568,7 @@ def _normalize_request_path(self, request): request["path"] = newPath def _process_request(self, request): - """Accept serialized request from VSCode and write response. - """ + """Accept serialized request from VSCode and write response.""" request = self._deserialize(request) self._set_request_config(request.get("config", {})) diff --git a/pythonFiles/refactor.py b/pythonFiles/refactor.py index b62802ce2c53..9e578906b3c2 100644 --- a/pythonFiles/refactor.py +++ b/pythonFiles/refactor.py @@ -52,8 +52,7 @@ class ChangeType: class Change: - """ - """ + """""" EDIT = 0 NEW = 1 @@ -337,8 +336,7 @@ def _deserialize(self, request): return json.loads(request) def _process_request(self, request): - """Accept serialized request from VSCode and write response. - """ + """Accept serialized request from VSCode and write response.""" request = self._deserialize(request) lookup = request.get("lookup", "") diff --git a/pythonFiles/tests/debug_adapter/test_install_debugpy.py b/pythonFiles/tests/debug_adapter/test_install_debugpy.py index 7a5354ba5ed7..19565c19675c 100644 --- a/pythonFiles/tests/debug_adapter/test_install_debugpy.py +++ b/pythonFiles/tests/debug_adapter/test_install_debugpy.py @@ -19,7 +19,8 @@ def _check_binaries(dir_path): @pytest.mark.skipif( - sys.version_info[:2] != (3, 7), reason="DEBUGPY wheels shipped for Python 3.7 only", + sys.version_info[:2] != (3, 7), + reason="DEBUGPY wheels shipped for Python 3.7 only", ) def test_install_debugpy(tmpdir): import install_debugpy diff --git a/pythonFiles/tests/testing_tools/adapter/pytest/test_cli.py b/pythonFiles/tests/testing_tools/adapter/pytest/test_cli.py index f5d41f603be0..6f590a31fa56 100644 --- a/pythonFiles/tests/testing_tools/adapter/pytest/test_cli.py +++ b/pythonFiles/tests/testing_tools/adapter/pytest/test_cli.py @@ -35,7 +35,10 @@ def test_discover(self): add_subparser("discover", "pytest", subparsers) self.assertEqual( - stub.calls, [("subparsers.add_parser", None, {"name": "pytest"}),] + stub.calls, + [ + ("subparsers.add_parser", None, {"name": "pytest"}), + ], ) def test_unsupported_command(self): diff --git a/pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py b/pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py index f7234cdc0a68..19d90d970781 100644 --- a/pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py +++ b/pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py @@ -187,11 +187,21 @@ def normcase(path): raise NotImplementedError ########## def _fix_fileid(*args): - return fix_fileid(*args, **dict(_normcase=normcase, _pathsep=pathsep,)) + return fix_fileid( + *args, + **dict( + _normcase=normcase, + _pathsep=pathsep, + ) + ) def _normalize_test_id(*args): return pytest_item._normalize_test_id( - *args, **dict(_fix_fileid=_fix_fileid, _pathsep=pathsep,) + *args, + **dict( + _fix_fileid=_fix_fileid, + _pathsep=pathsep, + ) ) def _iter_nodes(*args): @@ -205,20 +215,39 @@ def _iter_nodes(*args): ) def _parse_node_id(*args): - return pytest_item._parse_node_id(*args, **dict(_iter_nodes=_iter_nodes,)) + return pytest_item._parse_node_id( + *args, + **dict( + _iter_nodes=_iter_nodes, + ) + ) ########## def _split_fspath(*args): - return pytest_item._split_fspath(*args, **dict(_normcase=normcase,)) + return pytest_item._split_fspath( + *args, + **dict( + _normcase=normcase, + ) + ) ########## def _matches_relfile(*args): return pytest_item._matches_relfile( - *args, **dict(_normcase=normcase, _pathsep=pathsep,) + *args, + **dict( + _normcase=normcase, + _pathsep=pathsep, + ) ) def _is_legacy_wrapper(*args): - return pytest_item._is_legacy_wrapper(*args, **dict(_pathsep=pathsep,)) + return pytest_item._is_legacy_wrapper( + *args, + **dict( + _pathsep=pathsep, + ) + ) def _get_location(*args): return pytest_item._get_location( @@ -300,7 +329,9 @@ def test_failure(self): self.assertEqual( stub.calls, - [("pytest.main", None, {"args": self.DEFAULT_ARGS, "plugins": [plugin]}),], + [ + ("pytest.main", None, {"args": self.DEFAULT_ARGS, "plugins": [plugin]}), + ], ) def test_no_tests_found(self): @@ -837,7 +868,9 @@ def test_doctest(self): id="./x/y/z/test_eggs.py::test_eggs", name="test_eggs", path=TestPath( - root=testroot, relfile=fix_relpath(relfile), func=None, + root=testroot, + relfile=fix_relpath(relfile), + func=None, ), source="{}:{}".format(fix_relpath(relfile), 1), markers=[], @@ -860,7 +893,9 @@ def test_doctest(self): id="./x/y/z/test_eggs.py::test_eggs.TestSpam", name="test_eggs.TestSpam", path=TestPath( - root=testroot, relfile=fix_relpath(relfile), func=None, + root=testroot, + relfile=fix_relpath(relfile), + func=None, ), source="{}:{}".format(fix_relpath(relfile), 13), markers=[], @@ -883,7 +918,9 @@ def test_doctest(self): id="./x/y/z/test_eggs.py::test_eggs.TestSpam.TestEggs", name="test_eggs.TestSpam.TestEggs", path=TestPath( - root=testroot, relfile=fix_relpath(relfile), func=None, + root=testroot, + relfile=fix_relpath(relfile), + func=None, ), source="{}:{}".format(fix_relpath(relfile), 28), markers=[], diff --git a/pythonFiles/tests/testing_tools/adapter/test___main__.py b/pythonFiles/tests/testing_tools/adapter/test___main__.py index e14b08ee9d5b..53500a2f4afe 100644 --- a/pythonFiles/tests/testing_tools/adapter/test___main__.py +++ b/pythonFiles/tests/testing_tools/adapter/test___main__.py @@ -48,7 +48,12 @@ def test_unsupported_command(self): class ParseDiscoverTests(unittest.TestCase): def test_pytest_default(self): - tool, cmd, args, toolargs = parse_args(["discover", "pytest",]) + tool, cmd, args, toolargs = parse_args( + [ + "discover", + "pytest", + ] + ) self.assertEqual(tool, "pytest") self.assertEqual(cmd, "discover") @@ -88,7 +93,13 @@ def test_pytest_full(self): def test_pytest_opts(self): tool, cmd, args, toolargs = parse_args( - ["discover", "pytest", "--simple", "--no-hide-stdio", "--pretty",] + [ + "discover", + "pytest", + "--simple", + "--no-hide-stdio", + "--pretty", + ] ) self.assertEqual(tool, "pytest") @@ -120,8 +131,14 @@ def test_discover(self): "discover", {"spam": "eggs"}, [], - _tools={tool.name: {"discover": tool.discover,}}, - _reporters={"discover": reporter.report,}, + _tools={ + tool.name: { + "discover": tool.discover, + } + }, + _reporters={ + "discover": reporter.report, + }, ) self.assertEqual( diff --git a/pythonFiles/tests/testing_tools/adapter/test_discovery.py b/pythonFiles/tests/testing_tools/adapter/test_discovery.py index e1238282cad7..afe458a1b8f0 100644 --- a/pythonFiles/tests/testing_tools/adapter/test_discovery.py +++ b/pythonFiles/tests/testing_tools/adapter/test_discovery.py @@ -28,7 +28,10 @@ def test_list(self): id="test_spam.py::test_each[10-10]", name="test_each[10-10]", path=TestPath( - root=testroot, relfile=relfile, func="test_each", sub=["[10-10]"], + root=testroot, + relfile=relfile, + func="test_each", + sub=["[10-10]"], ), source="{}:{}".format(relfile, 10), markers=None, @@ -85,12 +88,19 @@ def test_reset(self): TestInfo( id="./test_spam.py::test_each", name="test_each", - path=TestPath(root=testroot, relfile="test_spam.py", func="test_each",), + path=TestPath( + root=testroot, + relfile="test_spam.py", + func="test_each", + ), source="test_spam.py:11", markers=[], parentid="./test_spam.py", ), - [("./test_spam.py", "test_spam.py", "file"), (".", testroot, "folder"),], + [ + ("./test_spam.py", "test_spam.py", "file"), + (".", testroot, "folder"), + ], ) before = len(discovered), len(discovered.parents) @@ -163,7 +173,11 @@ def test_parents(self): self.assertEqual( parents, [ - ParentInfo(id=".", kind="folder", name=testroot,), + ParentInfo( + id=".", + kind="folder", + name=testroot, + ), ParentInfo( id="./x", kind="folder", @@ -246,7 +260,11 @@ def test_add_test_simple(self): before = list(discovered), discovered.parents discovered.add_test( - test, [(relfile, relfile, "file"), (".", testroot, "folder"),] + test, + [ + (relfile, relfile, "file"), + (".", testroot, "folder"), + ], ) after = list(discovered), discovered.parents @@ -257,7 +275,11 @@ def test_add_test_simple(self): ( [expected], [ - ParentInfo(id=".", kind="folder", name=testroot,), + ParentInfo( + id=".", + kind="folder", + name=testroot, + ), ParentInfo( id="./test_spam.py", kind="file", @@ -280,7 +302,9 @@ def test_multiroot(self): id=relfile1 + "::test_spam", name="test_spam", path=TestPath( - root=testroot1, relfile=fix_relpath(relfile1), func="test_spam", + root=testroot1, + relfile=fix_relpath(relfile1), + func="test_spam", ), source="{}:{}".format(relfile1, 10), markers=[], @@ -290,7 +314,10 @@ def test_multiroot(self): ] allparents = [ # missing "./": - [(relfile1, "test_spam.py", "file"), (".", testroot1, "folder"),], + [ + (relfile1, "test_spam.py", "file"), + (".", testroot1, "folder"), + ], ] # the second root testroot2 = fix_path("/x/y/z") @@ -338,7 +365,9 @@ def test_multiroot(self): id="./test_spam.py::test_spam", name="test_spam", path=TestPath( - root=testroot1, relfile=fix_relpath(relfile1), func="test_spam", + root=testroot1, + relfile=fix_relpath(relfile1), + func="test_spam", ), source="{}:{}".format(relfile1, 10), markers=[], @@ -363,7 +392,11 @@ def test_multiroot(self): parents, [ # the first root - ParentInfo(id=".", kind="folder", name=testroot1,), + ParentInfo( + id=".", + kind="folder", + name=testroot1, + ), ParentInfo( id="./test_spam.py", kind="file", @@ -373,7 +406,11 @@ def test_multiroot(self): parentid=".", ), # the secondroot - ParentInfo(id=".", kind="folder", name=testroot2,), + ParentInfo( + id=".", + kind="folder", + name=testroot2, + ), ParentInfo( id="./w", kind="folder", @@ -408,7 +445,11 @@ def test_doctest(self): TestInfo( id=doctestfile + "::test_doctest.txt", name="test_doctest.txt", - path=TestPath(root=testroot, relfile=doctestfile, func=None,), + path=TestPath( + root=testroot, + relfile=doctestfile, + func=None, + ), source="{}:{}".format(doctestfile, 0), markers=[], parentid=doctestfile, @@ -417,7 +458,11 @@ def test_doctest(self): TestInfo( id=relfile + "::test_eggs", name="test_eggs", - path=TestPath(root=testroot, relfile=relfile, func=None,), + path=TestPath( + root=testroot, + relfile=relfile, + func=None, + ), source="{}:{}".format(relfile, 0), markers=[], parentid=relfile, @@ -425,7 +470,11 @@ def test_doctest(self): TestInfo( id=relfile + "::test_eggs.TestSpam", name="test_eggs.TestSpam", - path=TestPath(root=testroot, relfile=relfile, func=None,), + path=TestPath( + root=testroot, + relfile=relfile, + func=None, + ), source="{}:{}".format(relfile, 12), markers=[], parentid=relfile, @@ -433,7 +482,11 @@ def test_doctest(self): TestInfo( id=relfile + "::test_eggs.TestSpam.TestEggs", name="test_eggs.TestSpam.TestEggs", - path=TestPath(root=testroot, relfile=relfile, func=None,), + path=TestPath( + root=testroot, + relfile=relfile, + func=None, + ), source="{}:{}".format(relfile, 27), markers=[], parentid=relfile, @@ -484,7 +537,11 @@ def test_doctest(self): self.assertEqual( parents, [ - ParentInfo(id=".", kind="folder", name=testroot,), + ParentInfo( + id=".", + kind="folder", + name=testroot, + ), ParentInfo( id="./x", kind="folder", @@ -587,7 +644,11 @@ def test_nested_suite_simple(self): self.assertEqual( parents, [ - ParentInfo(id=".", kind="folder", name=testroot,), + ParentInfo( + id=".", + kind="folder", + name=testroot, + ), ParentInfo( id="./test_eggs.py", kind="file", diff --git a/pythonFiles/tests/testing_tools/adapter/test_report.py b/pythonFiles/tests/testing_tools/adapter/test_report.py index 0c94ebd51567..79b12bbfcca4 100644 --- a/pythonFiles/tests/testing_tools/adapter/test_report.py +++ b/pythonFiles/tests/testing_tools/adapter/test_report.py @@ -29,14 +29,22 @@ def test_basic(self): TestInfo( id="test#1", name="test_spam", - path=TestPath(root=testroot, relfile=relfile, func="test_spam",), + path=TestPath( + root=testroot, + relfile=relfile, + func="test_spam", + ), source="{}:{}".format(relfile, 10), markers=[], parentid="file#1", ), ] parents = [ - ParentInfo(id="", kind="folder", name=testroot,), + ParentInfo( + id="", + kind="folder", + name=testroot, + ), ParentInfo( id="file#1", kind="file", @@ -74,7 +82,12 @@ def test_basic(self): report_discovered(tests, parents, _send=stub.send) self.maxDiff = None - self.assertEqual(stub.calls, [("send", (expected,), None),]) + self.assertEqual( + stub.calls, + [ + ("send", (expected,), None), + ], + ) def test_multiroot(self): stub = StubSender() @@ -87,14 +100,22 @@ def test_multiroot(self): TestInfo( id=relfileid1 + "::test_spam", name="test_spam", - path=TestPath(root=testroot1, relfile=relfile1, func="test_spam",), + path=TestPath( + root=testroot1, + relfile=relfile1, + func="test_spam", + ), source="{}:{}".format(relfile1, 10), markers=[], parentid=relfileid1, ), ] parents = [ - ParentInfo(id=".", kind="folder", name=testroot1,), + ParentInfo( + id=".", + kind="folder", + name=testroot1, + ), ParentInfo( id=relfileid1, kind="file", @@ -139,7 +160,9 @@ def test_multiroot(self): id=relfileid2 + "::BasicTests::test_first", name="test_first", path=TestPath( - root=testroot2, relfile=relfile2, func="BasicTests.test_first", + root=testroot2, + relfile=relfile2, + func="BasicTests.test_first", ), source="{}:{}".format(relfile2, 61), markers=[], @@ -149,7 +172,11 @@ def test_multiroot(self): ) parents.extend( [ - ParentInfo(id=".", kind="folder", name=testroot2,), + ParentInfo( + id=".", + kind="folder", + name=testroot2, + ), ParentInfo( id="./w", kind="folder", @@ -218,7 +245,12 @@ def test_multiroot(self): report_discovered(tests, parents, _send=stub.send) self.maxDiff = None - self.assertEqual(stub.calls, [("send", (expected,), None),]) + self.assertEqual( + stub.calls, + [ + ("send", (expected,), None), + ], + ) def test_complex(self): """ @@ -269,7 +301,9 @@ def test_complex(self): id=relfileid1 + "::MySuite::test_x1", name="test_x1", path=TestPath( - root=testroot, relfile=fix_path(relfileid1), func="MySuite.test_x1", + root=testroot, + relfile=fix_path(relfileid1), + func="MySuite.test_x1", ), source="{}:{}".format(fix_path(relfileid1), 10), markers=None, @@ -279,7 +313,9 @@ def test_complex(self): id=relfileid1 + "::MySuite::test_x2", name="test_x2", path=TestPath( - root=testroot, relfile=fix_path(relfileid1), func="MySuite.test_x2", + root=testroot, + relfile=fix_path(relfileid1), + func="MySuite.test_x2", ), source="{}:{}".format(fix_path(relfileid1), 21), markers=None, @@ -301,7 +337,9 @@ def test_complex(self): id=relfileid3 + "::test_ham1", name="test_ham1", path=TestPath( - root=testroot, relfile=fix_path(relfileid3), func="test_ham1", + root=testroot, + relfile=fix_path(relfileid3), + func="test_ham1", ), source="{}:{}".format(fix_path(relfileid3), 8), markers=None, @@ -395,7 +433,11 @@ def test_complex(self): ), ] parents = [ - ParentInfo(id=".", kind="folder", name=testroot,), + ParentInfo( + id=".", + kind="folder", + name=testroot, + ), ParentInfo( id=relfileid1, kind="file", @@ -770,7 +812,12 @@ def test_complex(self): report_discovered(tests, parents, _send=stub.send) self.maxDiff = None - self.assertEqual(stub.calls, [("send", (expected,), None),]) + self.assertEqual( + stub.calls, + [ + ("send", (expected,), None), + ], + ) def test_simple_basic(self): stub = StubSender() @@ -808,7 +855,12 @@ def test_simple_basic(self): report_discovered(tests, parents, simple=True, _send=stub.send) self.maxDiff = None - self.assertEqual(stub.calls, [("send", (expected,), None),]) + self.assertEqual( + stub.calls, + [ + ("send", (expected,), None), + ], + ) def test_simple_complex(self): """ @@ -861,7 +913,10 @@ def test_simple_complex(self): id="test#1", name="test_x1", path=TestPath( - root=testroot1, relfile=relfile1, func="MySuite.test_x1", sub=None, + root=testroot1, + relfile=relfile1, + func="MySuite.test_x1", + sub=None, ), source="{}:{}".format(relfile1, 10), markers=None, @@ -871,7 +926,10 @@ def test_simple_complex(self): id="test#2", name="test_x2", path=TestPath( - root=testroot1, relfile=relfile1, func="MySuite.test_x2", sub=None, + root=testroot1, + relfile=relfile1, + func="MySuite.test_x2", + sub=None, ), source="{}:{}".format(relfile1, 21), markers=None, @@ -895,7 +953,10 @@ def test_simple_complex(self): id="test#4", name="test_ham1", path=TestPath( - root=testroot2, relfile=relfile3, func="test_ham1", sub=None, + root=testroot2, + relfile=relfile3, + func="test_ham1", + sub=None, ), source="{}:{}".format(relfile3, 8), markers=None, @@ -1110,4 +1171,9 @@ def test_simple_complex(self): report_discovered(tests, parents, simple=True, _send=stub.send) self.maxDiff = None - self.assertEqual(stub.calls, [("send", (expected,), None),]) + self.assertEqual( + stub.calls, + [ + ("send", (expected,), None), + ], + ) diff --git a/pythonFiles/tests/testing_tools/adapter/test_util.py b/pythonFiles/tests/testing_tools/adapter/test_util.py index e9c0e5f2ab19..6d162845ae06 100644 --- a/pythonFiles/tests/testing_tools/adapter/test_util.py +++ b/pythonFiles/tests/testing_tools/adapter/test_util.py @@ -109,7 +109,12 @@ def test_fix_path(self): # no-op paths paths = [path for _, path in tests] paths.extend( - [".", "..", "some-dir", "spam.py",] + [ + ".", + "..", + "some-dir", + "spam.py", + ] ) for path in paths: for pathsep in [ntpath.sep, posixpath.sep]: @@ -140,7 +145,10 @@ def test_fix_relpath(self): # no-op for path in [".", ".."]: tests.extend( - [(path, posixpath, path), (path, ntpath, path),] + [ + (path, posixpath, path), + (path, ntpath, path), + ] ) for path, _os_path, expected in tests: with self.subTest((path, _os_path.sep)): @@ -169,7 +177,10 @@ def test_fix_fileid(self): ] tests = [(p, posixpath, e) for p, e in common] tests.extend( - (p, posixpath, e) for p, e in [(r"\spam.py", r"./\spam.py"),] + (p, posixpath, e) + for p, e in [ + (r"\spam.py", r"./\spam.py"), + ] ) tests.extend((p, ntpath, e) for p, e in common) tests.extend( diff --git a/pythonFiles/vscode_datascience_helpers/daemon/__main__.py b/pythonFiles/vscode_datascience_helpers/daemon/__main__.py index aed1c21e1cd1..666f245b2a23 100644 --- a/pythonFiles/vscode_datascience_helpers/daemon/__main__.py +++ b/pythonFiles/vscode_datascience_helpers/daemon/__main__.py @@ -47,7 +47,7 @@ def add_arguments(parser): class TemporaryQueueHandler(logging.Handler): - """ Logger used to temporarily store everything into a queue. + """Logger used to temporarily store everything into a queue. Later the messages are pushed back to the RPC client as a notification. Once the RPC channel is up, we'll stop queuing messages and sending id directly. """ @@ -111,7 +111,7 @@ def _configure_logger(verbose=0, log_config=None, log_file=None): def main(): - """ Starts the daemon. + """Starts the daemon. The daemon_module allows authors of modules to provide a custom daemon implementation. E.g. we have a base implementation for standard python functionality, and a custom daemon implementation for DS work (related to jupyter). diff --git a/pythonFiles/vscode_datascience_helpers/daemon/daemon_python.py b/pythonFiles/vscode_datascience_helpers/daemon/daemon_python.py index 819bcbb086e6..be36682303d6 100644 --- a/pythonFiles/vscode_datascience_helpers/daemon/daemon_python.py +++ b/pythonFiles/vscode_datascience_helpers/daemon/daemon_python.py @@ -62,7 +62,7 @@ def _decorator(self, *args, **kwargs): class PythonDaemon(MethodDispatcher): - """ Base Python Daemon with simple methods to check if a module exists, get version info and the like. + """Base Python Daemon with simple methods to check if a module exists, get version info and the like. To add additional methods, please create a separate class based off this and pass in the arg `--daemon-module` to `vscode_datascience_helpers.daemon`. """ diff --git a/pythonFiles/vscode_datascience_helpers/dataframes/vscodeDataFrameHelpers.py b/pythonFiles/vscode_datascience_helpers/dataframes/vscodeDataFrameHelpers.py index 2bfb9faa138f..d72dbacfc62b 100644 --- a/pythonFiles/vscode_datascience_helpers/dataframes/vscodeDataFrameHelpers.py +++ b/pythonFiles/vscode_datascience_helpers/dataframes/vscodeDataFrameHelpers.py @@ -13,8 +13,8 @@ def _VSCODE_convertToDataFrame(df): elif hasattr(df, "toPandas"): df = df.toPandas() else: - """ Disabling bandit warning for try, except, pass. We want to swallow all exceptions here to not crash on - variable fetching """ + """Disabling bandit warning for try, except, pass. We want to swallow all exceptions here to not crash on + variable fetching""" try: temp = _VSCODE_pd.DataFrame(df) df = temp diff --git a/pythonFiles/vscode_datascience_helpers/getServerInfo.py b/pythonFiles/vscode_datascience_helpers/getServerInfo.py index 1993008ae6f2..cc4e69899679 100644 --- a/pythonFiles/vscode_datascience_helpers/getServerInfo.py +++ b/pythonFiles/vscode_datascience_helpers/getServerInfo.py @@ -24,8 +24,8 @@ print(json.dumps(server_info_list)) except Exception: - """ Usage of subprocess is safe here as we are using run and are in control of all the arguments passed to it - flagging for execution of partial path is also not correct as it is a command, not a path """ + """Usage of subprocess is safe here as we are using run and are in control of all the arguments passed to it + flagging for execution of partial path is also not correct as it is a command, not a path""" import subprocess # nosec import sys diff --git a/pythonFiles/vscode_datascience_helpers/kernel_launcher.py b/pythonFiles/vscode_datascience_helpers/kernel_launcher.py index 3ce6d0f81cc5..342f28d46b56 100644 --- a/pythonFiles/vscode_datascience_helpers/kernel_launcher.py +++ b/pythonFiles/vscode_datascience_helpers/kernel_launcher.py @@ -25,7 +25,7 @@ def launch_kernel( cwd=None, **kw ): - """ Launches a localhost kernel, binding to the specified ports. + """Launches a localhost kernel, binding to the specified ports. Parameters ---------- @@ -81,7 +81,13 @@ def launch_kernel( encoding = getdefaultencoding(prefer_stream=False) kwargs = kw.copy() - main_args = dict(stdin=_stdin, stdout=_stdout, stderr=_stderr, cwd=cwd, env=env,) + main_args = dict( + stdin=_stdin, + stdout=_stdout, + stderr=_stderr, + cwd=cwd, + env=env, + ) kwargs.update(main_args) # Spawn a kernel. diff --git a/pythonFiles/vscode_datascience_helpers/kernel_launcher_daemon.py b/pythonFiles/vscode_datascience_helpers/kernel_launcher_daemon.py index b6f7b454e982..7247cf6ba3a7 100644 --- a/pythonFiles/vscode_datascience_helpers/kernel_launcher_daemon.py +++ b/pythonFiles/vscode_datascience_helpers/kernel_launcher_daemon.py @@ -29,8 +29,7 @@ def __init__(self, rx, tx): self.log.info("DataScience Kernel Launcher Daemon init") def close(self): - """Ensure we kill the kernel when shutting down the daemon. - """ + """Ensure we kill the kernel when shutting down the daemon.""" try: self.m_kill_kernel() """ We don't care about exceptions coming back from killing the kernel, so pass here """ @@ -78,8 +77,7 @@ def m_kill_kernel(self): @error_decorator def m_prewarm_kernel(self): - """Starts the kernel process with the module - """ + """Starts the kernel process with the module""" self.log.info("Pre-Warm DS Kernel in DS Kernel Launcher Daemon") isolated_runner = os.path.join( os.path.dirname(__file__), "..", "pyvsc-run-isolated.py" @@ -97,8 +95,7 @@ def prewarm_kernel(): @error_decorator def m_start_prewarmed_kernel(self, args=[]): - """Starts the pre-warmed kernel process. - """ + """Starts the pre-warmed kernel process.""" self.log.info( "Start pre-warmed Kernel in DS Kernel Launcher Daemon %s with args %s", self.kernel.pid, @@ -172,7 +169,8 @@ def _exec_module_observable_in_background( def _start_kernel_observable_in_background(self, cmd, cwd=None, env=None): self.log.info( - "Exec in DS Kernel Launcher Daemon (observable) %s", cmd, + "Exec in DS Kernel Launcher Daemon (observable) %s", + cmd, ) # As the kernel is launched from this same python executable, ensure the kernel variables # are merged with the variables of this current environment. diff --git a/pythonFiles/vscode_datascience_helpers/win_interrupt.py b/pythonFiles/vscode_datascience_helpers/win_interrupt.py index ecb0d925aeac..3625954d89e6 100644 --- a/pythonFiles/vscode_datascience_helpers/win_interrupt.py +++ b/pythonFiles/vscode_datascience_helpers/win_interrupt.py @@ -38,6 +38,5 @@ class SECURITY_ATTRIBUTES(ctypes.Structure): def send_interrupt(interrupt_handle): - """ Sends an interrupt event using the specified handle. - """ + """Sends an interrupt event using the specified handle.""" ctypes.windll.kernel32.SetEvent(interrupt_handle)