Repository navigation
[vscode-pytest]: unsupported operand type(s) for +=: 'int' and 'NoneType' #25793
Description
Activity
- addedtriage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team
on Feb 12, 2026 basictheprogram commented
on Feb 12, 2026 AuthorMore actionsI can squelch the message with
.vscode/settings.json"python.testing.pytestArgs": [ "-v", "-p", "no:vscode_pytest" ],
Hi! Thanks for the issue this is a weird one-
-
Is this reproducible every time, or intermittent?
-
What was the previous extension version that worked?
- They said "1.109" but that's the VS Code version. Need extension version.
-
is
python.useEnvironmentsExtensionenabled in settings? Does toggling it change anything? -
Can you reproduce with a minimal test file and all other pytest plugins disabled?
-
- addedinfo-neededIssue requires more information from posterIssue requires more information from poster
on Feb 12, 2026 basictheprogram commented
on Feb 12, 2026 AuthorMore actions- Is this reproducible every time, or intermittent?
reproducible every time
- What was the previous extension version that worked?>
- They said "1.109" but that's the VS Code version. Need extension version.
I did not upgrade the Python extension myself, manually. But the extension has the
Auto Updatechecked.I do run this in a devcontainer and current Python extension is 2026.0.0 I do not know what release was working before things broke.
All I know is I was on vscode 1.109 before the recommend upgrade was applied.
- is
python.useEnvironmentsExtensionenabled in settings? Does toggling it change anything?
My .vscode/settings.json, I just added (Feb 12) the
-v, -p no:vscode_pytestto get some functionality back.{ // General Editor Settings "files.insertFinalNewline": true, "files.trimTrailingWhitespace": true, // Python Interpreter and Testing "python.defaultInterpreterPath": "/home/vscode/.venv/bin/python", "python.experiments.enabled": false, "python.testing.autoTestDiscoverOnSaveEnabled": true, "python.testing.pytestEnabled": true, "python.testing.unittestEnabled": false, "python.testing.pytestPath": "/home/vscode/.venv/bin/pytest", "python.testing.pytestArgs": [ "-v", "-p", "no:vscode_pytest" ], "python.testing.cwd": "${workspaceFolder}", // Terminal - Use Bash "terminal.integrated.defaultProfile.linux": "bash", "terminal.integrated.fontSize": 15, "terminal.integrated.profiles.linux": { "bash": { "path": "/bin/bash" } }, // Language-specific Editor Configurations "[python]": { "editor.tabSize": 4, "editor.formatOnSave": false, "editor.defaultFormatter": "charliermarsh.ruff", "editor.codeActionsOnSave": { "source.fixAll": "explicit", "source.fixAll.ruff": "explicit", "source.organizeImports": "explicit", } }, "[dockercompose]": { "editor.tabSize": 4, "editor.insertSpaces": true, "editor.autoIndent": "advanced", "editor.formatOnSave": true, "editor.defaultFormatter": "redhat.vscode-yaml", "editor.quickSuggestions": { "other": true, "comments": false, "strings": true } }, "[dockerfile]": { "editor.formatOnSave": true, "editor.defaultFormatter": "ms-azuretools.vscode-docker" }, "[github-actions-workflow]": { "editor.tabSize": 4, "editor.insertSpaces": true, "editor.autoIndent": "advanced", "editor.formatOnSave": true, "editor.defaultFormatter": "redhat.vscode-yaml", "editor.quickSuggestions": { "other": true, "comments": false, "strings": true } }, "[json]": { "editor.tabSize": 4, "editor.insertSpaces": true, "editor.formatOnSave": true, "editor.defaultFormatter": "vscode.json-language-features" }, "[jsonc]": { "editor.tabSize": 4, "editor.insertSpaces": true, "editor.formatOnSave": true, "editor.defaultFormatter": "vscode.json-language-features" }, "[toml]": { "editor.tabSize": 4, "editor.insertSpaces": true, "editor.formatOnSave": true, "editor.defaultFormatter": "tamasfe.even-better-toml" }, "[yaml]": { "editor.tabSize": 4, "editor.insertSpaces": true, "editor.autoIndent": "advanced", "editor.formatOnSave": true, "editor.defaultFormatter": "redhat.vscode-yaml" }, "python-envs.pythonProjects": [ { "path": "", "envManager": "ms-python.python:venv", "packageManager": "ms-python.python:pip" } ], "[git-commit]": { "rewrap.wrappingColumn": 72 }, }I added
"python.useEnvironmentsExtension": trueand I still get the errorsrc/judgingportal/tests/management/test_import_judge_experience.py Plugin error, exception thrown while attempting to send data[vscode-pytest]: unsupported operand type(s) for +=: 'int' and 'NoneType' [vscode-pytest] data: {"jsonrpc": "2.0", "params": {"cwd": "/workspaces/judging-portal", "status": "success", "result": {"/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_valid_import": {"test": "/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_valid_import", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}}- Can you reproduce with a minimal test file and all other pytest plugins disabled?
============================= test session starts ============================== platform linux -- Python 3.12.12, pytest-8.4.2, pluggy-1.6.0 django: version: 5.1.15, settings: core.settings (from ini) rootdir: /workspaces/judging-portal configfile: pytest.ini plugins: django-4.11.1, base-url-2.1.0, mock-3.15.1, cov-7.0.0, factoryboy-2.8.1, Faker-40.4.0, lazy-fixtures-1.4.0, playwright-0.7.2, django-test-plus-2.4.1 collected 8 itemsI can duplicate the behavior with:
- code --install-extension ms-python.python@2026.1.2026020601
- code --install-extension ms-python.python@2026.1.2026012801
- Regressed to pytest-8.4.2, same problem
- Same problem with pytest-9.0.2
Minimal test with plugins enabled
def test_example(): """A simple test to reproduce potential vscode_pytest issues.""" assert 1 + 1 == 2
Test Results console
Running pytest with args: ['-p', 'vscode_pytest', '--rootdir=/workspaces/judging-portal', '/workspaces/judging-portal/src/judgingportal/tests/issue-25793/test_minimal.py::test_example'] ============================= test session starts ============================== platform linux -- Python 3.12.12, pytest-9.0.2, pluggy-1.6.0 django: version: 5.1.15, settings: core.settings (from ini) rootdir: /workspaces/judging-portal configfile: pytest.ini plugins: django-4.11.1, base-url-2.1.0, mock-3.15.1, cov-7.0.0, factoryboy-2.8.1, Faker-40.4.0, lazy-fixtures-1.4.0, playwright-0.7.2, django-test-plus-2.4.1 collected 1 item src/judgingportal/tests/issue-25793/test_minimal.py . [100%] ============================== 1 passed in 0.02s =============================== Finished running tests!Bellow is the "test nothing" test suite similar to the real test suite.
The "test nothing" tests all passes all tests.
The first test in real test suite test_valid_import() still throws the
unsupported operand type(s) for +=: 'int' and 'NoneType'error.The "testing nothing" test_call_command() is similar to test_valid_import().
The "test nothing" test suite, run with all plugins active.
import pytest from django.core.management import call_command from faker import Faker @pytest.fixture def do_nothing_fixture() -> None: """A fixture that generates fake data but otherwise does nothing.""" fake = Faker() name = fake.name() email = fake.email() return {"name": name, "email": email} def test_example(do_nothing_fixture) -> None: """A simple test to reproduce potential vscode_pytest issues.""" data = do_nothing_fixture assert 1 + 1 == 2 def test_print_fake_data(do_nothing_fixture, capsys) -> None: """A test that uses the fixture and captures stdout with capsys.""" data = do_nothing_fixture print(f"Name: {data['name']}, Email: {data['email']}") # Capture output captured = capsys.readouterr() # Check that our printed data is in the captured output assert data['name'] in captured.out assert data['email'] in captured.out @pytest.mark.django_db(transaction=True, reset_sequences=True) class TestNothing: """A minimal test class example.""" def test_nothing(self) -> None: """A test method that literally does nothing.""" assert True def test_with_mocker(self, mocker) -> None: """A test method that uses the pytest-mock fixture to mock an object.""" # Create a mock using pytest-mock do_nothing_mock = mocker.Mock() # Call the mock (does nothing) do_nothing_mock() # Assert it was called exactly once do_nothing_mock.assert_called_once() def test_patch_builtin_open(self, mocker) -> None: """Example of patching a built-in function (like open).""" fake_file_content = "Hello, world!" # Patch builtins.open to return a mock file object mock_open = mocker.mock_open(read_data=fake_file_content) mocker.patch("builtins.open", mock_open) # Use open (calls the mock) with open("dummy.txt") as f: content = f.read() # Verify the mock was called mock_open.assert_called_once_with("dummy.txt") assert content == fake_file_content def test_call_command(self, capsys) -> None: """Example of calling a Django management command.""" call_command("makemigrations", "--dry-run") captured = capsys.readouterr() assert "No changes detected" in captured.out
Test Result console
Running pytest with args: ['-p', 'vscode_pytest', '-v', '--rootdir=/workspaces/judging-portal', '/workspaces/judging-portal/src/judgingportal/tests/issue-25793/test_minimal.py::TestNothing::test_nothing', '/workspaces/judging-portal/src/judgingportal/tests/issue-25793/test_minimal.py::TestNothing::test_with_mocker', '/workspaces/judging-portal/src/judgingportal/tests/issue-25793/test_minimal.py::TestNothing::test_patch_builtin_open', '/workspaces/judging-portal/src/judgingportal/tests/issue-25793/test_minimal.py::TestNothing::test_call_command', '/workspaces/judging-portal/src/judgingportal/tests/issue-25793/test_minimal.py::test_example', '/workspaces/judging-portal/src/judgingportal/tests/issue-25793/test_minimal.py::test_print_fake_data'] ============================= test session starts ============================== platform linux -- Python 3.12.12, pytest-9.0.2, pluggy-1.6.0 -- /home/vscode/.venv/bin/python cachedir: .pytest_cache django: version: 5.1.15, settings: core.settings (from ini) rootdir: /workspaces/judging-portal configfile: pytest.ini plugins: django-4.11.1, base-url-2.1.0, mock-3.15.1, cov-7.0.0, factoryboy-2.8.1, Faker-40.4.0, lazy-fixtures-1.4.0, playwright-0.7.2, django-test-plus-2.4.1 collecting ... collected 6 items src/judgingportal/tests/issue-25793/test_minimal.py::TestNothing::test_nothing PASSED [ 16%] src/judgingportal/tests/issue-25793/test_minimal.py::TestNothing::test_with_mocker PASSED [ 33%] src/judgingportal/tests/issue-25793/test_minimal.py::TestNothing::test_patch_builtin_open PASSED [ 50%] src/judgingportal/tests/issue-25793/test_minimal.py::TestNothing::test_call_command PASSED [ 66%] src/judgingportal/tests/issue-25793/test_minimal.py::test_example PASSED [ 83%] src/judgingportal/tests/issue-25793/test_minimal.py::test_print_fake_data PASSED [100%] ============================== 6 passed in 2.33s =============================== Finished running tests!Could imports or pytest fixtures cause the problem? The "testing nothing" test suite hints at "no".
Here is the skeleton of the real test suite.
import pytest from django.core.management import call_command from django.core.management.base import CommandError from faker import Faker from tablib import Dataset from judgingportal.management.commands.import_judge_experience import MAX_EXPERIENCE, MIN_EXPERIENCE, valid_experience from judgingportal.tests.factories import ProfileFactory faker = Faker() # Define a global constant for the command name COMMAND_NAME = "import_judge_experience" @pytest.fixture def excel_file_data() -> bytes: """Fixture that returns valid Excel data as bytes.""" dataset = Dataset(headers=["id", "experience"]) dataset.append([1, 1]) # id=1, experience=1 return dataset.export("xlsx") @pytest.fixture def invalid_excel_file_data() -> bytes: """Fixture that returns invalid Excel data as bytes.""" dataset = Dataset(headers=["id", "experience"]) dataset.append([1, 87]) # invalid experience return dataset.export("xlsx") @pytest.fixture def profile() -> ProfileFactory: """Fixture to create a Profile. See tests/factories.py for factories.""" judge = ProfileFactory.create() return judge @pytest.mark.django_db(transaction=True, reset_sequences=True) class TestImportingJudgeExperience: def test_valid_import(self, profile, mock_open_file, capsys) -> None: """Test successful import of judge experience from an Excel file.""" # Call the command and capture output call_command(COMMAND_NAME, "dummy.xlsx") # Capture standard output captured = capsys.readouterr() assert "Successfully imported judge experience" in captured.out
And the Test Results console
Running pytest with args: ['-p', 'vscode_pytest', '-v', '--rootdir=/workspaces/judging-portal', '/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_valid_import', '/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_missing_id_column', '/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_missing_experience_column', '/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_invalid_data_import', '/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_no_file_provided', '/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_invalid_file_format', '/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_file_not_found', '/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_empty_file'] ============================= test session starts ============================== platform linux -- Python 3.12.12, pytest-9.0.2, pluggy-1.6.0 -- /home/vscode/.venv/bin/python cachedir: .pytest_cache django: version: 5.1.15, settings: core.settings (from ini) rootdir: /workspaces/judging-portal configfile: pytest.ini plugins: django-4.11.1, base-url-2.1.0, mock-3.15.1, cov-7.0.0, factoryboy-2.8.1, Faker-40.4.0, lazy-fixtures-1.4.0, playwright-0.7.2, django-test-plus-2.4.1 collecting ... collected 8 items src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_valid_import Plugin error, exception thrown while attempting to send data[vscode-pytest]: unsupported operand type(s) for +=: 'int' and 'NoneType' [vscode-pytest] data: {"jsonrpc": "2.0", "params": {"cwd": "/workspaces/judging-portal", "status": "success", "result": {"/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_valid_import": {"test": "/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_valid_import", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}} PASSED [ 12%] src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_missing_id_column Plugin error, exception thrown while attempting to send data[vscode-pytest]: unsupported operand type(s) for +=: 'int' and 'NoneType' [vscode-pytest] data: {"jsonrpc": "2.0", "params": {"cwd": "/workspaces/judging-portal", "status": "success", "result": {"/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_missing_id_column": {"test": "/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_missing_id_column", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}} PASSED [ 25%] src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_missing_experience_column Plugin error, exception thrown while attempting to send data[vscode-pytest]: unsupported operand type(s) for +=: 'int' and 'NoneType' [vscode-pytest] data: {"jsonrpc": "2.0", "params": {"cwd": "/workspaces/judging-portal", "status": "success", "result": {"/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_missing_experience_column": {"test": "/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_missing_experience_column", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}} PASSED [ 37%] src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_invalid_data_import Plugin error, exception thrown while attempting to send data[vscode-pytest]: unsupported operand type(s) for +=: 'int' and 'NoneType' [vscode-pytest] data: {"jsonrpc": "2.0", "params": {"cwd": "/workspaces/judging-portal", "status": "success", "result": {"/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_invalid_data_import": {"test": "/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_invalid_data_import", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}} PASSED [ 50%] src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_no_file_provided Plugin error, exception thrown while attempting to send data[vscode-pytest]: unsupported operand type(s) for +=: 'int' and 'NoneType' [vscode-pytest] data: {"jsonrpc": "2.0", "params": {"cwd": "/workspaces/judging-portal", "status": "success", "result": {"/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_no_file_provided": {"test": "/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_no_file_provided", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}} PASSED [ 62%] src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_invalid_file_format Plugin error, exception thrown while attempting to send data[vscode-pytest]: unsupported operand type(s) for +=: 'int' and 'NoneType' [vscode-pytest] data: {"jsonrpc": "2.0", "params": {"cwd": "/workspaces/judging-portal", "status": "success", "result": {"/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_invalid_file_format": {"test": "/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_invalid_file_format", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}} PASSED [ 75%] src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_file_not_found Plugin error, exception thrown while attempting to send data[vscode-pytest]: unsupported operand type(s) for +=: 'int' and 'NoneType' [vscode-pytest] data: {"jsonrpc": "2.0", "params": {"cwd": "/workspaces/judging-portal", "status": "success", "result": {"/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_file_not_found": {"test": "/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_file_not_found", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}} PASSED [ 87%] src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_empty_file Plugin error, exception thrown while attempting to send data[vscode-pytest]: unsupported operand type(s) for +=: 'int' and 'NoneType' [vscode-pytest] data: {"jsonrpc": "2.0", "params": {"cwd": "/workspaces/judging-portal", "status": "success", "result": {"/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_empty_file": {"test": "/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_empty_file", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}} PASSED [100%] ============================== 8 passed in 3.22s =============================== Finished running tests!- removedinfo-neededIssue requires more information from posterIssue requires more information from poster
on Feb 12, 2026 great this helps me figure it out- it is a dup of #24811. Copilot is telling me this is actually fixable (closed the other as not fixable). Worth exploring but I do not have the bandwidth right now. If you have any interest putting in a fix feel free to investigate and send me a PR!
we can actually fix this on our side with a one-liner — _real_open = open from workbench.html at import time, then use _real_open() to open the pipe. That would make us immune to builtins.open mocking entirely.- addedinfo-neededIssue requires more information from posterIssue requires more information from poster
on Feb 17, 2026 - addedbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bugconfirmation pendingThe issue needs to be confirmed through a maintainer reproducing the bug.The issue needs to be confirmed through a maintainer reproducing the bug.and removedtriage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team
on Mar 13, 2026 Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.
Happy Coding!
Type: Bug
Behaviour
src/judgingportal/tests/management/test_import_judge_experience.py Plugin error, exception thrown while attempting to send data[vscode-pytest]: unsupported operand type(s) for +=: 'int' and 'NoneType' [vscode-pytest] data: {"jsonrpc": "2.0", "params": {"cwd": "/workspaces/judging-portal", "status": "success", "result": {"/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_valid_import": {"test": "/workspaces/judging-portal/src/judgingportal/tests/management/test_import_judge_experience.py::TestImportingJudgeExperience::test_valid_import", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}}
Steps to reproduce:
Diagnostic data
Output for
Pythonin theOutputpanel (View→Output, change the drop-down the upper-right of theOutputpanel toPython)Extension version: 2026.0.0
VS Code version: Code 1.109.2 (591199df409fbf59b4b52d5ad4ee0470152a9b31, 2026-02-10T20:18:23.520Z)
OS version: Darwin arm64 24.6.0
Modes:
Remote OS version: Linux arm64 6.12.67-linuxkit
Remote OS version: Linux arm64 6.12.67-linuxkit
Remote OS version: Linux arm64 6.12.67-linuxkit
System Info
GPU0: VENDOR= 0x106b [Google Inc. (Apple)], DEVICE=0x0000 [ANGLE (Apple, ANGLE Metal Renderer: Apple M1 Max, Version 15.7.3 (Build 24G419))], DRIVER_VENDOR=Apple, DRIVER_VERSION=15.7.3 ACTIVE
Machine model name: MacBookPro
Machine model version: 18.2
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
trees_in_viz: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
A/B Experiments