From d9c9adb78bf2a1ae4e272cb3888301d08fd5acd2 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Mon, 16 May 2022 13:26:56 -0700 Subject: [PATCH] Add python static type checking in CI checks (#11518) - Enable pyright and pylint (https://github.com/microsoft/pyright) in CI - Enable pyright, pylint and bandit by default in VS code Pylint has some good style checks. pyright is Microsoft's static type checker. --- .github/workflows/lint.yml | 24 +++++++++++++++++------- .vscode/settings.json | 4 +++- pyproject.toml | 7 +++++++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0f214e44cb..0f45163b5f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,7 +13,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: reviewdog/action-black@v3 + - name: black + uses: reviewdog/action-black@v3 with: github_token: ${{ secrets.github_token }} # Change reviewdog reporter if you need [github-pr-check, github-check, github-pr-review]. @@ -22,7 +23,8 @@ jobs: # GitHub Status Check won't become failure with a warning. level: error filter_mode: file - - uses: reviewdog/action-flake8@v3 + - name: flake8 + uses: reviewdog/action-flake8@v3 with: github_token: ${{ secrets.github_token }} reporter: github-pr-check @@ -50,14 +52,22 @@ jobs: reporter: github-pr-check level: info filter_mode: file - - name: markdownlint - uses: reviewdog/action-markdownlint@v0.7 + - name: pyright + uses: jordemort/action-pyright@v1 with: github_token: ${{ secrets.github_token }} reporter: github-pr-check - level: info - filter_mode: file - markdownlint_flags: ". --disable MD013 MD041 MD033 MD034" + level: warning + filter_mode: diff_context + lib: true + - name: pylint + uses: dciborow/action-pylint@0.0.7 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-check + level: warning + filter_mode: diff_context + glob_pattern: "**/*.py" lint-python-format: # Separated black/isort from other Python linters because we want this job to diff --git a/.vscode/settings.json b/.vscode/settings.json index f04de98af5..94a3a17c2c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -29,8 +29,10 @@ ], "python.linting.enabled": true, "python.linting.flake8Enabled": true, + "python.linting.pylintEnabled": true, "python.linting.pydocstyleEnabled": true, "python.linting.pydocstyleArgs": [ "--convention=google" - ] + ], + "python.linting.banditEnabled": true } diff --git a/pyproject.toml b/pyproject.toml index 7a3fe477d1..91e3c13440 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,3 +15,10 @@ extend_skip_glob = [ [tool.pydocstyle] convention = "google" + +[tool.pylint.'MESSAGES CONTROL'] +disable = ["format", "line-too-long", "import-error", "no-name-in-module"] + +[tool.pyright] +exclude = ["onnxruntime/core/flatbuffers/*"] +reportMissingImports = false