Setup IDE

Лев Коваленко — Senior DS Engineer

Настройка джентельменского набора

Поставьте расширения: black, isort, flake8, mypy

{
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.codeActionsOnSave": {
            "source.organizeImports.ruff": "explicit"
        },
        "editor.formatOnSave": true
    },
    "isort.args":["--profile", "black"],
    "notebook.formatOnSave.enabled": true,
    "notebook.codeActionsOnSave": {
        "notebook.source.fixAll": "explicit"
    },
}

Настройка Ruff

Поставьте расширение: ruff

{
    "notebook.formatOnSave.enabled": true,
    "notebook.codeActionsOnSave": {
        "notebook.source.fixAll": "explicit",
        "notebook.source.organizeImports": "explicit"
    },
    "[python]": {
        "editor.formatOnSave": true,
        "editor.defaultFormatter": "charliermarsh.ruff",
        "editor.codeActionsOnSave": {
            "source.fixAll": "explicit",
            "source.organizeImports": "explicit"
        }
    }
    
}

Pre-commit автоматизация

.pre-commit-config.yaml

default_stages: [commit, push]
repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.2.0
    hooks:
    -   id: trailing-whitespace
    -   id: end-of-file-fixer
    -   id: check-added-large-files
    -   id: check-merge-conflict
-   repo: https://github.com/python/black
    rev: 24.2.0
    hooks:
      - id: black
-   repo: https://github.com/pycqa/isort
    rev: 5.11.2
    hooks:
    -   id: isort
-   repo: https://github.com/PyCQA/flake8
    rev: 7.0.0
    hooks:
    -   id: flake8
-   repo: https://github.com/pre-commit/mirrors-mypy
    rev: 'v1.8.0'
    hooks:
    -   id: mypy
-   repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.3.0
    hooks:
    - id: ruff
      args: [ --fix ]
    - id: ruff-format
-   repo: https://github.com/nbQA-dev/nbQA
    rev: 1.8.3
    hooks:
    - id: nbqa-black