Skip to content

Commit

Permalink
style: sort imports in project base code and unit tests using `line_l…
Browse files Browse the repository at this point in the history
…ength = 120`
  • Loading branch information
laurent-laporte-pro committed Sep 1, 2023
1 parent 586fb43 commit 13a5929
Show file tree
Hide file tree
Showing 308 changed files with 1,035 additions and 3,547 deletions.
10 changes: 1 addition & 9 deletions antarest/core/configdata/model.py
Expand Up @@ -2,15 +2,7 @@
from typing import Any, Optional

from pydantic import BaseModel
from sqlalchemy import ( # type: ignore
Boolean,
Column,
DateTime,
ForeignKey,
Integer,
Sequence,
String,
)
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, Sequence, String # type: ignore
from sqlalchemy.orm import relationship # type: ignore

from antarest.core.persistence import Base
Expand Down
6 changes: 1 addition & 5 deletions antarest/core/core_blueprint.py
Expand Up @@ -8,11 +8,7 @@
from antarest.core.jwt import JWTUser
from antarest.core.requests import UserHasNotPermissionError
from antarest.core.utils.web import APITag
from antarest.core.version_info import (
VersionInfoDTO,
get_commit_id,
get_dependencies,
)
from antarest.core.version_info import VersionInfoDTO, get_commit_id, get_dependencies
from antarest.login.auth import Auth


Expand Down
8 changes: 1 addition & 7 deletions antarest/core/filetransfer/model.py
Expand Up @@ -4,13 +4,7 @@
from typing import Optional

from pydantic import BaseModel
from sqlalchemy import ( # type: ignore
Boolean,
Column,
DateTime,
Integer,
String,
)
from sqlalchemy import Boolean, Column, DateTime, Integer, String # type: ignore

from antarest.core.persistence import Base

Expand Down
13 changes: 2 additions & 11 deletions antarest/core/filetransfer/service.py
Expand Up @@ -9,21 +9,12 @@
from starlette.background import BackgroundTasks

from antarest.core.config import Config
from antarest.core.filetransfer.model import (
FileDownload,
FileDownloadDTO,
FileDownloadNotFound,
FileDownloadNotReady,
)
from antarest.core.filetransfer.model import FileDownload, FileDownloadDTO, FileDownloadNotFound, FileDownloadNotReady
from antarest.core.filetransfer.repository import FileDownloadRepository
from antarest.core.interfaces.eventbus import Event, EventType, IEventBus
from antarest.core.jwt import JWTUser
from antarest.core.model import PermissionInfo, PublicMode
from antarest.core.requests import (
MustBeAuthenticatedError,
RequestParameters,
UserHasNotPermissionError,
)
from antarest.core.requests import MustBeAuthenticatedError, RequestParameters, UserHasNotPermissionError

logger = logging.getLogger(__name__)

Expand Down
5 changes: 1 addition & 4 deletions antarest/core/logging/utils.py
Expand Up @@ -5,10 +5,7 @@
from contextvars import ContextVar, Token
from typing import Any, Dict, Optional, Type

from starlette.middleware.base import (
BaseHTTPMiddleware,
RequestResponseEndpoint,
)
from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
from starlette.requests import Request
from starlette.responses import Response

Expand Down
10 changes: 1 addition & 9 deletions antarest/core/tasks/model.py
Expand Up @@ -4,15 +4,7 @@
from typing import Any, List, Optional

from pydantic import BaseModel, Extra
from sqlalchemy import ( # type: ignore
Boolean,
Column,
DateTime,
ForeignKey,
Integer,
Sequence,
String,
)
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, Sequence, String # type: ignore
from sqlalchemy.orm import relationship # type: ignore

from antarest.core.persistence import Base
Expand Down
13 changes: 2 additions & 11 deletions antarest/core/tasks/service.py
Expand Up @@ -9,19 +9,10 @@
from fastapi import HTTPException

