VS Code task ile python autoflake kullanarak kullanilmayan importlari temizlemek

python, vs code, autoflake, task, import

task.json icerisine alttaki scripti ekleyin

vsconfig="$HOME/Library/Application Support/Code/User"
open $vsconfig/tasks.json
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "autoflake.removeUnusedImports",
            "command": "${command:python.interpreterPath}",
            "args": [
                "-m",
                "autoflake",
                "-i",
                "--remove-all-unused-imports",
                "${file}"
            ],
            "presentation": {
                "echo": false,
                "reveal": "silent",
                "focus": false,
                "panel": "shared",
                "showReuseMessage": false,
                "clear": true,
                "close": true
            },
            "problemMatcher": [],
            "group": {
                "kind": "none",
            }
        }
    ]
}

keyboard.json icerisinden $⇧⌥P$ gibi bir kisayol ile temizleme islemini tetikleyebilirsiniz

// Place your key bindings in this file to override the defaults
[
    {
        "key": "Shift+Alt+P", //Set this value to any you like.
        "command": "workbench.action.tasks.runTask",
        "args": "autoflake.removeUnusedImports",
    },
]

settings.json uzerinden her kayitta otomatik calistirmak

"tasks.onSave": "autoflake.removeUnusedImports"

Last updated

© 2024 ~ Yunus Emre Ak ~ yEmreAk