skip to Main Content

I am windows users and I want to use black formatter in vscode to format my python code. I have the extension installed, extension installed
and I have made modifications in setting.JSON file. But I found it not working still. JSON file

"[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": "always"
        },
    },
    "isort.args": [
        "--profile",
        "black"
    ]
}

Also, i tried to rerun the vscode and re-install the extensions, still not work.
For example: Like these lines of code:enter image description here

#to build the tx u just need to call the constructor field
transaction = simplestorage.constructor().build_transaction(
    {
        "gasPrice": w3.eth.gas_price, "chainId": chain_id,
        "from": my_address,
        "nonce": nonce,
    
    }
)

it should be formatted like this enter image description here

# to build the tx u just need to call the constructor field
transaction = simplestorage.constructor().build_transaction(
    {
        "gasPrice": w3.eth.gas_price, 
        "chainId": chain_id,
        "from": my_address,
        "nonce": nonce,
    
    }
)

but i hit control+s, it turns out that it wasn’t. Note that yesterday it can work but I don’t know what happened today.

sorry about the image link. I’m newbie here so I’m not able to embed images.

2

Answers


  1. Chosen as BEST ANSWER

    Solved. Try to run command Black Formatter: Restart Server after opening your Command Palette (Ctrl + Shift + P). this works for me


  2. This is not a problem with settings. Your settings can make black work in my vscode. Try to run command Black Formatter: Restart Server after opening your Command Palette (Ctrl + Shift + P).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search