Skip to content

Commit

Permalink
Add python static type checking in CI checks (#11518)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
justinchuby authored May 16, 2022
1 parent c556f5f commit d9c9adb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
24 changes: 17 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand All @@ -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
Expand Down Expand Up @@ -50,14 +52,22 @@ jobs:
reporter: github-pr-check
level: info
filter_mode: file
- name: markdownlint
uses: reviewdog/action-[email protected]
- 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/[email protected]
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
Expand Down
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d9c9adb

Please sign in to comment.