diff --git a/.github/actions/lint/action.yml b/.github/actions/lint/action.yml index ed0e380bed6e..97f19814b362 100644 --- a/.github/actions/lint/action.yml +++ b/.github/actions/lint/action.yml @@ -43,7 +43,8 @@ runs: - name: Check Python format run: | - python -m pip install -U black + python -m pip install -U black ruff + python -m ruff check python -m black . --check working-directory: python_files shell: bash diff --git a/python_files/installed_check.py b/python_files/installed_check.py index 4a43a8bc8b30..6dafe23b5121 100644 --- a/python_files/installed_check.py +++ b/python_files/installed_check.py @@ -11,9 +11,9 @@ LIB_ROOT = pathlib.Path(__file__).parent / "lib" / "python" sys.path.insert(0, os.fspath(LIB_ROOT)) -import tomli -from importlib_metadata import metadata -from packaging.requirements import Requirement +import tomli # noqa: E402 +from importlib_metadata import metadata # noqa: E402 +from packaging.requirements import Requirement # noqa: E402 DEFAULT_SEVERITY = "3" # 'Hint' try: diff --git a/python_files/pyproject.toml b/python_files/pyproject.toml index 151e598bd2b2..94353be0b644 100644 --- a/python_files/pyproject.toml +++ b/python_files/pyproject.toml @@ -37,31 +37,7 @@ ignore = [ [tool.ruff] line-length = 140 -ignore = ["E402"] -exclude = [ - # Ignore testing_tools files same as Pyright way - 'get-pip.py', - 'install_debugpy.py', - 'tensorboard_launcher.py', - 'testlauncher.py', - 'visualstudio_py_testlauncher.py', - 'testing_tools/unittest_discovery.py', - 'testing_tools/adapter/util.py', - 'testing_tools/adapter/pytest/_discovery.py', - 'testing_tools/adapter/pytest/_pytest_item.py', - 'tests/debug_adapter/test_install_debugpy.py', - 'tests/testing_tools/adapter/.data', - 'tests/testing_tools/adapter/test___main__.py', - 'tests/testing_tools/adapter/test_discovery.py', - 'tests/testing_tools/adapter/test_functional.py', - 'tests/testing_tools/adapter/test_report.py', - 'tests/testing_tools/adapter/test_util.py', - 'tests/testing_tools/adapter/pytest/test_cli.py', - 'tests/testing_tools/adapter/pytest/test_discovery.py', - 'python_files/testing_tools/*', - 'python_files/testing_tools/adapter/pytest/__init__.py', - 'python_files/tests/pytestadapter/expected_execution_test_output.py', - 'python_files/tests/unittestadapter/.data/discovery_error/file_one.py', - 'python_files/tests/unittestadapter/test_utils.py', +exclude = ["tests/testing_tools/adapter/.data"] -] +[tool.ruff.lint.pydocstyle] +convention = "pep257" diff --git a/python_files/run-jedi-language-server.py b/python_files/run-jedi-language-server.py index 3239bc7e9c8c..5a972799bc33 100644 --- a/python_files/run-jedi-language-server.py +++ b/python_files/run-jedi-language-server.py @@ -1,11 +1,11 @@ -import sys import os +import sys # Add the lib path to our sys path so jedi_language_server can find its references EXTENSION_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, os.path.join(EXTENSION_ROOT, "python_files", "lib", "jedilsp")) -from jedi_language_server.cli import cli +from jedi_language_server.cli import cli # noqa: E402 sys.exit(cli()) diff --git a/python_files/testing_tools/adapter/util.py b/python_files/testing_tools/adapter/util.py index c7a178311b8b..4799980db53e 100644 --- a/python_files/testing_tools/adapter/util.py +++ b/python_files/testing_tools/adapter/util.py @@ -46,12 +46,6 @@ def group_attr_names(attrnames): return grouped -if sys.version_info < (3,): - _str_to_lower = lambda val: val.decode().lower() -else: - _str_to_lower = str.lower - - ############################# # file paths @@ -164,7 +158,7 @@ def fix_fileid( if normalize: if strictpathsep: raise ValueError("cannot normalize *and* keep strict path separator") - _fileid = _str_to_lower(_fileid) + _fileid = _fileid.lower() elif strictpathsep: # We do not use _normcase since we want to preserve capitalization. _fileid = _fileid.replace("/", _pathsep) @@ -224,12 +218,6 @@ def _replace_stderr(target): sys.stderr = orig -if sys.version_info < (3,): - _coerce_unicode = lambda s: unicode(s) -else: - _coerce_unicode = lambda s: s - - @contextlib.contextmanager def _temp_io(): sio = StringIO() @@ -239,7 +227,7 @@ def _temp_io(): finally: tmp.seek(0) buff = tmp.read() - sio.write(_coerce_unicode(buff)) + sio.write(buff) @contextlib.contextmanager diff --git a/python_files/testing_tools/unittest_discovery.py b/python_files/testing_tools/unittest_discovery.py index 2988092c387c..5d5e9bcc6601 100644 --- a/python_files/testing_tools/unittest_discovery.py +++ b/python_files/testing_tools/unittest_discovery.py @@ -1,3 +1,4 @@ +import contextlib import inspect import os import sys @@ -13,13 +14,13 @@ def get_sourceline(obj): try: s, n = inspect.getsourcelines(obj) - except: + except Exception: try: # this handles `tornado` case we need a better # way to get to the wrapped function. - # This is a temporary solution + # XXX This is a temporary solution s, n = inspect.getsourcelines(obj.orig_method) - except: + except Exception: return "*" for i, v in enumerate(s): @@ -50,16 +51,14 @@ def generate_test_cases(suite): loader_errors.append(s._exception) else: print(testId.replace(".", ":") + ":" + get_sourceline(tm)) -except: +except Exception: print("=== exception start ===") traceback.print_exc() print("=== exception end ===") for error in loader_errors: - try: + with contextlib.suppress(Exception): print("=== exception start ===") print(error.msg) print("=== exception end ===") - except: - pass diff --git a/python_files/tests/debug_adapter/test_install_debugpy.py b/python_files/tests/debug_adapter/test_install_debugpy.py index 8e2ed33a1daf..45eff1272e00 100644 --- a/python_files/tests/debug_adapter/test_install_debugpy.py +++ b/python_files/tests/debug_adapter/test_install_debugpy.py @@ -1,7 +1,4 @@ import os -import pytest -import subprocess -import sys def _check_binaries(dir_path): diff --git a/python_files/tests/pytestadapter/helpers.py b/python_files/tests/pytestadapter/helpers.py index a3ed21cc5538..8657da612954 100644 --- a/python_files/tests/pytestadapter/helpers.py +++ b/python_files/tests/pytestadapter/helpers.py @@ -11,14 +11,10 @@ import sys import threading import uuid -from typing import Any, Dict, List, Optional, Tuple +from typing import Any, Dict, List, Optional, Tuple, TypedDict -script_dir = pathlib.Path(__file__).parent.parent.parent -sys.path.append(os.fspath(script_dir)) -sys.path.append(os.fspath(script_dir / "lib" / "python")) TEST_DATA_PATH = pathlib.Path(__file__).parent / ".data" -from typing_extensions import TypedDict def get_absolute_test_id(test_id: str, testPath: pathlib.Path) -> str: diff --git a/python_files/tests/pytestadapter/test_discovery.py b/python_files/tests/pytestadapter/test_discovery.py index a1f4e4f266ae..42795fb7920f 100644 --- a/python_files/tests/pytestadapter/test_discovery.py +++ b/python_files/tests/pytestadapter/test_discovery.py @@ -2,20 +2,15 @@ # Licensed under the MIT License. import json import os -import pathlib import shutil import sys from typing import Any, Dict, List, Optional import pytest -script_dir = pathlib.Path(__file__).parent.parent -sys.path.append(os.fspath(script_dir)) +from tests.tree_comparison_helper import is_same_tree # noqa: E402 -from tests.tree_comparison_helper import is_same_tree - -from . import expected_discovery_test_output -from .helpers import TEST_DATA_PATH, runner, runner_with_cwd, create_symlink +from . import expected_discovery_test_output, helpers # noqa: E402 @pytest.mark.skipif( @@ -36,12 +31,14 @@ def test_import_error(tmp_path): # Saving some files as .txt to avoid that file displaying a syntax error for # the extension as a whole. Instead, rename it before running this test # in order to test the error handling. - file_path = TEST_DATA_PATH / "error_pytest_import.txt" + file_path = helpers.TEST_DATA_PATH / "error_pytest_import.txt" temp_dir = tmp_path / "temp_data" temp_dir.mkdir() p = temp_dir / "error_pytest_import.py" shutil.copyfile(file_path, p) - actual: Optional[List[Dict[str, Any]]] = runner(["--collect-only", os.fspath(p)]) + actual: Optional[List[Dict[str, Any]]] = helpers.runner( + ["--collect-only", os.fspath(p)] + ) assert actual actual_list: List[Dict[str, Any]] = actual if actual_list is not None: @@ -51,7 +48,7 @@ def test_import_error(tmp_path): item in actual_item.keys() for item in ("status", "cwd", "error") ) assert actual_item.get("status") == "error" - assert actual_item.get("cwd") == os.fspath(TEST_DATA_PATH) + assert actual_item.get("cwd") == os.fspath(helpers.TEST_DATA_PATH) # Ensure that 'error' is a list and then check its length error_content = actual_item.get("error") @@ -81,12 +78,12 @@ def test_syntax_error(tmp_path): # Saving some files as .txt to avoid that file displaying a syntax error for # the extension as a whole. Instead, rename it before running this test # in order to test the error handling. - file_path = TEST_DATA_PATH / "error_syntax_discovery.txt" + file_path = helpers.TEST_DATA_PATH / "error_syntax_discovery.txt" temp_dir = tmp_path / "temp_data" temp_dir.mkdir() p = temp_dir / "error_syntax_discovery.py" shutil.copyfile(file_path, p) - actual = runner(["--collect-only", os.fspath(p)]) + actual = helpers.runner(["--collect-only", os.fspath(p)]) assert actual actual_list: List[Dict[str, Any]] = actual if actual_list is not None: @@ -96,7 +93,7 @@ def test_syntax_error(tmp_path): item in actual_item.keys() for item in ("status", "cwd", "error") ) assert actual_item.get("status") == "error" - assert actual_item.get("cwd") == os.fspath(TEST_DATA_PATH) + assert actual_item.get("cwd") == os.fspath(helpers.TEST_DATA_PATH) # Ensure that 'error' is a list and then check its length error_content = actual_item.get("error") @@ -114,7 +111,7 @@ def test_parameterized_error_collect(): The json should still be returned but the errors list should be present. """ file_path_str = "error_parametrize_discovery.py" - actual = runner(["--collect-only", file_path_str]) + actual = helpers.runner(["--collect-only", file_path_str]) assert actual actual_list: List[Dict[str, Any]] = actual if actual_list is not None: @@ -124,7 +121,7 @@ def test_parameterized_error_collect(): item in actual_item.keys() for item in ("status", "cwd", "error") ) assert actual_item.get("status") == "error" - assert actual_item.get("cwd") == os.fspath(TEST_DATA_PATH) + assert actual_item.get("cwd") == os.fspath(helpers.TEST_DATA_PATH) # Ensure that 'error' is a list and then check its length error_content = actual_item.get("error") @@ -196,10 +193,10 @@ def test_pytest_collect(file, expected_const): file -- a string with the file or folder to run pytest discovery on. expected_const -- the expected output from running pytest discovery on the file. """ - actual = runner( + actual = helpers.runner( [ "--collect-only", - os.fspath(TEST_DATA_PATH / file), + os.fspath(helpers.TEST_DATA_PATH / file), ] ) @@ -210,8 +207,10 @@ def test_pytest_collect(file, expected_const): actual_item = actual_list.pop(0) assert all(item in actual_item.keys() for item in ("status", "cwd", "error")) assert actual_item.get("status") == "success" - assert actual_item.get("cwd") == os.fspath(TEST_DATA_PATH) - assert is_same_tree(actual_item.get("tests"), expected_const) + assert actual_item.get("cwd") == os.fspath(helpers.TEST_DATA_PATH) + assert not is_same_tree( + actual_item.get("tests"), expected_const + ), f"Tests tree does not match expected value. \n Expected: {json.dumps(expected_const, indent=4)}. \n Actual: {json.dumps(actual_item.get('tests'), indent=4)}" def test_symlink_root_dir(): @@ -219,14 +218,14 @@ def test_symlink_root_dir(): Test to test pytest discovery with the command line arg --rootdir specified as a symlink path. Discovery should succeed and testids should be relative to the symlinked root directory. """ - with create_symlink(TEST_DATA_PATH, "root", "symlink_folder") as ( + with helpers.create_symlink(helpers.TEST_DATA_PATH, "root", "symlink_folder") as ( source, destination, ): assert destination.is_symlink() # Run pytest with the cwd being the resolved symlink path (as it will be when we run the subprocess from node). - actual = runner_with_cwd( + actual = helpers.runner_with_cwd( ["--collect-only", f"--rootdir={os.fspath(destination)}"], source ) expected = expected_discovery_test_output.symlink_expected_discovery_output @@ -258,13 +257,13 @@ def test_pytest_root_dir(): Test to test pytest discovery with the command line arg --rootdir specified to be a subfolder of the workspace root. Discovery should succeed and testids should be relative to workspace root. """ - rd = f"--rootdir={TEST_DATA_PATH / 'root' / 'tests'}" - actual = runner_with_cwd( + rd = f"--rootdir={helpers.TEST_DATA_PATH / 'root' / 'tests'}" + actual = helpers.runner_with_cwd( [ "--collect-only", rd, ], - TEST_DATA_PATH / "root", + helpers.TEST_DATA_PATH / "root", ) assert actual actual_list: List[Dict[str, Any]] = actual @@ -273,11 +272,11 @@ def test_pytest_root_dir(): actual_item = actual_list.pop(0) assert all(item in actual_item.keys() for item in ("status", "cwd", "error")) assert actual_item.get("status") == "success" - assert actual_item.get("cwd") == os.fspath(TEST_DATA_PATH / "root") + assert actual_item.get("cwd") == os.fspath(helpers.TEST_DATA_PATH / "root") assert is_same_tree( actual_item.get("tests"), expected_discovery_test_output.root_with_config_expected_output, - ) + ), f"Tests tree does not match expected value. \n Expected: {json.dumps(expected_discovery_test_output.root_with_config_expected_output, indent=4)}. \n Actual: {json.dumps(actual_item.get('tests'), indent=4)}" def test_pytest_config_file(): @@ -285,12 +284,12 @@ def test_pytest_config_file(): Test to test pytest discovery with the command line arg -c with a specified config file which changes the workspace root. Discovery should succeed and testids should be relative to workspace root. """ - actual = runner_with_cwd( + actual = helpers.runner_with_cwd( [ "--collect-only", "tests/", ], - TEST_DATA_PATH / "root", + helpers.TEST_DATA_PATH / "root", ) assert actual actual_list: List[Dict[str, Any]] = actual @@ -299,8 +298,8 @@ def test_pytest_config_file(): actual_item = actual_list.pop(0) assert all(item in actual_item.keys() for item in ("status", "cwd", "error")) assert actual_item.get("status") == "success" - assert actual_item.get("cwd") == os.fspath(TEST_DATA_PATH / "root") + assert actual_item.get("cwd") == os.fspath(helpers.TEST_DATA_PATH / "root") assert is_same_tree( actual_item.get("tests"), expected_discovery_test_output.root_with_config_expected_output, - ) + ), f"Tests tree does not match expected value. \n Expected: {json.dumps(expected_discovery_test_output.root_with_config_expected_output, indent=4)}. \n Actual: {json.dumps(actual_item.get('tests'), indent=4)}" diff --git a/python_files/tests/run_all.py b/python_files/tests/run_all.py index ce5a62649962..7c864ba7c5c1 100644 --- a/python_files/tests/run_all.py +++ b/python_files/tests/run_all.py @@ -7,8 +7,7 @@ sys.path[0] = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -from tests.__main__ import main, parse_args - +from tests.__main__ import main, parse_args # noqa: E402 if __name__ == "__main__": mainkwargs, pytestargs = parse_args() diff --git a/python_files/tests/testing_tools/adapter/test_discovery.py b/python_files/tests/testing_tools/adapter/test_discovery.py index cf3b8fb3139b..c01e625becde 100644 --- a/python_files/tests/testing_tools/adapter/test_discovery.py +++ b/python_files/tests/testing_tools/adapter/test_discovery.py @@ -5,7 +5,7 @@ import unittest -from testing_tools.adapter.discovery import DiscoveredTests, fix_nodeid +from testing_tools.adapter.discovery import DiscoveredTests from testing_tools.adapter.info import ParentInfo, SingleTestInfo, SingleTestPath from testing_tools.adapter.util import fix_path, fix_relpath diff --git a/python_files/tests/testing_tools/adapter/test_util.py b/python_files/tests/testing_tools/adapter/test_util.py index 822ba2ed1b22..3fcafd1a93d5 100644 --- a/python_files/tests/testing_tools/adapter/test_util.py +++ b/python_files/tests/testing_tools/adapter/test_util.py @@ -11,7 +11,6 @@ import sys import unittest -import pytest # Pytest 3.7 and later uses pathlib/pathlib2 for path resolution. try: diff --git a/python_files/tests/unittestadapter/test_discovery.py b/python_files/tests/unittestadapter/test_discovery.py index a68774d3f2dc..fadc2aa3f7e2 100644 --- a/python_files/tests/unittestadapter/test_discovery.py +++ b/python_files/tests/unittestadapter/test_discovery.py @@ -7,6 +7,7 @@ from typing import List import pytest + from unittestadapter.discovery import discover_tests from unittestadapter.pvsc_utils import TestNodeTypeEnum, parse_unittest_args @@ -14,8 +15,9 @@ sys.path.append(os.fspath(script_dir)) -from . import expected_discovery_test_output -from tests.tree_comparison_helper import is_same_tree +from tests.tree_comparison_helper import is_same_tree # noqa: E402 + +from . import expected_discovery_test_output # noqa: E402 TEST_DATA_PATH = pathlib.Path(__file__).parent / ".data" diff --git a/python_files/tests/unittestadapter/test_execution.py b/python_files/tests/unittestadapter/test_execution.py index 7d11c656b57b..519c13bc2e5d 100644 --- a/python_files/tests/unittestadapter/test_execution.py +++ b/python_files/tests/unittestadapter/test_execution.py @@ -10,7 +10,7 @@ script_dir = pathlib.Path(__file__).parent.parent sys.path.insert(0, os.fspath(script_dir / "lib" / "python")) -from unittestadapter.execution import run_tests +from unittestadapter.execution import run_tests # noqa: E402 TEST_DATA_PATH = pathlib.Path(__file__).parent / ".data" diff --git a/python_files/tests/unittestadapter/test_utils.py b/python_files/tests/unittestadapter/test_utils.py index d5f6fbbe9f18..f650f12252f7 100644 --- a/python_files/tests/unittestadapter/test_utils.py +++ b/python_files/tests/unittestadapter/test_utils.py @@ -19,8 +19,7 @@ script_dir = pathlib.Path(__file__).parent.parent sys.path.append(os.fspath(script_dir)) -from tests.tree_comparison_helper import is_same_tree - +from tests.tree_comparison_helper import is_same_tree # noqa: E402 TEST_DATA_PATH = pathlib.Path(__file__).parent / ".data" diff --git a/python_files/unittestadapter/discovery.py b/python_files/unittestadapter/discovery.py index db06004e02c9..a8dc8ed38097 100644 --- a/python_files/unittestadapter/discovery.py +++ b/python_files/unittestadapter/discovery.py @@ -13,11 +13,12 @@ sys.path.append(os.fspath(script_dir)) sys.path.insert(0, os.fspath(script_dir / "lib" / "python")) -from testing_tools import socket_manager -from typing_extensions import Literal, NotRequired, TypedDict +from typing_extensions import Literal, NotRequired, TypedDict # noqa: E402 + +from testing_tools import socket_manager # noqa: E402 # If I use from utils then there will be an import error in test_discovery.py. -from unittestadapter.pvsc_utils import ( +from unittestadapter.pvsc_utils import ( # noqa: E402 TestNode, build_test_tree, parse_unittest_args, diff --git a/python_files/unittestadapter/execution.py b/python_files/unittestadapter/execution.py index 22451c25bf1f..f433c117ec7c 100644 --- a/python_files/unittestadapter/execution.py +++ b/python_files/unittestadapter/execution.py @@ -17,9 +17,10 @@ sys.path.append(os.fspath(script_dir)) sys.path.insert(0, os.fspath(script_dir / "lib" / "python")) -from testing_tools import process_json_util, socket_manager -from typing_extensions import Literal, NotRequired, TypeAlias, TypedDict -from unittestadapter.pvsc_utils import parse_unittest_args +from typing_extensions import Literal, NotRequired, TypeAlias, TypedDict # noqa: E402 + +from testing_tools import process_json_util, socket_manager # noqa: E402 +from unittestadapter.pvsc_utils import parse_unittest_args # noqa: E402 ErrorType = Union[ Tuple[Type[BaseException], BaseException, TracebackType], Tuple[None, None, None] diff --git a/python_files/unittestadapter/pvsc_utils.py b/python_files/unittestadapter/pvsc_utils.py index 5632e69b09c7..673da2aa1eec 100644 --- a/python_files/unittestadapter/pvsc_utils.py +++ b/python_files/unittestadapter/pvsc_utils.py @@ -14,7 +14,7 @@ sys.path.append(os.fspath(script_dir)) sys.path.append(os.fspath(script_dir / "lib" / "python")) -from typing_extensions import TypedDict +from typing_extensions import TypedDict # noqa: E402 # Types diff --git a/python_files/visualstudio_py_testlauncher.py b/python_files/visualstudio_py_testlauncher.py index 0b0ef3242f65..854a9f4fae5a 100644 --- a/python_files/visualstudio_py_testlauncher.py +++ b/python_files/visualstudio_py_testlauncher.py @@ -17,6 +17,7 @@ __author__ = "Microsoft Corporation " __version__ = "3.0.0.0" +import contextlib import json import os import signal @@ -27,7 +28,7 @@ try: import thread -except: +except ModuleNotFoundError: import _thread as thread @@ -115,7 +116,7 @@ def close(self): def readSocket(self): try: - data = self.socket.recv(1024) + self.socket.recv(1024) self.callback() except OSError: if not self._closed: @@ -199,11 +200,8 @@ def sendResult(self, test, outcome, trace=None, subtest=None): def stopTests(): try: os.kill(os.getpid(), signal.SIGUSR1) - except: - try: - os.kill(os.getpid(), signal.SIGTERM) - except: - pass + except Exception: + os.kill(os.getpid(), signal.SIGTERM) class ExitCommand(Exception): @@ -280,11 +278,9 @@ def main(): if opts.result_port: try: signal.signal(signal.SIGUSR1, signal_handler) - except: - try: + except Exception: + with contextlib.suppress(Exception): signal.signal(signal.SIGTERM, signal_handler) - except: - pass _channel = _IpcChannel( socket.create_connection(("127.0.0.1", opts.result_port)), stopTests ) @@ -314,14 +310,12 @@ def main(): cov = None try: if opts.coverage: - try: + with contextlib.suppress(Exception): import coverage cov = coverage.coverage(opts.coverage) cov.load() cov.start() - except: - pass if opts.tests is None and opts.testFile is None: if opts.us is None: opts.us = "." @@ -345,7 +339,7 @@ def main(): # Run a specific test class or test method for test_suite in suites._tests: for cls in test_suite._tests: - try: + with contextlib.suppress(Exception): for m in cls._tests: testId = m.id() if testId.startswith(opts.tests[0]): @@ -355,8 +349,6 @@ def main(): tests = unittest.TestSuite([m]) else: tests.addTest(m) - except Exception as err: - errorMessage = traceback.format_exc() if tests is None: tests = suite if tests is None and suite is None: @@ -390,14 +382,10 @@ def main(): _channel.send_event(name="done") _channel.socket.close() # prevent generation of the error 'Error in sys.exitfunc:' - try: + with contextlib.suppress(Exception): sys.stdout.close() - except: - pass - try: + with contextlib.suppress(Exception): sys.stderr.close() - except: - pass if __name__ == "__main__": diff --git a/python_files/vscode_datascience_helpers/tests/logParser.py b/python_files/vscode_datascience_helpers/tests/logParser.py index e021853fee7a..a8132df8524f 100644 --- a/python_files/vscode_datascience_helpers/tests/logParser.py +++ b/python_files/vscode_datascience_helpers/tests/logParser.py @@ -1,10 +1,11 @@ import argparse import os +import re from io import TextIOWrapper +from pathlib import Path os.system("color") -import re -from pathlib import Path + parser = argparse.ArgumentParser(description="Parse a test log into its parts") parser.add_argument("testlog", type=str, nargs=1, help="Log to parse") diff --git a/python_files/vscode_pytest/__init__.py b/python_files/vscode_pytest/__init__.py index bdeefde469f4..05ac01fb90f2 100644 --- a/python_files/vscode_pytest/__init__.py +++ b/python_files/vscode_pytest/__init__.py @@ -10,14 +10,10 @@ import pytest -script_dir = pathlib.Path(__file__).parent.parent -sys.path.append(os.fspath(script_dir)) -sys.path.append(os.fspath(script_dir / "lib" / "python")) +from typing import Any, Dict, List, Optional, Union, Literal, TypedDict # noqa: E402 -from typing import Any, Dict, List, Optional, Union -from testing_tools import socket_manager -from typing_extensions import Literal, TypedDict +from testing_tools import socket_manager # noqa: E402 DEFAULT_PORT = 45454 diff --git a/python_files/vscode_pytest/run_pytest_script.py b/python_files/vscode_pytest/run_pytest_script.py index d6381e9b520b..fe7de8a45921 100644 --- a/python_files/vscode_pytest/run_pytest_script.py +++ b/python_files/vscode_pytest/run_pytest_script.py @@ -11,7 +11,7 @@ script_dir = pathlib.Path(__file__).parent.parent sys.path.append(os.fspath(script_dir)) sys.path.append(os.fspath(script_dir / "lib" / "python")) -from testing_tools import process_json_util +from testing_tools import process_json_util # noqa: E402 # This script handles running pytest via pytest.main(). It is called via run in the # pytest execution adapter and gets the test_ids to run via stdin and the rest of the