No more Refactor > Move to File in Python?

Describe the Bug

Since moving to Anysphere Python, I’m unable to right click class or function names and “Refactor” > “Move to File” or “Move to New File”.

This is a very useful command for moving around classes and functions between files and having all the imports automatically updated, a task that is not great for LLMs.

Steps to Reproduce

Install Anysphere Python. Right click a function name. Click “Refactor”. It now says “No refactorings available”

Expected Behavior

It should provide two refactor options:

  1. Move to new file (creates a new file with all the appropriate imports)
  2. Move to file (just moves to an existing file)

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.1.3
VSCode Version: 1.96.2
Commit: 979ba33804ac150108481c14e0b5cb970bda3260
Date: 2025-06-15T06:35:49.230Z (17 hrs ago)
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Darwin arm64 23.6.0

Does this stop you from using Cursor

No - Cursor works, but with this issue

3 Likes

Hi! Can you double check that a python interpreter is selected for your workspace, and that the python language server setter is none?

If you had settings configured in pylance, you’ll want to import them – there’s a pop-up when first installing the extension, and it’s also available in the command palette.

Could you also try reloading the window?

Hi @ravirahman

Thanks for looking into this. I followed your suggestions, but no luck.

  • Python interpreter selected (3.12.8, using the extension Python Envy by teticio to swap between python venvs managed by uv in my multi-project monorepo)
  • “python.languageServer”: “None” (in my defaultSettings.json. I don’t have this key in my user settings or workspace settings)
  • Cursor Pyright: Import Pylance Settings
  • Reload window

Still seeing “No refactorings available” when I right click on a classname and select “Refactor”.

I have the following python-related extensions installed:

  1. Python by Anysphere
  2. Ruff by charliermarsh
  3. Python by ms-python (required by Ruff)
  4. Python by teticio (I use this for managing multiple python environments in one workspace)

I’ve tried disabling each of them and still had the same problem. Is this an MS Pylance feature that is missing from Cursor Pyright?

In case this helps, here are all of my settings files with any mention of Python I can find:

.vscode/settings.json

{
    // Python settings
    "[python]": {
        "editor.formatOnSave": true,
        "editor.defaultFormatter": "charliermarsh.ruff",
        "editor.codeActionsOnSave": {
            "source.fixAll": "explicit",
            "source.organizeImports": "explicit"
        },
        "python.analysis.extraPaths": [
            "${workspaceFolder}/lib/src",
            "${workspaceFolder}/frontend/src",
            "${workspaceFolder}/backend/app"
        ],
    },

    // Let VS Code discover the Poetry environments
    "python.analysis.autoImportCompletions": true,
    "python.analysis.indexing": true,
    "python.analysis.typeCheckingMode": "basic",
    
    "yaml.schemas": {
        "./data/questions/v4/schema-questionnaire-v4.json": ["data/questions/v4/**/*.{yaml,yml}"],
        "./data/questions/v1/schema-questionnaire-v1.json": ["data/questions/v1/**/*.{yaml,yml}"]
    },
    "python.REPL.enableREPLSmartSend": false,
    "cursorpyright.analysis.autoImportCompletions": true,
    "cursorpyright.analysis.typeCheckingMode": "basic",
}

Cursor/User/settings.json

...
    "[python]": {
        
        "diffEditor.ignoreTrimWhitespace": false,
        "editor.defaultColorDecorators": "never",
        "gitlens.codeLens.symbolScopes": [
            "!Module"
        ],
        "editor.formatOnType": true,
        "editor.wordBasedSuggestions": "off"
    },
...

defaultSettings.json

