Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/instructions/python-quality-checks.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion python_files/normalizeSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 0 additions & 2 deletions python_files/tests/test_create_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion python_files/tests/test_get_variable_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
8 changes: 4 additions & 4 deletions python_files/tests/test_shell_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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)"
)

Expand All @@ -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)"
)