forked from xapi-project/xen-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy action-mypy to review this PR
Signed-off-by: Bernhard Kaindl <[email protected]>
- Loading branch information
1 parent
06db91c
commit 1631639
Showing
5 changed files
with
237 additions
and
5 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,16 +14,18 @@ jobs: | |
strategy: | ||
fail-fast: false | ||
matrix: | ||
docker-image: # See https://hub.docker.com/_/python/tags for images | ||
- python:2.7.18-alpine3.11 | ||
- python:3.11.4-alpine3.18 | ||
container: ${{ matrix.docker-image }} | ||
python-version: ['2.7', '3.11'] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Python ${{matrix.python-version}} (without a container) | ||
uses: LizardByte/setup-python-action@master | ||
with: | ||
python-version: ${{matrix.python-version}} | ||
|
||
- name: Install python 2 dependencies | ||
if: ${{ startsWith(matrix.docker-image, 'python:2.7.18') }} | ||
if: ${{ matrix.python-version == '2.7' }} | ||
run: pip install enum | ||
|
||
- name: Install dependencies | ||
|
@@ -115,3 +117,51 @@ jobs: | |
|
||
- name: quality-gate | ||
run: make quality-gate | ||
|
||
- uses: reviewdog/action-actionlint@v1 | ||
name: GitHub Action linter from https://github.com/reviewdog/action-actionlint | ||
with: | ||
github_token: ${{ secrets.github_token }} | ||
level: error | ||
reporter: github-pr-review | ||
|
||
- uses: tsuyoshicho/[email protected] | ||
with: | ||
filter_mode: no_filter | ||
setup_method: install | ||
setup_command: pip install mypy mock | ||
mypy_flags: | | ||
--scripts-are-modules | ||
--check-untyped-defs | ||
--allow-redefinition | ||
--hide-error-context | ||
--ignore-missing-imports | ||
--no-pretty | ||
--warn-unreachable | ||
--exclude ocaml/ | ||
--exclude scripts/examples | ||
--exclude scripts/examples/python/monitor-unwanted-domains.py | ||
--exclude scripts/scalability-tests/ping-master.py | ||
--exclude scripts/backup-sr-metadata.py | ||
--exclude scripts/restore-sr-metadata.py | ||
--exclude scripts/nbd_client_manager.py | ||
--config-file mypy.ini | ||
target: | | ||
scripts/perfmon | ||
scripts/hfx_filename | ||
scripts/mail-alarm | ||
scripts/host-display | ||
github_token: ${{ secrets.github_token }} | ||
reporter: github-pr-review | ||
|
||
- uses: dciborow/[email protected] | ||
with: | ||
filter_mode: no_filter | ||
glob_pattern: "scripts/*" | ||
pylint_args: | | ||
--verbose | ||
--disable=trailing-whitespace | ||
--disable=bad-indentation | ||
--rc .pylintrc | ||
github_token: ${{ secrets.github_token }} | ||
reporter: github-pr-review |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Python Code Review | ||
on: [pull_request] | ||
|
||
# Cancel a currently running workflow from the same PR, branch or tag when | ||
# a new workflow is triggered: | ||
# https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre | ||
concurrency: | ||
cancel-in-progress: true | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
|
||
jobs: | ||
python-code-review: | ||
name: Python Code Review | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- uses: tsuyoshicho/[email protected] | ||
with: | ||
filter_mode: file | ||
setup_method: install | ||
setup_command: pip install mypy mock | ||
mypy_flags: | | ||
--scripts-are-modules | ||
--check-untyped-defs | ||
--allow-redefinition | ||
--ignore-missing-imports | ||
--no-pretty | ||
--warn-unreachable | ||
--exclude ocaml/ | ||
--exclude scripts/examples | ||
--exclude scripts/examples/python/monitor-unwanted-domains.py | ||
--exclude scripts/scalability-tests/ping-master.py | ||
--exclude scripts/backup-sr-metadata.py | ||
--exclude scripts/restore-sr-metadata.py | ||
--exclude scripts/nbd_client_manager.py | ||
--config-file .mypy.ini | ||
target: | | ||
scripts/perfmon | ||
scripts/hfx_filename | ||
scripts/mail-alarm | ||
scripts/host-display | ||
github_token: ${{ secrets.github_token }} | ||
reporter: github-pr-review | ||
|
||
- uses: dciborow/[email protected] | ||
with: | ||
filter_mode: file | ||
glob_pattern: "scripts/*" | ||
github_token: ${{ secrets.github_token }} | ||
reporter: github-pr-review | ||
|
||
- uses: reviewdog/action-actionlint@v1 | ||
name: GitHub Action linter from https://github.com/reviewdog/action-actionlint | ||
with: | ||
github_token: ${{ secrets.github_token }} | ||
level: error | ||
reporter: github-pr-review |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
[MAIN] | ||
|
||
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the | ||
# number of processors available to use, and will cap the count on Windows to | ||
# avoid hangs. | ||
jobs=2 | ||
|
||
# Pickle collected data for later comparisons. | ||
persistent=yes | ||
|
||
# Discover python modules and packages in the file system subtree. | ||
recursive=yes | ||
|
||
# Add paths to the list of the source roots. Supports globbing patterns. The | ||
# source root is an absolute path or a path relative to the current working | ||
# directory used to determine a package namespace for modules located under the | ||
# source root. | ||
source-roots= | ||
ocaml/xapi-storage/python, | ||
scripts, | ||
scripts/examples/python, | ||
|
||
# When enabled, pylint would attempt to guess common misconfiguration and emit | ||
# user-friendly hints instead of false-positive error messages. | ||
suggestion-mode=yes | ||
|
||
# In verbose mode, extra non-checker-related info will be displayed. | ||
verbose=yes | ||
|
||
[MESSAGES CONTROL] | ||
|
||
# Disable the message, report, category or checker with the given id(s). You | ||
# can either give multiple identifiers separated by comma (,) or put this | ||
# option multiple times (only on the command line, not in the configuration | ||
# file where it should appear only once). You can also use "--disable=all" to | ||
# disable everything first and then re-enable specific checks. For example, if | ||
# you want to run only the similarities checker, you can use "--disable=all | ||
# --enable=similarities". If you want to run only the classes checker, but have | ||
# no Warning level messages displayed, use "--disable=all --enable=classes | ||
# --disable=W". | ||
disable= | ||
bad-option-value, # old pylint for py2: ignore newer (unknown) pylint options | ||
bad-continuation, # old pylint warns about some modern black formatting | ||
bad-indentation, | ||
consider-using-dict-comprehension, | ||
consider-using-f-string, | ||
consider-using-with, | ||
import-error, | ||
import-outside-toplevel, | ||
invalid-name, | ||
missing-final-newline, | ||
missing-function-docstring, | ||
multiple-imports, | ||
redefined-outer-name, | ||
trailing-whitespace, # enable this soon, after citical PRs are merged | ||
useless-option-value, # new pylint has abaondoned these old options | ||
|
||
[FORMAT] | ||
|
||
# Maximum number of characters on a single line. | ||
max-line-length=98 | ||
|
||
[BASIC] | ||
|
||
# Good variable names which should always be accepted, separated by a comma. | ||
good-names=a, | ||
b, | ||
c, | ||
f, | ||
i, | ||
j, | ||
k, | ||
ex, | ||
Run, | ||
_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
[mypy-XenAPI.*] | ||
# TODO/FIXME: | ||
disable_error_code = union-attr | ||
[mypy] | ||
# TODO/FIXME: | ||
exclude = (?x)( | ||
^ocaml/ | ||
| scripts/.*usb_scan.py | ||
| scripts/examples | ||
| scripts/examples/python/monitor-unwanted-domains.py | ||
| scripts/scalability-tests/ping-master.py | ||
| scripts/backup-sr-metadata.py | ||
| scripts/restore-sr-metadata.py | ||
| scripts/nbd_client_manager.py | ||
) | ||
# Python scripts that don't end in .py must be given here: | ||
files = | ||
# TODO/FIXME: Test more scripts by default after those are fixed: | ||
scripts/hfx_filename, | ||
scripts/perfmon, | ||
scripts/mail-alarm, | ||
scripts/host-display, | ||
# TODO/FIXME: | ||
disable_error_code = | ||
attr-defined, | ||
import-not-found, | ||
import-untyped, | ||
type-arg, | ||
var-annotated, | ||
mypy_path = scripts/examples/python:.:scripts:scripts/plugins:scripts/examples | ||
pretty = true | ||
error_summary = true | ||
strict_equality = true | ||
show_error_codes = true | ||
show_error_context = true | ||
# Check the contents of untyped functions in all modules by default: | ||
check_untyped_defs = true | ||
scripts_are_modules = true | ||
# TODO/FIXME: mypy does not support targetting 3.6 anymore: | ||
python_version = 3.8 | ||
warn_return_any = true | ||
warn_unreachable = true | ||
warn_unused_configs = true | ||
warn_redundant_casts = true | ||
disallow_any_explicit = false | ||
disallow_any_generics = true | ||
disallow_any_unimported = true | ||
disallow_subclassing_any = true |