...
	// Path to the State Tool executable for ActiveState runtimes (version 0.36+).
	"python.activeStateToolPath": "state",

	// List of paths to libraries and the like that need to be imported by auto complete engine. E.g. when using Google App SDK, the paths are not in system path, hence need to be added into this list.
	"python.autoComplete.extraPaths": [],

	// Path to the conda executable to use for activation (version 4.4+).
	"python.condaPath": "",

	// Show or hide Create Environment button in the editor for `requirements.txt` or other dependency files.
	"python.createEnvironment.contentButton": "hide",

	// Detect if environment creation is required for the current project
	"python.createEnvironment.trigger": "prompt",

	// Path to default Python to use when extension loads up for the first time, no longer used once an interpreter is selected for the workspace. See [here](https://aka.ms/AAfekmf) to understand when this is used
	"python.defaultInterpreterPath": "python",

	// Absolute path to a file containing environment variable definitions.
	"python.envFile": "${workspaceFolder}/.env",

	// Enables A/B tests experiments in the Python extension. If enabled, you may get included in proposed enhancements and/or features.
	"python.experiments.enabled": true,

	// List of experiments to opt into. If empty, user is assigned the default experiment groups. See [here](https://github.com/microsoft/vscode-python/wiki/AB-Experiments) for more details.
	"python.experiments.optInto": [],

	// List of experiments to opt out of. If empty, user is assigned the default experiment groups. See [here](https://github.com/microsoft/vscode-python/wiki/AB-Experiments) for more details.
	"python.experiments.optOutFrom": [],

	// Whether to install Python modules globally when not using an environment.
	"python.globalModuleInstallation": false,

	// Controls when to display information of selected interpreter in the status bar.
	//  - never: Never display information.
	//  - onPythonRelated: Only display information if Python-related files are opened.
	//  - always: Always display information.
	"python.interpreter.infoVisibility": "onPythonRelated",

	// Defines type of the language server.
	//  - Default: Automatically select a language server: Pylance if installed and available, otherwise fallback to Jedi.
	//  - Jedi: Use Jedi behind the Language Server Protocol (LSP) as a language server.
	//  - Pylance: Use Pylance as a language server.
	//  - None: Disable language server capabilities.
	"python.languageServer": "None",

	// [Experimental] Select implementation of environment locators. This is an experimental setting while we test native environment location.
	"python.locator": "js",

	// This setting is deprecated. Please use command `Developer: Set Log Level...` to set logging level.
	// The logging level the extension logs at, defaults to 'error'
	"python.logging.level": "error",

	// Set severity of missing packages in requirements.txt or pyproject.toml
	"python.missingPackage.severity": "Hint",

	// Path to the pipenv executable to use for activation.
	"python.pipenvPath": "pipenv",

	// Path to the pixi executable.
	"python.pixiToolPath": "pixi",

	// Path to the poetry executable.
	"python.poetryPath": "poetry",

	// Toggle Smart Send for the Python REPL. Smart Send enables sending the smallest runnable block of code to the REPL on Shift+Enter and moves the cursor accordingly.
	"python.REPL.enableREPLSmartSend": true,

	// Toggle to provide variables for the REPL variable view for the native REPL.
	"python.REPL.provideVariables": true,

	// Toggle to send code to Python REPL instead of the terminal on execution. Turning this on will change the behavior for both Smart Send and Run Selection/Line in the Context Menu.
	"python.REPL.sendToNativeREPL": false,

	// Activate Python Environment in the current Terminal on load of the Extension.
	"python.terminal.activateEnvInCurrentTerminal": false,

	// Activate Python Environment in all Terminals created.
	"python.terminal.activateEnvironment": true,

	// When executing a file in the terminal, whether to use execute in the file's directory, instead of the current open folder.
	"python.terminal.executeInFileDir": false,

	// When launching a python terminal, whether to focus the cursor on the terminal.
	"python.terminal.focusAfterLaunch": false,

	// Python launch arguments to use when executing a file in the terminal.
	"python.terminal.launchArgs": [],

	// Enable [shell integration](https://code.visualstudio.com/docs/terminal/shell-integration) for the terminals running python. Shell integration enhances the terminal experience by enabling command decorations, run recent command, improving accessibility among other things.
	"python.terminal.shellIntegration.enabled": false,

	// Enable auto run test discovery when saving a test file.
	"python.testing.autoTestDiscoverOnSaveEnabled": true,

	// Glob pattern used to determine which files are used by autoTestDiscoverOnSaveEnabled.
	"python.testing.autoTestDiscoverOnSavePattern": "**/*.py",

	// Optional working directory for tests.
	"python.testing.cwd": null,

	// Port number used for debugging of tests.
	"python.testing.debugPort": 3000,

	// Prompt to configure a test framework if potential tests directories are discovered.
	"python.testing.promptToConfigure": true,

	// Arguments passed in. Each argument is a separate item in the array.
	"python.testing.pytestArgs": [],

	// Enable testing using pytest.
	"python.testing.pytestEnabled": false,

	// Path to pytest. You can use a custom version of pytest by modifying this setting to include the full path.
	"python.testing.pytestPath": "pytest",

	// Arguments passed in. Each argument is a separate item in the array.
	"python.testing.unittestArgs": [
		"-v",
		"-s",
		".",
		"-p",
		"*test*.py"
	],

	// Enable testing using unittest.
	"python.testing.unittestEnabled": false,

	// Folders in your home directory to look into for virtual environments (supports pyenv, direnv and virtualenvwrapper by default).
	"python.venvFolders": [],
