Skip to content

Commit

Permalink
fix: multiple warnings fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoPascoli committed Jan 27, 2025
1 parent f213a26 commit d43d9f9
Show file tree
Hide file tree
Showing 24 changed files with 23 additions and 42 deletions.
2 changes: 0 additions & 2 deletions antarest/core/maintenance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

from typing import Optional

from fastapi import APIRouter, FastAPI

from antarest.core.application import AppBuildContext
from antarest.core.config import Config
from antarest.core.interfaces.cache import ICache
Expand Down
2 changes: 0 additions & 2 deletions antarest/core/tasks/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

from typing import Optional

from fastapi import APIRouter, FastAPI

from antarest.core.application import AppBuildContext
from antarest.core.config import Config
from antarest.core.interfaces.eventbus import DummyEventBusService, IEventBus
Expand Down
1 change: 0 additions & 1 deletion antarest/eventbus/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from typing import Optional

from fastapi import APIRouter, FastAPI
from redis import Redis

from antarest.core.application import AppBuildContext
Expand Down
1 change: 0 additions & 1 deletion antarest/eventbus/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import logging
import random
import threading
import time
import uuid
from typing import Awaitable, Callable, Dict, List, Optional

Expand Down
5 changes: 4 additions & 1 deletion antarest/fastapi_jwt_auth/auth_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,15 @@ def _verify_and_get_jwt_in_cookies(
if not isinstance(request, (Request, WebSocket)):
raise TypeError("request must be an instance of 'Request' or 'WebSocket'")

cookie = None
cookie_key = None

if type_token == "access":
cookie_key = self._access_cookie_key
cookie = request.cookies.get(cookie_key)
if not isinstance(request, WebSocket):
csrf_token = request.headers.get(self._access_csrf_header_name)
if type_token == "refresh":
elif type_token == "refresh":
cookie_key = self._refresh_cookie_key
cookie = request.cookies.get(cookie_key)
if not isinstance(request, WebSocket):
Expand Down
3 changes: 1 addition & 2 deletions antarest/front.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
what are the API and websocket prefixes
"""

import re
from pathlib import Path
from typing import Any, List, Optional, Sequence
from typing import Any, List, Optional

from fastapi import FastAPI
from starlette.middleware.base import BaseHTTPMiddleware, DispatchFunction, RequestResponseEndpoint
Expand Down
2 changes: 0 additions & 2 deletions antarest/launcher/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

from typing import Optional

from fastapi import APIRouter, FastAPI

from antarest.core.application import AppBuildContext
from antarest.core.config import Config
from antarest.core.filetransfer.service import FileTransferManager
Expand Down
2 changes: 0 additions & 2 deletions antarest/matrixstore/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

from typing import Optional

from fastapi import APIRouter, FastAPI

from antarest.core.application import AppBuildContext
from antarest.core.config import Config
from antarest.core.filetransfer.service import FileTransferManager
Expand Down
2 changes: 1 addition & 1 deletion antarest/study/business/advanced_parameters_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def get_value(field_info: FieldInfo) -> Any:
parent = seeds
return parent.get(target_name, field_info["default_value"])

return AdvancedParamsFormFields.construct(**{name: get_value(info) for name, info in FIELDS_INFO.items()})
return AdvancedParamsFormFields.model_construct(**{name: get_value(info) for name, info in FIELDS_INFO.items()})

def set_field_values(self, study: Study, field_values: AdvancedParamsFormFields) -> None:
"""
Expand Down
4 changes: 2 additions & 2 deletions antarest/study/business/allocation_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def set_allocation_form_fields(

updated_allocations = self.get_allocation_data(study, area_id)

return AllocationFormFields.construct(
return AllocationFormFields.model_construct(
allocation=[
AllocationField.construct(area_id=area, coefficient=value)
for area, value in updated_allocations.items()
Expand Down Expand Up @@ -250,4 +250,4 @@ def get_allocation_matrix(self, study: Study, all_areas: List[AreaInfoDTO]) -> A
col_idx = columns.index(prod_area)
array[row_idx][col_idx] = coefficient

return AllocationMatrix.construct(index=rows, columns=columns, data=array.tolist())
return AllocationMatrix.model_construct(index=rows, columns=columns, data=array.tolist())
2 changes: 1 addition & 1 deletion antarest/study/business/area_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def update_areas_props(

@staticmethod
def get_table_schema() -> JSON:
return AreaOutput.schema()
return AreaOutput.model_json_schema()

def get_all_areas(self, study: RawStudy, area_type: t.Optional[AreaType] = None) -> t.List[AreaInfoDTO]:
"""
Expand Down
4 changes: 2 additions & 2 deletions antarest/study/business/areas/hydro_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#
# This file is part of the Antares project.

from typing import Any, Dict, List, Optional, Union
from typing import Any, Dict, List

from pydantic import Field, model_validator
from pydantic import Field

from antarest.study.business.all_optional_meta import all_optional_model
from antarest.study.business.utils import FieldInfo, FormFieldsBaseModel, execute_or_add_commands
Expand Down
2 changes: 1 addition & 1 deletion antarest/study/business/areas/renewable_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,4 +427,4 @@ def update_renewables_props(

@staticmethod
def get_table_schema() -> JSON:
return RenewableClusterOutput.schema()
return RenewableClusterOutput.model_json_schema()
2 changes: 1 addition & 1 deletion antarest/study/business/areas/st_storage_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,4 +718,4 @@ def validate_matrix(matrix_type: STStorageTimeSeries) -> STStorageMatrix:

@staticmethod
def get_table_schema() -> JSON:
return STStorageOutput.schema()
return STStorageOutput.model_json_schema()
2 changes: 1 addition & 1 deletion antarest/study/business/areas/thermal_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def update_thermals_props(

@staticmethod
def get_table_schema() -> JSON:
return ThermalClusterOutput.schema()
return ThermalClusterOutput.model_json_schema()

def create_cluster(self, study: Study, area_id: str, cluster_data: ThermalClusterCreation) -> ThermalClusterOutput:
"""
Expand Down
2 changes: 1 addition & 1 deletion antarest/study/business/binding_constraint_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ def remove_constraint_term(

@staticmethod
def get_table_schema() -> JSON:
return ConstraintOutput870.schema()
return ConstraintOutput870.model_json_schema()


def _replace_matrices_according_to_frequency_and_version(
Expand Down
9 changes: 5 additions & 4 deletions antarest/study/business/model/link_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#
# This file is part of the Antares project.
import typing as t
from dataclasses import field

from antares.study.version import StudyVersion
from pydantic import BeforeValidator, ConfigDict, Field, PlainSerializer, model_validator
Expand Down Expand Up @@ -154,8 +155,8 @@ class LinkBaseDTO(AntaresBaseModel):
colorg: int = Field(default=DEFAULT_COLOR, ge=0, le=255)
link_width: float = 1
link_style: LinkStyle = LinkStyle.PLAIN
filter_synthesis: t.Optional[comma_separated_enum_list] = FILTER_VALUES
filter_year_by_year: t.Optional[comma_separated_enum_list] = FILTER_VALUES
filter_synthesis: t.Optional[comma_separated_enum_list] = field(default_factory=lambda: FILTER_VALUES)
filter_year_by_year: t.Optional[comma_separated_enum_list] = field(default_factory=lambda: FILTER_VALUES)


class Area(AntaresBaseModel):
Expand Down Expand Up @@ -203,8 +204,8 @@ class LinkInternal(AntaresBaseModel):
colorg: int = Field(default=DEFAULT_COLOR, ge=0, le=255)
link_width: float = 1
link_style: LinkStyle = LinkStyle.PLAIN
filter_synthesis: t.Optional[comma_separated_enum_list] = FILTER_VALUES
filter_year_by_year: t.Optional[comma_separated_enum_list] = FILTER_VALUES
filter_synthesis: t.Optional[comma_separated_enum_list] = field(default_factory=lambda: FILTER_VALUES)
filter_year_by_year: t.Optional[comma_separated_enum_list] = field(default_factory=lambda: FILTER_VALUES)

def to_dto(self) -> LinkDTO:
data = self.model_dump()
Expand Down
1 change: 0 additions & 1 deletion antarest/study/business/optimization_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from typing import Any, Dict, List, Union, cast

from antares.study.version import StudyVersion
from pydantic.types import StrictBool

from antarest.study.business.all_optional_meta import all_optional_model
Expand Down
2 changes: 0 additions & 2 deletions antarest/study/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

from typing import Optional

from fastapi import APIRouter, FastAPI

from antarest.core.application import AppBuildContext
from antarest.core.config import Config
from antarest.core.filetransfer.service import FileTransferManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,11 @@
from enum import Enum
from pathlib import Path

import py7zr
from antares.study.version import StudyVersion

from antarest.core.model import JSON
from antarest.core.serialization import from_json
from antarest.core.utils.archives import (
ArchiveFormat,
extract_lines_from_archive,
is_archive_format,
read_file_from_archive,
)
from antarest.core.utils.archives import extract_lines_from_archive, is_archive_format, read_file_from_archive
from antarest.study.model import STUDY_VERSION_8_1, STUDY_VERSION_8_6
from antarest.study.storage.rawstudy.ini_reader import IniReader
from antarest.study.storage.rawstudy.model.filesystem.config.binding_constraint import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#
# This file is part of the Antares project.

from antares.study.version import StudyVersion

from antarest.study.model import STUDY_VERSION_6_5
from antarest.study.storage.rawstudy.model.filesystem.config.model import FileStudyTreeConfig
from antarest.study.storage.rawstudy.model.filesystem.context import ContextServer
Expand Down
1 change: 0 additions & 1 deletion antarest/study/storage/rawstudy/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# This file is part of the Antares project.

import logging
import re
import tempfile
from html import escape
from pathlib import Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import shutil
import uuid
from pathlib import Path
from typing import Any, Callable, List, Optional, Tuple, Union, cast
from typing import Callable, List, Optional, Tuple, Union, cast

from antarest.core.utils.utils import StopWatch
from antarest.study.storage.rawstudy.model.filesystem.config.model import FileStudyTreeConfig
Expand Down
2 changes: 1 addition & 1 deletion antarest/tools/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from antarest.study.storage.variantstudy.business.matrix_constants_generator import GeneratorMatrixConstants
from antarest.study.storage.variantstudy.command_factory import CommandFactory
from antarest.study.storage.variantstudy.model.command.icommand import ICommand
from antarest.study.storage.variantstudy.model.model import CommandDTO, CommandDTOAPI, GenerationResultInfoDTO
from antarest.study.storage.variantstudy.model.model import CommandDTO, GenerationResultInfoDTO
from antarest.study.storage.variantstudy.variant_command_extractor import VariantCommandsExtractor
from antarest.study.storage.variantstudy.variant_command_generator import VariantCommandGenerator

Expand Down

0 comments on commit d43d9f9

Please sign in to comment.