diff --git a/.github/workflows/py_checks.yml b/.github/workflows/py_checks.yml index 5010a6c7535..c068fe31ee7 100644 --- a/.github/workflows/py_checks.yml +++ b/.github/workflows/py_checks.yml @@ -151,3 +151,16 @@ jobs: - name: Run Bandit run: python -m bandit -r ./ -f screen working-directory: src/bindings/python/src/compatibility/openvino + + # layer_tests Flake code-style + - name: Run flake8 on python tests in openvino/tests/layer_tests + run: | + modified_files=$(git diff --name-only) + for file in $modified_files; do + if [[ $file == "openvino/tests/layer_tests/"* ]]; then + if [[ -f "$file" ]]; then + python -m flake8 "$file" --config= ./setup.cfg + fi + fi + done + diff --git a/tests/layer_tests/common/constants.py b/tests/layer_tests/common/constants.py index 5e7f8313776..18089f4b4f3 100644 --- a/tests/layer_tests/common/constants.py +++ b/tests/layer_tests/common/constants.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 diff --git a/tests/layer_tests/common/logger.py b/tests/layer_tests/common/logger.py index 18977c28ea7..f7c9cf3cb12 100644 --- a/tests/layer_tests/common/logger.py +++ b/tests/layer_tests/common/logger.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright (C) 2022 Intel Corporation # SPDX-License-Identifier: Apache-2.0 @@ -8,10 +9,12 @@ import re class TagFilter(log.Filter): def __init__(self, regex): + """Initialize the TagFilter with a regular expression.""" log.Filter.__init__(self) self.regex = regex - def filter(self, record): + def filter(self, record): # noqa: A003 + """Filter the log record based on the provided regex.""" if record.__dict__['funcName'] == 'load_grammar': # for nx not to log into our logs return False if self.regex: @@ -20,15 +23,16 @@ class TagFilter(log.Filter): return re.findall(self.regex, tag) else: return False - else: # if regex wasn't set print all logs + else: # if regex wasn't set, print all logs return True def init_logger(lvl): + """Initialize the logger with the specified log level.""" logger = log.getLogger(__name__) log_exp = os.environ.get('MO_LOG_PATTERN') log.basicConfig( format='%(levelname)s: %(module)s. %(funcName)s():%(lineno)d - %(message)s', - level=lvl + level=lvl, ) logger.addFilter(TagFilter(log_exp))