Skip to content

Commit 196406d

Browse files
committed
fix: explicit typing for LOGGER and unify usage in engine/tests (#2870)
1 parent e456daf commit 196406d

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

cve_bin_tool/log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ def filter(self, record):
4242
# Add the handlers to the root logger
4343
root_logger = logging.getLogger()
4444

45-
LOGGER = logging.getLogger(__package__)
45+
LOGGER: logging.Logger = logging.getLogger(__package__)
4646
LOGGER.setLevel(logging.INFO)

test/pages/html_report.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (C) 2024 Intel Corporation
22
# SPDX-License-Identifier: GPL-3.0-or-later
33

4-
import logging
4+
from cve_bin_tool.log import LOGGER
55
import os
66
from pathlib import Path
77
from tempfile import NamedTemporaryFile
@@ -25,7 +25,7 @@ def __init__(
2525
"w+", delete=False, suffix=".html", encoding="utf-8"
2626
)
2727

28-
logger = logging.getLogger()
28+
logger = LOGGER
2929

3030
intermediate_report = None
3131

test/test_output_engine.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
from pathlib import Path
1616
from unittest.mock import MagicMock, call, patch
1717

18+
from cve_bin_tool.log import LOGGER
19+
1820
from jsonschema import validate
1921
from jsonschema.exceptions import ValidationError
2022
from rich.console import Console
@@ -1432,7 +1434,7 @@ def test_output_console_metrics_false(self):
14321434

14331435
def test_output_file(self):
14341436
"""Test file generation logic in output_file"""
1435-
logger = logging.getLogger()
1437+
logger = LOGGER
14361438

14371439
with self.assertLogs(logger, logging.INFO) as cm:
14381440
self.output_engine.output_file(output_type="json")
@@ -1467,7 +1469,7 @@ def test_csv_output_file(self):
14671469

14681470
def test_output_file_wrapper(self):
14691471
"""Test file generation logic in output_file_wrapper"""
1470-
logger = logging.getLogger()
1472+
logger = LOGGER
14711473
self.output_engine.filename = "test-report"
14721474

14731475
with self.assertLogs(logger, logging.INFO) as cm:
@@ -1507,7 +1509,7 @@ def test_output_file_filename_already_exists(self):
15071509
with open("testfile.csv", "w") as f:
15081510
f.write("testing")
15091511

1510-
logger = logging.getLogger()
1512+
logger = LOGGER
15111513

15121514
# setup the context manager
15131515
with self.assertLogs(logger, logging.INFO) as cm:
@@ -1545,7 +1547,7 @@ def test_output_file_incorrect_filename(self):
15451547
# update the filename in output_engine
15461548
self.output_engine.filename = "/not/a/good_filename"
15471549

1548-
logger = logging.getLogger()
1550+
logger = LOGGER
15491551

15501552
# setup the context manager
15511553
with self.assertLogs(logger, logging.INFO) as cm:

0 commit comments

Comments
 (0)