Skip to content

Commit d2db7bd

Browse files
committed
Make mypy and pyright optional.
1 parent b23c4a2 commit d2db7bd

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

analyze-project/action.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,25 @@ inputs:
1919
runs:
2020
using: composite
2121
steps:
22-
- name: Get package name and version
22+
- name: Check for mypy and pyright installation
23+
id: check_tools
24+
run: |
25+
python - <<EOF
26+
import os
27+
from importlib.metadata import version, PackageNotFoundError
28+
29+
def is_installed(pkg_name):
30+
try:
31+
version(pkg_name)
32+
return "true"
33+
except PackageNotFoundError:
34+
return "false"
35+
36+
print(f"::set-output name=mypy::{is_installed('mypy')}")
37+
print(f"::set-output name=pyright::{is_installed('pyright')}")
38+
EOF
39+
shell: bash
40+
- name: Get package name and version
2341
id: get_package_info
2442
run: |
2543
result=$(poetry version -C "${{ inputs.project-directory }}")
@@ -54,10 +72,12 @@ runs:
5472
working-directory: ${{ inputs.project-directory }}
5573
shell: bash
5674
- name: Mypy static analysis
75+
if: steps.check_tools.outputs.mypy == 'true'
5776
run: poetry run mypy
5877
working-directory: ${{ inputs.project-directory }}
5978
shell: bash
6079
- name: Add virtualenv to the path for pyright-action
80+
if: steps.check_tools.outputs.pyright == 'true'
6181
shell: bash
6282
run: |
6383
VENV_PATH="$(poetry env info --path)"
@@ -68,6 +88,7 @@ runs:
6888
fi
6989
working-directory: ${{ inputs.project-directory }}
7090
- name: Pyright static analysis
91+
if: steps.check_tools.outputs.pyright == 'true'
7192
uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2
7293
with:
7394
version: PATH

0 commit comments

Comments
 (0)