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.
This commit is contained in:
Justin Chu 2022-05-16 13:26:56 -07:00 committed by GitHub
parent c556f5f22f
commit d9c9adb78b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 8 deletions

View file

@ -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

View file

@ -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
}

View file

@ -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