Skip to content

Make PyREPL disabling conditional on shell integration setting for Python 3.13+ #25281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jul 14, 2025

Problem

PyREPL (Python's enhanced REPL introduced in Python 3.13) causes cursor indentation issues when used with VS Code's Python shell integration feature. The previous implementation unconditionally disabled PyREPL for all Python 3.13+ environments by setting PYTHON_BASIC_REPL=1, but this prevented users from using PyREPL even when shell integration was disabled.

Solution

This PR makes PyREPL disabling conditional based on the user's shell integration preference:

  • PyREPL is disabled (via PYTHON_BASIC_REPL=1) only when:
    • Python shell integration is enabled (python.terminal.shellIntegration.enabled = true) AND
    • Python version is 3.13 or higher
  • PyREPL is allowed in all other cases

Behavior Matrix

Shell Integration Python Version PyREPL Status Environment Variable
Disabled Any ✅ Allowed PYTHON_BASIC_REPL not set
Enabled < 3.13 ✅ Allowed PYTHON_BASIC_REPL not set
Enabled >= 3.13 ❌ Disabled PYTHON_BASIC_REPL=1
Enabled Unknown ✅ Allowed PYTHON_BASIC_REPL not set (safe fallback)

Changes Made

Core Implementation

  • Modified registerBasicRepl() in src/client/terminals/pythonStartup.ts to conditionally set environment variable based on shell integration setting and Python version
  • Added configuration change listener to dynamically update when shell integration setting is toggled
  • Enhanced error handling for cases where Python version cannot be determined

Documentation

  • Updated setting description in package.nls.json to inform users that PyREPL is automatically disabled when shell integration is enabled for Python 3.13+

Testing

  • Added comprehensive test coverage for all conditional scenarios
  • Tests verify correct behavior for different combinations of shell integration settings and Python versions

Benefits

  1. Fixes cursor indentation issues: Resolves conflicts between PyREPL and shell integration
  2. Preserves user choice: Users can still access PyREPL functionality when shell integration is disabled
  3. Future-proof: Automatically applies to Python 3.14+ and later versions
  4. Dynamic updates: Changes take effect immediately when settings are modified
  5. Safe defaults: Graceful fallback when Python version detection fails

Fixes #25240.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Mention PyREPL is disabled when Python shell integration is enabled for Python3.13 and above Make PyREPL disabling conditional on shell integration setting for Python 3.13+ Jul 14, 2025
@Copilot Copilot AI requested a review from anthonykim1 July 14, 2025 01:48
Copilot finished work on behalf of anthonykim1 July 14, 2025 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mention PyREPL is disabled when Python shell integration is enabled for Python3.13 and above
2 participants