Skip to content

Commit

Permalink
Merge pull request #11 from SimeonEhrig/lintingActions
Browse files Browse the repository at this point in the history
add mypy and pylint to the CI
  • Loading branch information
SimeonEhrig authored Feb 12, 2024
2 parents 4661bd3 + 708c513 commit 20174e2
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 17 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: lint-code
on: [push, pull_request]
jobs:
mypy-linter:
name: run mypy linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.12"
architecture: x64
- name: Install bashi
run: |
pip install .
- name: Install mypy
run: |
pip install mypy
- name: Run mypy
run: |
mypy bashi
pylint-linter:
name: run pylint linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.12"
architecture: x64
- name: Install bashi
run: |
pip install .
- name: Install pylint
run: |
pip install pylint
- name: Run pylint
run: |
pylint bashi
6 changes: 4 additions & 2 deletions bashi/filter_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ def backend_filter_typechecked(
return backend_filter(row, output)


# TODO(SimeonEhrig): remove disable=unused-argument
# only required for the CI at the moment
def backend_filter(
row: ParameterValueTuple,
output: Optional[IO[str]] = None,
row: ParameterValueTuple, # pylint: disable=unused-argument
output: Optional[IO[str]] = None, # pylint: disable=unused-argument
) -> bool:
"""Filter rules basing on backend names and versions.
Expand Down
7 changes: 5 additions & 2 deletions bashi/filter_compiler_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ def compiler_version_filter_typechecked(
return compiler_version_filter(row, output)


# TODO(SimeonEhrig): remove disable=unused-argument
# only required for the CI at the moment
def compiler_version_filter(
row: ParameterValueTuple,
output: Optional[IO[str]] = None,
row: ParameterValueTuple, # pylint: disable=unused-argument
output: Optional[IO[str]] = None, # pylint: disable=unused-argument
) -> bool:
"""Filter rules basing on host and device compiler names and versions.
Expand All @@ -47,4 +49,5 @@ def compiler_version_filter(
Returns:
bool: True, if parameter-value-tuple is valid.
"""

return True
6 changes: 4 additions & 2 deletions bashi/filter_software_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ def software_dependency_filter_typechecked(
return software_dependency_filter(row, output)


# TODO(SimeonEhrig): remove disable=unused-argument
# only required for the CI at the moment
def software_dependency_filter(
row: ParameterValueTuple,
output: Optional[IO[str]] = None,
row: ParameterValueTuple, # pylint: disable=unused-argument
output: Optional[IO[str]] = None, # pylint: disable=unused-argument
) -> bool:
"""Filter rules handling software dependencies and compiler settings.
Expand Down
4 changes: 2 additions & 2 deletions bashi/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Dict, List
from collections import OrderedDict

from covertable import make
from covertable import make # type: ignore

from bashi.types import (
Parameter,
Expand Down Expand Up @@ -43,7 +43,7 @@ def generate_combination_list(

# convert List[Dict[Parameter, ParameterValue]] to CombinationList
for all_pair in all_pairs:
tmp_comb: Combination = OrderedDict()
tmp_comb: Combination = OrderedDict({})
# covertable does not keep the ordering of the parameters
# therefore we sort it
for param in parameter_value_matrix.keys():
Expand Down
4 changes: 2 additions & 2 deletions bashi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ def create_parameter_value_pair( # pylint: disable=too-many-arguments
if isinstance(value_version1, packaging.version.Version):
parsed_value_version1: packaging.version.Version = value_version1
else:
parsed_value_version1: packaging.version.Version = packaging.version.parse(
parsed_value_version1: packaging.version.Version = packaging.version.parse( # type: ignore
str(value_version1)
)

if isinstance(value_version2, packaging.version.Version):
parsed_value_version2: packaging.version.Version = value_version2
else:
parsed_value_version2: packaging.version.Version = packaging.version.parse(
parsed_value_version2: packaging.version.Version = packaging.version.parse( # type: ignore
str(value_version2)
)

Expand Down
12 changes: 6 additions & 6 deletions bashi/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ def check_single_filter(
if filter_func(row, msg):
print(cs(f"{filter_name}() returns True", "Green"))
return True
else:
print(cs(f"{filter_name}() returns False", "Red"))
if msg.getvalue() != "":
print(" " + msg.getvalue())
return False

print(cs(f"{filter_name}() returns False", "Red"))
if msg.getvalue() != "":
print(" " + msg.getvalue())
return False


@typechecked
Expand Down Expand Up @@ -276,7 +276,7 @@ def check_filter_chain(row: ParameterValueTuple) -> bool:
return all_true == 4


def main():
def main() -> None:
"""Entry point for the application."""
args = get_args()

Expand Down
3 changes: 2 additions & 1 deletion bashi/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ def is_supported_version(name: ValueName, version: ValueVersion) -> bool:
on: str = "1.0.0"

local_versions[CLANG_CUDA] = local_versions[CLANG]
local_versions[ALPAKA_ACC_GPU_CUDA_ENABLE] = [off] + VERSIONS[NVCC]
local_versions[ALPAKA_ACC_GPU_CUDA_ENABLE] = [off]
local_versions[ALPAKA_ACC_GPU_CUDA_ENABLE] += VERSIONS[NVCC]

for backend_name in BACKENDS:
if backend_name != ALPAKA_ACC_GPU_CUDA_ENABLE:
Expand Down

0 comments on commit 20174e2

Please sign in to comment.