Skip to content

Commit

Permalink
Implement ruff recommendations
Browse files Browse the repository at this point in the history
Remove unused imports and improve readability
  • Loading branch information
Eddasol committed Dec 17, 2024
1 parent edc1f47 commit 699833b
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 37 deletions.
1 change: 0 additions & 1 deletion src/isar/apis/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from .models import InputPose, StartMissionResponse
8 changes: 6 additions & 2 deletions src/isar/apis/schedule/scheduling_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
from fastapi import Body, HTTPException, Path
from injector import inject

from isar.apis.models import InputPose, StartMissionResponse
from isar.apis.models.models import ControlMissionResponse, TaskResponse
from isar.apis.models.models import (
ControlMissionResponse,
TaskResponse,
InputPose,
StartMissionResponse,
)
from isar.apis.models.start_mission_definition import (
StartMissionDefinition,
to_isar_mission,
Expand Down
4 changes: 0 additions & 4 deletions src/isar/models/communication/queues/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
from .queue_io import QueueIO
from .queue_timeout_error import QueueTimeoutError
from .queues import Queues
from .status_queue import StatusQueue
4 changes: 2 additions & 2 deletions src/isar/models/communication/queues/status_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def check(self) -> Any:
if not self._qsize():
raise Empty
with self.mutex:
l = list(self.queue)
return l.pop()
queueList = list(self.queue)
return queueList.pop()

def update(self, item: Any):
with self.mutex:
Expand Down
8 changes: 6 additions & 2 deletions src/isar/services/utilities/scheduling_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
MissionPlannerInterface,
)
from isar.models.communication.message import StartMissionMessage
from isar.models.communication.queues import QueueIO, Queues, QueueTimeoutError
from isar.models.communication.queues.queue_io import QueueIO
from isar.models.communication.queues.queues import Queues
from isar.models.communication.queues.queue_timeout_error import (
QueueTimeoutError,
)
from isar.services.utilities.queue_utilities import QueueUtilities
from isar.state_machine.states_enum import States
from robot_interface.models.mission.mission import Mission
Expand Down Expand Up @@ -101,7 +105,7 @@ def verify_robot_capable_of_mission(
is_capable: bool = True
missing_capabilities: Set[str] = set()
for task in mission.tasks:
if not task.type in robot_capabilities:
if task.type not in robot_capabilities:
is_capable = False
missing_capabilities.add(task.type)

Expand Down
18 changes: 8 additions & 10 deletions src/isar/state_machine/state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@
)
from isar.models.communication.message import StartMissionMessage
from isar.models.communication.queues.queues import Queues
from isar.state_machine.states import (
Idle,
Initialize,
Initiate,
Monitor,
Off,
Offline,
Paused,
Stop,
)
from isar.state_machine.states.idle import Idle
from isar.state_machine.states.initialize import Initialize
from isar.state_machine.states.initiate import Initiate
from isar.state_machine.states.monitor import Monitor
from isar.state_machine.states.off import Off
from isar.state_machine.states.offline import Offline
from isar.state_machine.states.paused import Paused
from isar.state_machine.states.stop import Stop
from isar.state_machine.states_enum import States
from robot_interface.models.exceptions.robot_exceptions import ErrorMessage
from robot_interface.models.initialize.initialize_params import InitializeParams
Expand Down
8 changes: 0 additions & 8 deletions src/isar/state_machine/states/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
from .idle import Idle
from .initialize import Initialize
from .initiate import Initiate
from .monitor import Monitor
from .off import Off
from .offline import Offline
from .paused import Paused
from .stop import Stop
2 changes: 1 addition & 1 deletion src/isar/storage/blob_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def store(self, inspection: Inspection, mission: Mission) -> Union[str, dict]:
def _upload_file(self, path: Path, data: bytes) -> Union[str, dict]:
blob_client = self._get_blob_client(path)
try:
blob_properties = blob_client.upload_blob(data=data)
blob_client.upload_blob(data=data)
except ResourceExistsError as e:
self.logger.error(
f"Blob {path.as_posix()} already exists in container. Error: {e}"
Expand Down
2 changes: 1 addition & 1 deletion src/isar/storage/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from injector import inject

from isar.config.settings import settings
from isar.models.communication.queues import Queues
from isar.models.communication.queues.queues import Queues
from isar.storage.storage_interface import StorageException, StorageInterface
from robot_interface.models.inspection.inspection import Inspection
from robot_interface.models.mission.mission import Mission
Expand Down
1 change: 0 additions & 1 deletion src/robot_interface/models/initialize/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from .initialize_params import InitializeParams
2 changes: 1 addition & 1 deletion src/robot_interface/robot_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from threading import Thread
from typing import Callable, List, Optional

from robot_interface.models.initialize import InitializeParams
from robot_interface.models.initialize.initialize_params import InitializeParams
from robot_interface.models.inspection.inspection import Inspection
from robot_interface.models.mission.mission import Mission
from robot_interface.models.mission.status import RobotStatus, TaskStatus
Expand Down
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
from isar.services.service_connections.request_handler import RequestHandler
from isar.services.utilities.scheduling_utilities import SchedulingUtilities
from isar.state_machine.state_machine import StateMachine
from isar.state_machine.states import Idle, Initiate, Monitor
from isar.state_machine.states.idle import Idle
from isar.state_machine.states.initiate import Initiate
from isar.state_machine.states.monitor import Monitor
from robot_interface.telemetry.mqtt_client import MqttClientInterface
from tests.mocks.robot_interface import MockRobot
from tests.test_modules import (
Expand Down
2 changes: 1 addition & 1 deletion tests/isar/models/communication/test_queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from isar.models.communication.queues import Queues, StatusQueue
from isar.models.communication.queues.queues import Queues, StatusQueue


class TestQueues:
Expand Down
3 changes: 2 additions & 1 deletion tests/isar/services/utilities/test_scheduling_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from fastapi import HTTPException
from pytest_mock import MockerFixture

from isar.models.communication.queues import QueueIO, QueueTimeoutError
from isar.models.communication.queues.queues import QueueIO
from isar.models.communication.queues.queue_timeout_error import QueueTimeoutError
from isar.services.utilities.queue_utilities import QueueUtilities
from isar.services.utilities.scheduling_utilities import SchedulingUtilities
from isar.state_machine.states_enum import States
Expand Down
2 changes: 1 addition & 1 deletion tests/mocks/robot_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from alitra import Frame, Orientation, Pose, Position

from robot_interface.models.initialize import InitializeParams
from robot_interface.models.initialize.initialize_params import InitializeParams
from robot_interface.models.inspection.inspection import (
Image,
ImageMetadata,
Expand Down

0 comments on commit 699833b

Please sign in to comment.