from antarest.core.config import Config
from antarest.core.interfaces.eventbus import (
Event,
EventChannelDirectory,
EventType,
IEventBus,
)
from antarest.core.interfaces.eventbus import Event, EventChannelDirectory, EventType, IEventBus
from antarest.core.jwt import DEFAULT_ADMIN_USER
from antarest.core.model import PermissionInfo, PublicMode
from antarest.core.requests import (
MustBeAuthenticatedError,
RequestParameters,
UserHasNotPermissionError,
)
from antarest.core.requests import MustBeAuthenticatedError, RequestParameters, UserHasNotPermissionError
from antarest.core.tasks.model import (
CustomTaskEventMessages,
TaskDTO,
Expand Down
5 changes: 1 addition & 4 deletions antarest/core/utils/fastapi_sqlalchemy/__init__.py
@@ -1,7 +1,4 @@
from antarest.core.utils.fastapi_sqlalchemy.middleware import (
DBSessionMiddleware,
db,
)
from antarest.core.utils.fastapi_sqlalchemy.middleware import DBSessionMiddleware, db

__all__ = ["db", "DBSessionMiddleware"]

Expand Down
10 changes: 2 additions & 8 deletions antarest/core/utils/fastapi_sqlalchemy/middleware.py
Expand Up @@ -5,18 +5,12 @@
from sqlalchemy.engine import Engine # type: ignore
from sqlalchemy.engine.url import URL # type: ignore
from sqlalchemy.orm import Session, sessionmaker # type: ignore
from starlette.middleware.base import (
BaseHTTPMiddleware,
RequestResponseEndpoint,
)
from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
from starlette.requests import Request
from starlette.responses import Response
from starlette.types import ASGIApp

from antarest.core.utils.fastapi_sqlalchemy.exceptions import (
MissingSessionError,
SessionNotInitialisedError,
)
from antarest.core.utils.fastapi_sqlalchemy.exceptions import MissingSessionError, SessionNotInitialisedError

_Session: sessionmaker = None
_session: ContextVar[Optional[Session]] = ContextVar("_session", default=None)
Expand Down
7 changes: 1 addition & 6 deletions antarest/launcher/adapters/abstractlauncher.py
Expand Up @@ -5,12 +5,7 @@

from antarest.core.config import Config
from antarest.core.interfaces.cache import ICache
from antarest.core.interfaces.eventbus import (
Event,
EventChannelDirectory,
EventType,
IEventBus,
)
from antarest.core.interfaces.eventbus import Event, EventChannelDirectory, EventType, IEventBus
from antarest.core.model import PermissionInfo, PublicMode
from antarest.core.requests import RequestParameters
from antarest.launcher.adapters.log_parser import LaunchProgressDTO
Expand Down
13 changes: 3 additions & 10 deletions antarest/launcher/adapters/factory_launcher.py
Expand Up @@ -4,16 +4,9 @@
from antarest.core.config import Config
from antarest.core.interfaces.cache import ICache
from antarest.core.interfaces.eventbus import IEventBus
from antarest.launcher.adapters.abstractlauncher import (
AbstractLauncher,
LauncherCallbacks,
)
from antarest.launcher.adapters.local_launcher.local_launcher import (
LocalLauncher,
)
from antarest.launcher.adapters.slurm_launcher.slurm_launcher import (
SlurmLauncher,
)
from antarest.launcher.adapters.abstractlauncher import AbstractLauncher, LauncherCallbacks
from antarest.launcher.adapters.local_launcher.local_launcher import LocalLauncher
from antarest.launcher.adapters.slurm_launcher.slurm_launcher import SlurmLauncher

logger = logging.getLogger(__name__)

Expand Down
6 changes: 1 addition & 5 deletions antarest/launcher/adapters/local_launcher/local_launcher.py
Expand Up @@ -13,11 +13,7 @@
from antarest.core.interfaces.cache import ICache
from antarest.core.interfaces.eventbus import IEventBus
from antarest.core.requests import RequestParameters
from antarest.launcher.adapters.abstractlauncher import (
AbstractLauncher,
LauncherCallbacks,
LauncherInitException,
)
from antarest.launcher.adapters.abstractlauncher import AbstractLauncher, LauncherCallbacks, LauncherInitException
from antarest.launcher.adapters.log_manager import LogTailManager
from antarest.launcher.model import JobStatus, LauncherParametersDTO, LogType

Expand Down
18 changes: 3 additions & 15 deletions antarest/launcher/adapters/slurm_launcher/slurm_launcher.py
Expand Up @@ -13,10 +13,7 @@

from antareslauncher.data_repo.data_repo_tinydb import DataRepoTinydb
from antareslauncher.main import MainParameters, run_with
from antareslauncher.main_option_parser import (
MainOptionParser,
ParserParameters,
)
from antareslauncher.main_option_parser import MainOptionParser, ParserParameters
from antareslauncher.study_dto import StudyDTO
from filelock import FileLock

Expand All @@ -26,18 +23,9 @@
from antarest.core.model import PermissionInfo, PublicMode
from antarest.core.requests import RequestParameters
from antarest.core.utils.utils import assert_this, unzip
from antarest.launcher.adapters.abstractlauncher import (
AbstractLauncher,
LauncherCallbacks,
LauncherInitException,
)
from antarest.launcher.adapters.abstractlauncher import AbstractLauncher, LauncherCallbacks, LauncherInitException
from antarest.launcher.adapters.log_manager import LogTailManager
from antarest.launcher.model import (
JobStatus,
LauncherParametersDTO,
LogType,
XpansionParametersDTO,
)
from antarest.launcher.model import JobStatus, LauncherParametersDTO, LogType, XpansionParametersDTO
from antarest.study.storage.rawstudy.io.reader import IniReader
from antarest.study.storage.rawstudy.io.writer.ini_writer import IniWriter

Expand Down
4 changes: 1 addition & 3 deletions antarest/launcher/extensions/adequacy_patch/extension.py
Expand Up @@ -11,9 +11,7 @@
from antarest.core.utils.utils import assert_this
from antarest.launcher.extensions.interface import ILauncherExtension
from antarest.study.service import StudyService
from antarest.study.storage.rawstudy.model.filesystem.config.model import (
transform_name_to_id,
)
from antarest.study.storage.rawstudy.model.filesystem.config.model import transform_name_to_id
from antarest.study.storage.rawstudy.model.filesystem.factory import FileStudy

logger = logging.getLogger(__name__)
Expand Down
10 changes: 1 addition & 9 deletions antarest/launcher/model.py
Expand Up @@ -3,15 +3,7 @@
from typing import Any, Dict, List, Optional, Union

from pydantic import BaseModel
from sqlalchemy import ( # type: ignore
Column,
DateTime,
Enum,
ForeignKey,
Integer,
Sequence,
String,
)
from sqlalchemy import Column, DateTime, Enum, ForeignKey, Integer, Sequence, String # type: ignore
from sqlalchemy.orm import relationship # type: ignore

from antarest.core.persistence import Base
Expand Down
26 changes: 4 additions & 22 deletions antarest/launcher/service.py
Expand Up @@ -15,31 +15,17 @@
from antarest.core.filetransfer.model import FileDownloadTaskDTO
from antarest.core.filetransfer.service import FileTransferManager
from antarest.core.interfaces.cache import ICache
from antarest.core.interfaces.eventbus import (
Event,
EventChannelDirectory,
EventType,
IEventBus,
)
from antarest.core.interfaces.eventbus import Event, EventChannelDirectory, EventType, IEventBus
from antarest.core.jwt import DEFAULT_ADMIN_USER, JWTUser
from antarest.core.model import PermissionInfo, PublicMode, StudyPermissionType
from antarest.core.requests import RequestParameters, UserHasNotPermissionError
from antarest.core.tasks.model import TaskResult, TaskType
from antarest.core.tasks.service import ITaskService, TaskUpdateNotifier
from antarest.core.utils.fastapi_sqlalchemy import db
from antarest.core.utils.utils import (
StopWatch,
concat_files,
concat_files_to_str,
is_zip,
read_in_zip,
zip_dir,
)
from antarest.core.utils.utils import StopWatch, concat_files, concat_files_to_str, is_zip, read_in_zip, zip_dir
from antarest.launcher.adapters.abstractlauncher import LauncherCallbacks
from antarest.launcher.adapters.factory_launcher import FactoryLauncher
from antarest.launcher.extensions.adequacy_patch.extension import (
AdequacyPatchExtension,
)
from antarest.launcher.extensions.adequacy_patch.extension import AdequacyPatchExtension
from antarest.launcher.extensions.interface import ILauncherExtension
from antarest.launcher.model import (
JobLog,
Expand All @@ -52,11 +38,7 @@
)
from antarest.launcher.repository import JobResultRepository
from antarest.study.service import StudyService
from antarest.study.storage.utils import (
assert_permission,
extract_output_name,
find_single_output_path,
)
from antarest.study.storage.utils import assert_permission, extract_output_name, find_single_output_path

logger = logging.getLogger(__name__)

Expand Down
8 changes: 1 addition & 7 deletions antarest/launcher/web.py
Expand Up @@ -11,13 +11,7 @@
from antarest.core.jwt import JWTUser
from antarest.core.requests import RequestParameters
from antarest.core.utils.web import APITag
from antarest.launcher.model import (
JobCreationDTO,
JobResultDTO,
LauncherEnginesDTO,
LauncherParametersDTO,
LogType,
)
from antarest.launcher.model import JobCreationDTO, JobResultDTO, LauncherEnginesDTO, LauncherParametersDTO, LogType
from antarest.launcher.service import LauncherService
from antarest.login.auth import Auth

Expand Down
6 changes: 1 addition & 5 deletions antarest/login/ldap.py
Expand Up @@ -7,11 +7,7 @@
from antarest.core.config import Config
from antarest.core.model import JSON
from antarest.login.model import Group, Role, UserLdap
from antarest.login.repository import (
GroupRepository,
RoleRepository,
UserLdapRepository,
)
from antarest.login.repository import GroupRepository, RoleRepository, UserLdapRepository

logger = logging.getLogger(__name__)

Expand Down
8 changes: 1 addition & 7 deletions antarest/login/main.py
Expand Up @@ -12,13 +12,7 @@
from antarest.core.interfaces.eventbus import DummyEventBusService, IEventBus
from antarest.core.utils.fastapi_sqlalchemy import db
from antarest.login.ldap import LdapService
from antarest.login.repository import (
BotRepository,
GroupRepository,
RoleRepository,
UserLdapRepository,
UserRepository,
)
from antarest.login.repository import BotRepository, GroupRepository, RoleRepository, UserLdapRepository, UserRepository
from antarest.login.service import LoginService
from antarest.login.web import create_login_api

Expand Down
10 changes: 1 addition & 9 deletions antarest/login/model.py
Expand Up @@ -4,15 +4,7 @@

import bcrypt
from pydantic.main import BaseModel
from sqlalchemy import ( # type: ignore
Boolean,
Column,
Enum,
ForeignKey,
Integer,
Sequence,
String,
)
from sqlalchemy import Boolean, Column, Enum, ForeignKey, Integer, Sequence, String # type: ignore
from sqlalchemy.ext.hybrid import hybrid_property # type: ignore
from sqlalchemy.orm import relationship # type: ignore

Expand Down
7 changes: 1 addition & 6 deletions antarest/login/service.py
Expand Up @@ -27,12 +27,7 @@
UserLdap,
UserRoleDTO,
)
from antarest.login.repository import (
BotRepository,
GroupRepository,
RoleRepository,
UserRepository,
)
from antarest.login.repository import BotRepository, GroupRepository, RoleRepository, UserRepository

logger = logging.getLogger(__name__)

Expand Down

0 comments on commit 13a5929

Please sign in to comment.