From 373255450e2863ab2a4ca0c62f5ef363c248c2b8 Mon Sep 17 00:00:00 2001 From: Austin Dickey Date: Wed, 4 Nov 2026 12:06:24 -0600 Subject: [PATCH] Bump pyright to 1.1.414 and fix new type errors Pyright 1.1.308 can't handle the ModelBase.__getattr__ fallback in django-stubs 6.1.1, which causes errors when type-checking on Python 3.12+. Bump to the latest release and fix the errors it reports. --- .../instructions/python-quality-checks.instructions.md | 4 ++-- .github/workflows/build.yml | 2 +- .github/workflows/pr-check.yml | 2 +- package.json | 2 +- python_files/normalizeSelection.py | 2 +- python_files/tests/test_create_venv.py | 2 -- python_files/tests/test_get_variable_info.py | 2 +- python_files/tests/test_shell_integration.py | 8 ++++---- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/instructions/python-quality-checks.instructions.md b/.github/instructions/python-quality-checks.instructions.md index 48f37529dfbc..75811053801c 100644 --- a/.github/instructions/python-quality-checks.instructions.md +++ b/.github/instructions/python-quality-checks.instructions.md @@ -53,7 +53,7 @@ npm run check-python:pyright ## Configuration - **Ruff**: Line length 100, Python 3.9+, 40+ rule families (flake8, isort, pyupgrade, etc.) -- **Pyright**: Version 1.1.308 (or whatever is found in the environment), ignores `lib/` and 15+ legacy files +- **Pyright**: Version 1.1.414 (or whatever is found in the environment), ignores `lib/` and 15+ legacy files - Config: `python_files/pyproject.toml` sections `[tool.ruff]` and `[tool.pyright]` ## Troubleshooting @@ -93,5 +93,5 @@ This ensures your tests pass both functional checks and quality checks in CI. - Always run `npm run check-python` before pushing to catch CI failures early (1) - Use `ruff check . --fix` to auto-fix most linting issues before manual review (1) -- Pyright version must match CI (1.1.308) to avoid inconsistent results between local and CI runs (1) +- Pyright version must match CI (1.1.414) to avoid inconsistent results between local and CI runs (1) - Always run `ruff format` on test files after writing them to avoid formatting CI failures (1) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 59890d51d535..7d746271671a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -157,7 +157,7 @@ jobs: - name: Run Pyright uses: jakebailey/pyright-action@8ec14b5cfe41f26e5f41686a31eb6012758217ef # v3.0.2 with: - version: 1.1.308 + version: 1.1.414 working-directory: 'python_files' python-tests: diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index d36b4262f658..a2dfebe0b6c7 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -140,7 +140,7 @@ jobs: - name: Run Pyright uses: jakebailey/pyright-action@8ec14b5cfe41f26e5f41686a31eb6012758217ef # v3.0.2 with: - version: 1.1.308 + version: 1.1.414 working-directory: 'python_files' python-tests: diff --git a/package.json b/package.json index 12be1534f50e..0d4252730e22 100644 --- a/package.json +++ b/package.json @@ -1701,7 +1701,7 @@ "format-fix": "prettier --write 'src/**/*.ts' 'build/**/*.js' '.github/**/*.yml' gulpfile.js", "check-python": "npm run check-python:ruff && npm run check-python:pyright", "check-python:ruff": "cd python_files && python -m pip install -U ruff && python -m ruff check . && python -m ruff format --check", - "check-python:pyright": "cd python_files && npx --yes pyright@1.1.308 .", + "check-python:pyright": "cd python_files && npx --yes pyright@1.1.414 .", "clean": "gulp clean", "addExtensionPackDependencies": "gulp addExtensionPackDependencies", "updateBuildNumber": "gulp updateBuildNumber", diff --git a/python_files/normalizeSelection.py b/python_files/normalizeSelection.py index 9d82a4dc9440..32ed5016db39 100644 --- a/python_files/normalizeSelection.py +++ b/python_files/normalizeSelection.py @@ -219,7 +219,7 @@ def traverse_file(whole_file_content, start_line, end_line, was_highlighted): # # For each of the nodes in the parsed file content, # add the appropriate source code line(s) to be sent to the REPL, dependent on # user is trying to send and execute single line/statement or multiple with smart selection. - for top_node in ast.iter_child_nodes(parsed_file_content): + for top_node in parsed_file_content.body: if start_line == top_node.lineno and end_line == top_node.end_lineno: should_run_top_blocks.append(top_node) diff --git a/python_files/tests/test_create_venv.py b/python_files/tests/test_create_venv.py index 6308934d71a0..bfd9c388ac42 100644 --- a/python_files/tests/test_create_venv.py +++ b/python_files/tests/test_create_venv.py @@ -265,8 +265,6 @@ def redirect_io(stream: str, new_stream): class CustomIO(io.TextIOWrapper): """Custom stream object to replace stdio.""" - name: str = "customio" - def __init__(self, name: str, encoding="utf-8", newline=None): self._buffer = io.BytesIO() self._buffer.name = name diff --git a/python_files/tests/test_get_variable_info.py b/python_files/tests/test_get_variable_info.py index 73f94fe26f06..d38b94b1ac6d 100644 --- a/python_files/tests/test_get_variable_info.py +++ b/python_files/tests/test_get_variable_info.py @@ -3,7 +3,7 @@ def set_global_variable(value): # setting on the module allows tests to set a variable that the module under test can access - get_variable_info.test_variable = value # pyright: ignore[reportGeneralTypeIssues] + get_variable_info.test_variable = value # pyright: ignore[reportAttributeAccessIssue] def get_global_variable(): diff --git a/python_files/tests/test_shell_integration.py b/python_files/tests/test_shell_integration.py index 528f2084c3da..f3c2e53e594f 100644 --- a/python_files/tests/test_shell_integration.py +++ b/python_files/tests/test_shell_integration.py @@ -58,7 +58,7 @@ def test_displayhook_call(): importlib.reload(pythonrc) mock_displayhook = Mock() - hooks = sys.displayhook.__self__ + hooks = cast("Any", sys.displayhook).__self__ hooks.original_displayhook = mock_displayhook hooks.vscode_displayhook("mock_value") @@ -70,7 +70,7 @@ def test_excepthook_call(): importlib.reload(pythonrc) mock_excepthook = Mock() - hooks = sys.excepthook.__self__ + hooks = cast("Any", sys.excepthook).__self__ hooks.original_excepthook = mock_excepthook hooks.vscode_excepthook("mock_type", "mock_value", "mock_traceback") @@ -206,7 +206,7 @@ def test_print_statement_darwin(monkeypatch): with monkeypatch.context() as m: m.setattr("builtins.print", Mock()) importlib.reload(sys.modules["pythonrc"]) - print.assert_any_call( + cast("Mock", print).assert_any_call( "Cmd click to launch VS Code Native REPL (https://aka.ms/python-native-repl)" ) @@ -218,6 +218,6 @@ def test_print_statement_non_darwin(monkeypatch): with monkeypatch.context() as m: m.setattr("builtins.print", Mock()) importlib.reload(sys.modules["pythonrc"]) - print.assert_any_call( + cast("Mock", print).assert_any_call( "Ctrl click to launch VS Code Native REPL (https://aka.ms/python-native-repl)" )