Skip to content

Commit 45032d8

Browse files
committed
chore: lint
1 parent c4ef363 commit 45032d8

7 files changed

Lines changed: 38 additions & 26 deletions

File tree

src/dependencies.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
from src.controllers.environment import EnvironmentController
99
from src.controllers.flight import FlightController
1010

11+
1112
@cache
1213
def get_rocket_controller() -> RocketController:
1314
"""
1415
Provides a singleton RocketController instance.
15-
16+
1617
The controller is stateless and can be safely reused across requests.
1718
Using functools.cache memoizes this function so a single instance is reused per process; it does not by itself guarantee thread-safe initialization in multi-threaded setups.
18-
19+
1920
Returns:
2021
RocketController: Shared controller instance for rocket operations.
2122
"""
@@ -26,7 +27,7 @@ def get_rocket_controller() -> RocketController:
2627
def get_motor_controller() -> MotorController:
2728
"""
2829
Provides a singleton MotorController instance.
29-
30+
3031
Returns:
3132
MotorController: Shared controller instance for motor operations.
3233
"""
@@ -37,7 +38,7 @@ def get_motor_controller() -> MotorController:
3738
def get_environment_controller() -> EnvironmentController:
3839
"""
3940
Provides a singleton EnvironmentController instance.
40-
41+
4142
Returns:
4243
EnvironmentController: Shared controller instance for environment operations.
4344
"""
@@ -48,15 +49,20 @@ def get_environment_controller() -> EnvironmentController:
4849
def get_flight_controller() -> FlightController:
4950
"""
5051
Provides a singleton FlightController instance.
51-
52+
5253
Returns:
5354
FlightController: Shared controller instance for flight operations.
5455
"""
5556
return FlightController()
5657

57-
RocketControllerDep = Annotated[RocketController, Depends(get_rocket_controller)]
58+
59+
RocketControllerDep = Annotated[
60+
RocketController, Depends(get_rocket_controller)
61+
]
5862
MotorControllerDep = Annotated[MotorController, Depends(get_motor_controller)]
5963
EnvironmentControllerDep = Annotated[
6064
EnvironmentController, Depends(get_environment_controller)
6165
]
62-
FlightControllerDep = Annotated[FlightController, Depends(get_flight_controller)]
66+
FlightControllerDep = Annotated[
67+
FlightController, Depends(get_flight_controller)
68+
]

src/routes/flight.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ async def read_flight(
7676
with tracer.start_as_current_span("read_flight"):
7777
return await controller.get_flight_by_id(flight_id)
7878

79+
7980
@router.put("/{flight_id}", status_code=204)
8081
async def update_flight(
8182
flight_id: str,
@@ -117,6 +118,7 @@ async def update_flight_from_references(
117118
flight_id, payload
118119
)
119120

121+
120122
@router.delete("/{flight_id}", status_code=204)
121123
async def delete_flight(
122124
flight_id: str,
@@ -143,7 +145,6 @@ async def delete_flight(
143145
status_code=200,
144146
response_class=Response,
145147
)
146-
147148
async def get_rocketpy_flight_binary(
148149
flight_id: str,
149150
controller: FlightControllerDep,
@@ -210,6 +211,7 @@ async def update_flight_rocket(
210211
rocket=rocket,
211212
)
212213

214+
213215
@router.get("/{flight_id}/simulate")
214216
async def get_flight_simulation(
215217
flight_id: str,
@@ -222,4 +224,4 @@ async def get_flight_simulation(
222224
``` flight_id: Flight ID ```
223225
"""
224226
with tracer.start_as_current_span("get_flight_simulation"):
225-
return await controller.get_flight_simulation(flight_id)
227+
return await controller.get_flight_simulation(flight_id)

src/routes/rocket.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ async def create_rocket(
4343
"""
4444
with tracer.start_as_current_span("create_rocket"):
4545
return await controller.post_rocket(rocket)
46+
47+
4648
@router.post("/from-motor-reference", status_code=201)
4749
async def create_rocket_from_motor_reference(
4850
payload: RocketWithMotorReferenceRequest,
@@ -115,6 +117,8 @@ async def update_rocket_from_motor_reference(
115117
return await controller.update_rocket_from_motor_reference(
116118
rocket_id, payload
117119
)
120+
121+
118122
@router.delete("/{rocket_id}", status_code=204)
119123
async def delete_rocket(
120124
rocket_id: str,

tests/unit/test_routes/test_environments_route.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from unittest.mock import patch, Mock, AsyncMock
1+
from unittest.mock import patch, AsyncMock
22
import json
33
import pytest
44
from fastapi.testclient import TestClient
@@ -35,11 +35,11 @@ def mock_controller_instance():
3535
mock_controller.delete_environment_by_id = AsyncMock()
3636
mock_controller.get_environment_simulation = AsyncMock()
3737
mock_controller.get_rocketpy_environment_binary = AsyncMock()
38-
38+
3939
mock_class.return_value = mock_controller
40-
40+
4141
yield mock_controller
42-
42+
4343
get_environment_controller.cache_clear()
4444

4545

tests/unit/test_routes/test_flights_route.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from unittest.mock import patch, Mock, AsyncMock
1+
from unittest.mock import patch, AsyncMock
22
import copy
33
import json
44
import pytest
@@ -58,13 +58,13 @@ def mock_controller_instance():
5858
mock_controller.update_rocket_by_flight_id = AsyncMock()
5959
mock_controller.create_flight_from_references = AsyncMock()
6060
mock_controller.update_flight_from_references = AsyncMock()
61-
61+
6262
mock_class.return_value = mock_controller
63-
63+
6464
get_flight_controller.cache_clear()
65-
65+
6666
yield mock_controller
67-
67+
6868
get_flight_controller.cache_clear()
6969

7070

tests/unit/test_routes/test_motors_route.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from unittest.mock import patch, AsyncMock, Mock
1+
from unittest.mock import patch, AsyncMock
22
import json
33
import pytest
44
from fastapi.testclient import TestClient
@@ -35,13 +35,13 @@ def mock_controller_instance():
3535
mock_controller.delete_motor_by_id = AsyncMock()
3636
mock_controller.get_motor_simulation = AsyncMock()
3737
mock_controller.get_rocketpy_motor_binary = AsyncMock()
38-
38+
3939
mock_class.return_value = mock_controller
4040

4141
get_motor_controller.cache_clear()
42-
42+
4343
yield mock_controller
44-
44+
4545
get_motor_controller.cache_clear()
4646

4747

tests/unit/test_routes/test_rockets_route.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from unittest.mock import patch, Mock, AsyncMock
1+
from unittest.mock import patch, AsyncMock
22
import copy
33
import json
44
import pytest
@@ -86,13 +86,13 @@ def mock_controller_instance():
8686
mock_controller.get_rocketpy_rocket_binary = AsyncMock()
8787
mock_controller.create_rocket_from_motor_reference = AsyncMock()
8888
mock_controller.update_rocket_from_motor_reference = AsyncMock()
89-
89+
9090
mock_class.return_value = mock_controller
9191

9292
get_rocket_controller.cache_clear()
93-
93+
9494
yield mock_controller
95-
95+
9696
get_rocket_controller.cache_clear()
9797

9898

0 commit comments

Comments
 (0)