Skip to content

Commit

Permalink
mypy + ruff + isort
Browse files Browse the repository at this point in the history
  • Loading branch information
killian-scalian committed Jan 22, 2025
1 parent 3787580 commit 4bd5410
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 13 deletions.
13 changes: 8 additions & 5 deletions src/andromede/input_converter/src/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,29 @@
# SPDX-License-Identifier: MPL-2.0
#
# This file is part of the Antares project.
import logging
from pathlib import Path
from typing import Union
from typing import Optional, Union

from antares.craft.model.area import Area
from antares.craft.model.study import Study, read_study_local
from pandas import DataFrame

from andromede.input_converter.src.utils import resolve_path, transform_to_yaml
from andromede.study.parsing import (
InputComponent,
InputComponentParameter,
InputStudy,
InputPortConnections,
InputStudy,
)
from pandas import DataFrame
import logging


class AntaresStudyConverter:
def __init__(
self, study_input: Union[Path, Study], logger: logging, output_path: Path = None
self,
study_input: Union[Path, Study],
logger: logging.Logger,
output_path: Optional[Path] = None,
):
"""
Initialize processor
Expand Down
14 changes: 13 additions & 1 deletion src/andromede/input_converter/src/logger.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
# Copyright (c) 2024, RTE (https://www.rte-france.com)
#
# See AUTHORS.txt
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# SPDX-License-Identifier: MPL-2.0
#
# This file is part of the Antares project.
import logging
import logging.config
import sys
from typing import Optional


def Logger(name, file_name=None):
def Logger(name: str, file_name: Optional[str]) -> logging.Logger:
formatter = logging.Formatter(
fmt="%(asctime)s %(module)s,line: %(lineno)d %(levelname)8s | %(message)s",
datefmt="%Y/%m/%d %H:%M:%S",
Expand Down
25 changes: 18 additions & 7 deletions src/andromede/input_converter/src/main.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
from argparse import ArgumentParser, Namespace, ArgumentTypeError
from configparser import ConfigParser
# Copyright (c) 2024, RTE (https://www.rte-france.com)
#
# See AUTHORS.txt
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# SPDX-License-Identifier: MPL-2.0
#
# This file is part of the Antares project.
import logging
import os
import sys
from argparse import ArgumentParser, ArgumentTypeError, Namespace
from configparser import ConfigParser
from pathlib import Path
from __init__ import __version__
from converter import AntaresStudyConverter

from logger import Logger

from . import __version__
from .converter import AntaresStudyConverter
from .logger import Logger

DEFAULT: dict = {}
LOGGER_PATH: str = os.path.join(os.path.dirname(__file__), "../data/logging.log")
Expand Down Expand Up @@ -136,7 +147,7 @@ def parse_commandline() -> Namespace:
if __name__ == "__main__":
config: dict = {}
args = parse_commandline()
logger = Logger(__name__, args.logging)
logger: logging.Logger = Logger(__name__, args.logging)
config_parser = ConfigParser()

# Load the default configuration dictionary into the config parser.
Expand Down
11 changes: 11 additions & 0 deletions src/andromede/input_converter/src/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Copyright (c) 2024, RTE (https://www.rte-france.com)
#
# See AUTHORS.txt
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# SPDX-License-Identifier: MPL-2.0
#
# This file is part of the Antares project.
from pathlib import Path

import yaml
Expand Down

0 comments on commit 4bd5410

Please sign in to comment.