pythonvisual-studio-code

Have different Black settings for submodules in main repo


I'm cloning a repo which contains 2 submodules cloned in the subs/ folder, so the structure is like:

main_repo/
-- subs/
---- sub_01
---- sub_02

I would want each of them to have different settings, for example line length for the Black formatter and flake8, so I created 3 .vscode/settings.json file (main repo, and in each of the submodules' folders), each containing:

  "[python]": {
    "editor.formatOnType": false,
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "ms-python.black-formatter",
  },
  "black-formatter.args": [
    "--line-length=xxx".
  ]

I set the line length to 150 in the main repo and sub_01, and 100 in sub_02, but it seems the 150 setting is being used everywhere when I save.


Solution

  • A settings file only applies to one workspace.

    But you could vote the request: https://github.com/Microsoft/vscode/issues/32693