From b1589230c7758758ea21775940203d30662e41d9 Mon Sep 17 00:00:00 2001 From: "jiyeong.seok" Date: Tue, 25 Mar 2025 11:46:59 +0900 Subject: [PATCH] Change flake8 github action Signed-off-by: jiyeong.seok --- .github/workflows/pull-request.yml | 1 + src/fosslight_dependency/package_manager/Cargo.py | 4 ++-- tests/pytest/package_manager/test_android.py | 2 +- tests/pytest/package_manager/test_cargo.py | 2 +- tests/pytest/package_manager/test_gradle.py | 2 +- tests/pytest/package_manager/test_maven.py | 2 +- tests/pytest/package_manager/test_mod.py | 2 +- tests/pytest/package_manager/test_nuget.py | 2 +- tests/pytest/package_manager/test_pub.py | 2 +- tests/pytest/package_manager/test_pypi.py | 2 +- tox.ini | 12 +++++++----- 11 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 8ffb9319..9e64d440 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -30,6 +30,7 @@ jobs: sudo npm install -g license-checker - name: Run Tox run: | + tox -e release_flake8 tox -e run_ubuntu build_windows: runs-on: windows-latest diff --git a/src/fosslight_dependency/package_manager/Cargo.py b/src/fosslight_dependency/package_manager/Cargo.py index fcceda0f..eb742d91 100644 --- a/src/fosslight_dependency/package_manager/Cargo.py +++ b/src/fosslight_dependency/package_manager/Cargo.py @@ -132,11 +132,11 @@ def get_matched_dependencies(match_id, resolve_node): try: match = re.findall(r'^.*#(\S*)@(\S*)', dep_pkg) dependencies_list.append(f'{match[0][0]}({match[0][1]})') - except: + except Exception: try: match = re.findall(r'^(\S*)\s(\S*)\s', dep_pkg) dependencies_list.append(f'{match[0][0]}({match[0][1]})') - except: + except Exception: logger.info(f'cannot find name and version for dependencies: {match_id}') pass break diff --git a/tests/pytest/package_manager/test_android.py b/tests/pytest/package_manager/test_android.py index 52cd5474..443a41fc 100644 --- a/tests/pytest/package_manager/test_android.py +++ b/tests/pytest/package_manager/test_android.py @@ -6,7 +6,7 @@ import pytest import subprocess -DIST_PATH = os.path.join(os.environ.get("TOX_PATH"), "dist", "cli.exe") +DIST_PATH = os.path.join(os.environ.get("TOX_PATH", ""), "dist", "cli.exe") @pytest.mark.parametrize("input_path, output_path, extra_args", [ diff --git a/tests/pytest/package_manager/test_cargo.py b/tests/pytest/package_manager/test_cargo.py index 60e1f057..2269ef89 100644 --- a/tests/pytest/package_manager/test_cargo.py +++ b/tests/pytest/package_manager/test_cargo.py @@ -6,7 +6,7 @@ import pytest import subprocess -DIST_PATH = os.path.join(os.environ.get("TOX_PATH"), "dist", "cli.exe") +DIST_PATH = os.path.join(os.environ.get("TOX_PATH", ""), "dist", "cli.exe") @pytest.mark.parametrize("input_path, output_path", [ diff --git a/tests/pytest/package_manager/test_gradle.py b/tests/pytest/package_manager/test_gradle.py index 35e16c11..450942ae 100644 --- a/tests/pytest/package_manager/test_gradle.py +++ b/tests/pytest/package_manager/test_gradle.py @@ -6,7 +6,7 @@ import pytest import subprocess -DIST_PATH = os.path.join(os.environ.get("TOX_PATH"), "dist", "cli.exe") +DIST_PATH = os.path.join(os.environ.get("TOX_PATH", ""), "dist", "cli.exe") @pytest.mark.parametrize("input_path, output_path", [ diff --git a/tests/pytest/package_manager/test_maven.py b/tests/pytest/package_manager/test_maven.py index 58f26ab3..13653203 100644 --- a/tests/pytest/package_manager/test_maven.py +++ b/tests/pytest/package_manager/test_maven.py @@ -6,7 +6,7 @@ import pytest import subprocess -DIST_PATH = os.path.join(os.environ.get("TOX_PATH"), "dist", "cli.exe") +DIST_PATH = os.path.join(os.environ.get("TOX_PATH", ""), "dist", "cli.exe") @pytest.mark.parametrize("input_path, output_path", [ diff --git a/tests/pytest/package_manager/test_mod.py b/tests/pytest/package_manager/test_mod.py index e7c51c37..f2108375 100644 --- a/tests/pytest/package_manager/test_mod.py +++ b/tests/pytest/package_manager/test_mod.py @@ -7,7 +7,7 @@ import subprocess -DIST_PATH = os.path.join(os.environ.get("TOX_PATH"), "dist", "cli.exe") +DIST_PATH = os.path.join(os.environ.get("TOX_PATH", ""), "dist", "cli.exe") @pytest.mark.parametrize("input_path, output_path, extra_args", [ diff --git a/tests/pytest/package_manager/test_nuget.py b/tests/pytest/package_manager/test_nuget.py index c46f3628..6d612d0b 100644 --- a/tests/pytest/package_manager/test_nuget.py +++ b/tests/pytest/package_manager/test_nuget.py @@ -11,7 +11,7 @@ "fosslight_dependency -p tests/test_nuget2 -o tests/result/nuget2" ] -DIST_PATH = os.path.join(os.environ.get("TOX_PATH"), "dist", "cli.exe") +DIST_PATH = os.path.join(os.environ.get("TOX_PATH", ""), "dist", "cli.exe") @pytest.mark.parametrize("input_path, output_path", [ diff --git a/tests/pytest/package_manager/test_pub.py b/tests/pytest/package_manager/test_pub.py index a4a3e900..5786984c 100644 --- a/tests/pytest/package_manager/test_pub.py +++ b/tests/pytest/package_manager/test_pub.py @@ -6,7 +6,7 @@ import pytest import subprocess -DIST_PATH = os.path.join(os.environ.get("TOX_PATH"), "dist", "cli.exe") +DIST_PATH = os.path.join(os.environ.get("TOX_PATH", ""), "dist", "cli.exe") @pytest.mark.parametrize("input_path, output_path", [ diff --git a/tests/pytest/package_manager/test_pypi.py b/tests/pytest/package_manager/test_pypi.py index 2b63fe82..024a044e 100644 --- a/tests/pytest/package_manager/test_pypi.py +++ b/tests/pytest/package_manager/test_pypi.py @@ -6,7 +6,7 @@ import pytest import subprocess -DIST_PATH = os.path.join(os.environ.get("TOX_PATH"), "dist", "cli.exe") +DIST_PATH = os.path.join(os.environ.get("TOX_PATH", ""), "dist", "cli.exe") @pytest.mark.parametrize("input_path, output_path, extra_args", [ diff --git a/tox.ini b/tox.ini index 219bd08d..7bf63df7 100644 --- a/tox.ini +++ b/tox.ini @@ -23,7 +23,6 @@ markers = [flake8] max-line-length = 130 exclude = .tox/* -ignore = E722, W503 [testenv:test_run] deps = @@ -31,10 +30,8 @@ deps = commands = # Print Help Message fosslight_dependency -h - # Print Current Version - fosslight_dependency -v # Test for PEP8 - pytest -v --flake8 + pytest -v --flake8 src [testenv:run_ubuntu] deps = @@ -49,4 +46,9 @@ commands = # Test for making excutable file pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks --add-binary=LICENSE:LICENSES --add-binary=LICENSES\LicenseRef-3rd_party_licenses.txt:LICENSES --collect-datas fosslight_util --hidden-import=_cffi_backend pytest -m "windows" - pytest -v --flake8 + +[testenv:release_flake8] +deps = + -r{toxinidir}/requirements-dev.txt +commands = + pytest -v --flake8 src