microsoft / vscode-black-formatter

Formatting support for Python using the Black formatter
https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter
MIT License
144 stars 34 forks source link

Tolerate missing settings in initialize #453

Closed inducer closed 1 week ago

inducer commented 5 months ago

This is needed in order to get the language server to go with helix, using configuration as follows (in languages.toml):

[language-server.black-lsp]
command = "black-lsp"
args = ["--stdio"]
config = {}

[[language]]
name = "python"
language-servers = [
  "black-lsp"
]

Helix appears to pass null for initializationOptions, which appears to be allowed according to the spec.

inducer commented 5 months ago

Where would the tests for this live? How are they run?

karthiknadig commented 5 months ago

See here: https://github.com/microsoft/vscode-black-formatter/blob/main/src/test/python_tests/test_path_specialization.py

You should be able to run these tests using pytest src/test/python_tests. I recommend running specific file that you edit. The test_edit_utils.py can take over 10 mins.

You need to do the following to set up:

  1. Create a virtual environment
  2. Install nox and run nox --session install_bundled_libs
  3. Install test requirements from here: https://github.com/microsoft/vscode-black-formatter/blob/main/src/test/python_tests/requirements.txt
  4. Then run pytest src/test/python_tests/<your test file>.py
karthiknadig commented 1 week ago

Closing this for now. But feel, free to make the changes as recommended and I can re-open this.