...

Hi @not-an-llm – it looks like the “import settings” feautre missed the “python.analysis.extraPaths” inside the “[python]” section. Could you manually copy those entries so your file looks something like (see the extra section at the end):

{
    // Python settings
    "[python]": {
        "editor.formatOnSave": true,
        "editor.defaultFormatter": "charliermarsh.ruff",
        "editor.codeActionsOnSave": {
            "source.fixAll": "explicit",
            "source.organizeImports": "explicit"
        },
        "python.analysis.extraPaths": [
            "${workspaceFolder}/lib/src",
            "${workspaceFolder}/frontend/src",
            "${workspaceFolder}/backend/app"
        ],
    },

    // Let VS Code discover the Poetry environments
    "python.analysis.autoImportCompletions": true,
    "python.analysis.indexing": true,
    "python.analysis.typeCheckingMode": "basic",


    "yaml.schemas": {
        "./data/questions/v4/schema-questionnaire-v4.json": ["data/questions/v4/**/*.{yaml,yml}"],
        "./data/questions/v1/schema-questionnaire-v1.json": ["data/questions/v1/**/*.{yaml,yml}"]
    },
    "python.REPL.enableREPLSmartSend": false,
    "cursorpyright.analysis.autoImportCompletions": true,
    "cursorpyright.analysis.typeCheckingMode": "basic",
    "cursorpyright.analysis.extraPaths": [
        "${workspaceFolder}/lib/src",
        "${workspaceFolder}/frontend/src",
        "${workspaceFolder}/backend/app"
    ],
}

Hi @ravirahman, thanks for the suggestion. I just appended the extraPaths to my settings.json and restarted cursor, but the issue persists.

{
    // Python settings
    "[python]": {
        "editor.formatOnSave": true,
        "editor.defaultFormatter": "charliermarsh.ruff",
        "editor.codeActionsOnSave": {
            "source.fixAll": "explicit",
            "source.organizeImports": "explicit"
        },
        "python.analysis.extraPaths": [
            "${workspaceFolder}/lib/src",
            "${workspaceFolder}/frontend/src",
            "${workspaceFolder}/backend/app"
        ],
    },

    // Let VS Code discover the Poetry environments
    "python.analysis.autoImportCompletions": true,
    "python.analysis.indexing": true,
    "python.analysis.typeCheckingMode": "basic",
    
    "yaml.schemas": {
        "./data/questions/v4/schema-questionnaire-v4.json": ["data/questions/v4/**/*.{yaml,yml}"],
        "./data/questions/v1/schema-questionnaire-v1.json": ["data/questions/v1/**/*.{yaml,yml}"]
    },
    "python.REPL.enableREPLSmartSend": false,
    "cursorpyright.analysis.autoImportCompletions": true,
    "cursorpyright.analysis.typeCheckingMode": "basic",
    "cursorpyright.analysis.extraPaths": [
        "${workspaceFolder}/lib/src",
        "${workspaceFolder}/frontend/src",
        "${workspaceFolder}/backend/app"
    ],
}

Could you share the logs for the “Cursor - Pyright” and “basedpyright” output consoles?

This is also an issue for me:

[Info  - 23:13:47.120] [pylance import] Already imported settings globally
[Info  - 23:13:47.120] [pylance import] Already imported settings for remote dev-container://aethis_backend
[Info  - 23:13:47.120] [pylance import] Already imported settings for workspace tda-server [Container aethis_backend (8f7f24bf9c2d)]
[Info  - 23:13:47.120] [pylance import] Already imported settings for workspace folder /workspaces/tda-server
[Info  - 23:13:47.149] failed to find pyright executable, falling back to bundled:
/workspaces/tda-server/.venv/bin/basedpyright-langserver
[Info  - 23:13:47.149] using bundled pyright
[Info  - 23:13:47.149] running node with args: --max-old-space-size=16384
[Info  - 23:13:47.149] using default node executable

Version: 1.2.1 (user setup)
VSCode Version: 1.99.3
Commit: 031e7e0ff1e2eda9c1a0f5df67d44053b059c5d0
Date: 2025-07-03T06:16:02.610Z
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Windows_NT x64 10.0.22631

..either in win11 or running within a devcontainer

Having the same issue!