Skip to content

Commit 4ef5127

Browse files
authored
Add the flake8 for src directory (#210)
Signed-off-by: jiyeong.seok <[email protected]>
1 parent 192fbd8 commit 4ef5127

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

.github/workflows/pull-request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
pip install tox
3131
- name: Run Tox
3232
run: |
33+
tox -e release_flake8
3334
tox -e release
3435
reuse:
3536
runs-on: ubuntu-latest

src/fosslight_util/_get_downloadable_url.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def get_download_location_for_pypi(link):
121121
ret = True
122122
else:
123123
logger.warning(f'Cannot find the valid link for pypi (url:{new_link}')
124-
except Exception as e:
124+
except Exception:
125125
oss_name = re.sub(r"[-]+", "_", oss_name).lower()
126126
new_link = f'{host}/packages/source/{oss_name[0]}/{oss_name}/{oss_name}-{oss_version}.tar.gz'
127127
res = urlopen(new_link)

src/fosslight_util/exclude.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55

66
import os
77
import fnmatch
8+
from typing import List
89

9-
def excluding_files(patterns: list[str], path_to_scan: str) -> list[str]:
10+
11+
def excluding_files(patterns: List[str], path_to_scan: str) -> List[str]:
1012
excluded_paths = set()
1113

1214
# Normalize patterns: e.g., 'sample/', 'sample/*' -> 'sample'

src/fosslight_util/output_format.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def check_output_format(output='', format='', customized_format={}):
4848
if format:
4949
if output_extension != basename_extension:
5050
success = False
51-
msg = f"(-o & -f option) Enter the same extension of output file(-o:'{output}') with format(-f:'{format}')."
51+
msg = f"(-o & -f option) Enter the same extension of output file(-o:'{output}') \
52+
with format(-f:'{format}')."
5253
else:
5354
if basename_extension not in support_format.values():
5455
success = False
@@ -96,7 +97,8 @@ def check_output_formats(output='', formats=[], customized_format={}):
9697
if formats:
9798
if basename_extension not in output_extensions:
9899
success = False
99-
msg = f"(-o & -f option) The format of output file(-o:'{output}') should be in the format list(-f:'{formats}')."
100+
msg = f"(-o & -f option) The format of output file(-o:'{output}') \
101+
should be in the format list(-f:'{formats}')."
100102
else:
101103
if basename_extension not in support_format.values():
102104
success = False
@@ -145,7 +147,8 @@ def check_output_formats_v2(output='', formats=[], customized_format={}):
145147
if formats:
146148
if basename_extension not in output_extensions:
147149
success = False
148-
msg = f"(-o & -f option) The format of output file(-o:'{output}') should be in the format list(-f:'{formats}')."
150+
msg = f"(-o & -f option) The format of output file(-o:'{output}') \
151+
should be in the format list(-f:'{formats}')."
149152
else:
150153
if basename_extension not in support_format.values():
151154
success = False

src/fosslight_util/write_cyclonedx.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@
55
# SPDX-License-Identifier: Apache-2.0
66

77
import os
8-
import sys
98
import logging
109
import re
11-
import json
1210
from pathlib import Path
13-
from datetime import datetime
14-
from fosslight_util.spdx_licenses import get_spdx_licenses_json, get_license_from_nick
1511
from fosslight_util.constant import (LOGGER_NAME, FOSSLIGHT_DEPENDENCY, FOSSLIGHT_SCANNER,
16-
FOSSLIGHT_BINARY, FOSSLIGHT_SOURCE)
17-
from fosslight_util.oss_item import CHECKSUM_NULL, get_checksum_sha1
12+
FOSSLIGHT_SOURCE)
1813
import traceback
1914

2015
logger = logging.getLogger(LOGGER_NAME)
@@ -27,14 +22,11 @@
2722
from cyclonedx.model import XsUri, ExternalReferenceType
2823
from cyclonedx.model.bom import Bom
2924
from cyclonedx.model.component import Component, ComponentType, HashAlgorithm, HashType, ExternalReference
30-
from cyclonedx.model.contact import OrganizationalEntity
3125
from cyclonedx.output import make_outputter, BaseOutput
3226
from cyclonedx.output.json import JsonV1Dot6
3327
from cyclonedx.schema import OutputFormat, SchemaVersion
34-
from cyclonedx.validation import make_schemabased_validator
3528
from cyclonedx.validation.json import JsonStrictValidator
3629
from cyclonedx.output.json import Json as JsonOutputter
37-
from cyclonedx.output.xml import Xml as XmlOutputter
3830
from cyclonedx.validation.xml import XmlValidator
3931
except Exception:
4032
logger.info('No import cyclonedx-python-lib')
@@ -66,7 +58,6 @@ def write_cyclonedx(output_file_without_ext, output_extension, scan_item):
6658
type=ComponentType.APPLICATION,
6759
bom_ref=str(comp_id))
6860
relation_tree = {}
69-
bom_ref_packages = []
7061

7162
output_dir = os.path.dirname(output_file_without_ext)
7263
Path(output_dir).mkdir(parents=True, exist_ok=True)
@@ -113,7 +104,7 @@ def write_cyclonedx(output_file_without_ext, output_extension, scan_item):
113104
try:
114105
oss_licenses.append(lc_factory.make_from_string(ol))
115106
except Exception:
116-
logger.info(f'No spdx license name: {oi}')
107+
logger.info(f'No spdx license name: {ol}')
117108
if oss_licenses:
118109
comp.licenses = oss_licenses
119110

@@ -192,9 +183,9 @@ def write_cyclonedx_json(bom, result_file):
192183
except MissingOptionalDependencyException as error:
193184
logger.debug(f'JSON-validation was skipped due to {error}')
194185
except Exception as e:
186+
logger.warning(f'Fail to write cyclonedx json: {e}')
195187
success = False
196188
return success
197-
198189

199190

200191
def write_cyclonedx_xml(bom, result_file):
@@ -213,5 +204,6 @@ def write_cyclonedx_xml(bom, result_file):
213204
except MissingOptionalDependencyException as error:
214205
logger.debug(f'XML-validation was skipped due to {error}')
215206
except Exception as e:
207+
logger.warning(f'Fail to write cyclonedx xml: {e}')
216208
success = False
217-
return success
209+
return success

tox.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,10 @@ commands =
4141
# Test - run pytest
4242
pytest
4343

44+
[testenv:release_flake8]
45+
deps =
46+
-r{toxinidir}/requirements-dev.txt
47+
wheel = true
48+
commands =
4449
# Test - check PEP8
4550
pytest -v --flake8

0 commit comments

Comments
 (0)