aboutsummaryrefslogtreecommitdiff
path: root/src/mlia/cli/logging.py
diff options
context:
space:
mode:
authorDmitrii Agibov <dmitrii.agibov@arm.com>2022-09-08 14:24:39 +0100
committerDmitrii Agibov <dmitrii.agibov@arm.com>2022-09-09 17:21:48 +0100
commitf5b293d0927506c2a979a091bf0d07ecc78fa181 (patch)
tree4de585b7cb6ed34da8237063752270189a730a41 /src/mlia/cli/logging.py
parentcde0c6ee140bd108849bff40467d8f18ffc332ef (diff)
downloadmlia-f5b293d0927506c2a979a091bf0d07ecc78fa181.tar.gz
MLIA-386 Simplify typing in the source code
- Enable deferred annotations evaluation - Use builtin types for type hints whenever possible - Use | syntax for union types - Rename mlia.core._typing into mlia.core.typing Change-Id: I3f6ffc02fa069c589bdd9e8bddbccd504285427a
Diffstat (limited to 'src/mlia/cli/logging.py')
-rw-r--r--src/mlia/cli/logging.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/mlia/cli/logging.py b/src/mlia/cli/logging.py
index c5fc7bd..40f47d3 100644
--- a/src/mlia/cli/logging.py
+++ b/src/mlia/cli/logging.py
@@ -1,12 +1,11 @@
# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
"""CLI logging configuration."""
+from __future__ import annotations
+
import logging
import sys
from pathlib import Path
-from typing import List
-from typing import Optional
-from typing import Union
from mlia.utils.logging import attach_handlers
from mlia.utils.logging import create_log_handler
@@ -18,7 +17,7 @@ _FILE_DEBUG_FORMAT = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
def setup_logging(
- logs_dir: Optional[Union[str, Path]] = None,
+ logs_dir: str | Path | None = None,
verbose: bool = False,
log_filename: str = "mlia.log",
) -> None:
@@ -49,10 +48,10 @@ def setup_logging(
def _get_mlia_handlers(
- logs_dir: Optional[Union[str, Path]],
+ logs_dir: str | Path | None,
log_filename: str,
verbose: bool,
-) -> List[logging.Handler]:
+) -> list[logging.Handler]:
"""Get handlers for the MLIA loggers."""
result = []
stdout_handler = create_log_handler(
@@ -84,10 +83,10 @@ def _get_mlia_handlers(
def _get_tools_handlers(
- logs_dir: Optional[Union[str, Path]],
+ logs_dir: str | Path | None,
log_filename: str,
verbose: bool,
-) -> List[logging.Handler]:
+) -> list[logging.Handler]:
"""Get handler for the tools loggers."""
result = []
if verbose:
@@ -110,7 +109,7 @@ def _get_tools_handlers(
return result
-def _get_log_file(logs_dir: Union[str, Path], log_filename: str) -> Path:
+def _get_log_file(logs_dir: str | Path, log_filename: str) -> Path:
"""Get the log file path."""
logs_dir_path = Path(logs_dir)
logs_dir_path.mkdir(exist_ok=True)