vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

Claims that black is invalid as a formatter

Open pamelafox opened this issue 2 years ago • 5 comments
trafficstars

The dev container linter claims that "ms-python.black-formatter" is invalid as a value. I believe it's valid, however. (It seems to work)

Screenshot 2023-05-03 at 9 48 19 AM

Version: 1.77.3 Commit: 704ed70d4fd1c6bd6342c436f1ede30d1cff4710 User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.58 Embedder: codespaces

Full devcontainer.json:

// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/python-3
{
	"name": "Python 3",
	"forwardPorts": [8000],
	"build": {
		"dockerfile": "Dockerfile",
		"context": "..",
		"args": {
			// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6
			// Append -bullseye or -buster to pin to an OS version.
			// Use -bullseye variants on local on arm64/Apple Silicon.
			"VARIANT": "3.11-bullseye"
		}
	},

	// Configure tool-specific properties.
	"customizations": {
		// Configure properties specific to VS Code.
		"vscode": {
			// Set *default* container specific settings.json values on container create.
			"settings": {
				"python.defaultInterpreterPath": "/usr/local/bin/python",
				"python.linting.enabled": true,
				"python.testing.pytestEnabled": true,
				"python.testing.unittestEnabled": false,
				"[python]": {
					"editor.formatOnSave": true,
					"editor.codeActionsOnSave": {
						"source.fixAll": true
					},
					"editor.defaultFormatter": "ms-python.black-formatter"
				},
				"python.formatting.provider": "black",
				"files.exclude": {
					"**/*.coverage": true,
					".ruff_cache": true,
					".pytest_cache": true
				}
			},

			// Add the IDs of extensions you want installed when the container is created.
			"extensions": [
				"ms-python.python",
				"ms-python.vscode-pylance",
				"charliermarsh.ruff",
				"ms-python.black-formatter"
			]
		}
	},

	// Use 'forwardPorts' to make a list of ports inside the container available locally.
	// "forwardPorts": [],

	// Use 'postCreateCommand' to run commands after the container is created.
	"postCreateCommand": "pip3 install --user -r requirements-dev.txt && pre-commit install",

	// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
	"remoteUser": "vscode"
}

pamelafox avatar May 03 '23 16:05 pamelafox

This should likely be filed on the dev container extension (I will move it to the correct repo). The extension registers a formatter on activate using registerDocumentFormattingEditProvider.

karthiknadig avatar May 11 '23 18:05 karthiknadig

I also see this when editing .vscode/settings.json, so not sure that it should only be a dev container issue?

Screenshot 2023-11-06 at 11 42 54 AM

pamelafox avatar Nov 06 '23 19:11 pamelafox

/cc @chrmarti

karthiknadig avatar Nov 06 '23 19:11 karthiknadig

Having the same issue. I'm not running a dev container just plain vscode.

frstlvl avatar Jan 04 '24 08:01 frstlvl

I am having a similar issue with yapf but via SSH Remote. Black doesn't throw an error but just doesn't do anything. Yapf throws an error:

Yapf works fine locally on my Mac, but when I install on the remote, it throws an error:

Extension 'yapf' is configured as formatter but it cannot format 'Python'-files

astrowonk avatar Feb 16 '24 15:02 astrowonk