Skip to content

Commit 873f96e

Browse files
removes forward reference and improves logs wording
1 parent c02b505 commit 873f96e

File tree

3 files changed

+42
-40
lines changed

3 files changed

+42
-40
lines changed

lib/controllers/environment.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async def get_rocketpy_env(env: Env) -> RocketPyEnvironment:
6262
)
6363
return rocketpy_env
6464

65-
async def create_env(self) -> "Union[EnvCreated, HTTPException]":
65+
async def create_env(self) -> Union[EnvCreated, HTTPException]:
6666
"""
6767
Create a env in the database.
6868
@@ -84,11 +84,11 @@ async def create_env(self) -> "Union[EnvCreated, HTTPException]":
8484
return EnvCreated(env_id=created_env.env_id)
8585
finally:
8686
logger.info(
87-
f"Call to controllers.environment.create_env completed; params: Env {hash(self.env)}"
87+
f"Call to controllers.environment.create_env completed for Env {hash(self.env)}"
8888
)
8989

9090
@staticmethod
91-
async def get_env_by_id(env_id: str) -> "Union[Env, HTTPException]":
91+
async def get_env_by_id(env_id: str) -> Union[Env, HTTPException]:
9292
"""
9393
Get a env from the database.
9494
@@ -119,14 +119,14 @@ async def get_env_by_id(env_id: str) -> "Union[Env, HTTPException]":
119119
)
120120
finally:
121121
logger.info(
122-
f"Call to controllers.environment.get_env_by_id completed; params: EnvID {env_id}"
122+
f"Call to controllers.environment.get_env_by_id completed for Env {env_id}"
123123
)
124124

125125
@classmethod
126126
async def get_rocketpy_env_as_jsonpickle(
127127
cls,
128128
env_id: str,
129-
) -> "Union[EnvPickle, HTTPException]":
129+
) -> Union[EnvPickle, HTTPException]:
130130
"""
131131
Get rocketpy.Environmnet as jsonpickle string.
132132
@@ -159,12 +159,12 @@ async def get_rocketpy_env_as_jsonpickle(
159159
)
160160
finally:
161161
logger.info(
162-
f"Call to controllers.environment.get_rocketpy_env_as_jsonpickle completed; params: EnvID {env_id}"
162+
f"Call to controllers.environment.get_rocketpy_env_as_jsonpickle completed for Env {env_id}"
163163
)
164164

165165
async def update_env(
166166
self, env_id: str
167-
) -> "Union[EnvUpdated, HTTPException]":
167+
) -> Union[EnvUpdated, HTTPException]:
168168
"""
169169
Update a env in the database.
170170
@@ -195,11 +195,11 @@ async def update_env(
195195
return EnvUpdated(new_env_id=updated_env.env_id)
196196
finally:
197197
logger.info(
198-
f"Call to controllers.environment.update_env completed; params: EnvID {env_id}, Env {hash(self.env)}"
198+
f"Call to controllers.environment.update_env completed for Env {env_id}; Env {hash(self.env)}"
199199
)
200200

201201
@staticmethod
202-
async def delete_env(env_id: str) -> "Union[EnvDeleted, HTTPException]":
202+
async def delete_env(env_id: str) -> Union[EnvDeleted, HTTPException]:
203203
"""
204204
Delete a env from the database.
205205
@@ -225,11 +225,13 @@ async def delete_env(env_id: str) -> "Union[EnvDeleted, HTTPException]":
225225
return EnvDeleted(deleted_env_id=env_id)
226226
finally:
227227
logger.info(
228-
f"Call to controllers.environment.delete_env completed; params: EnvID {env_id}"
228+
f"Call to controllers.environment.delete_env completed for Env {env_id}"
229229
)
230230

231231
@classmethod
232-
async def simulate(cls, env_id: str) -> "Union[EnvSummary, HTTPException]":
232+
async def simulate_env(
233+
cls, env_id: str
234+
) -> Union[EnvSummary, HTTPException]:
233235
"""
234236
Simulate a rocket environment.
235237
@@ -267,5 +269,5 @@ async def simulate(cls, env_id: str) -> "Union[EnvSummary, HTTPException]":
267269
return env_summary
268270
finally:
269271
logger.info(
270-
f"Call to controllers.environment.simulate completed; params: EnvID {env_id}"
272+
f"Call to controllers.environment.simulate completed for Env {env_id}"
271273
)

lib/controllers/flight.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ async def get_rocketpy_flight(flight: Flight) -> RocketPyFlight:
9898
)
9999
return rocketpy_flight
100100

101-
async def create_flight(self) -> "Union[FlightCreated, HTTPException]":
101+
async def create_flight(self) -> Union[FlightCreated, HTTPException]:
102102
"""
103103
Create a flight in the database.
104104
@@ -122,13 +122,13 @@ async def create_flight(self) -> "Union[FlightCreated, HTTPException]":
122122
return FlightCreated(flight_id=str(created_flight.flight_id))
123123
finally:
124124
logger.info(
125-
f"Call to controllers.flight.create_flight completed; params: Flight {hash(self.flight)}"
125+
f"Call to controllers.flight.create_flight completed for Flight {hash(self.flight)}"
126126
)
127127

128128
@staticmethod
129129
async def get_flight_by_id(
130130
flight_id: str,
131-
) -> "Union[Flight, HTTPException]":
131+
) -> Union[Flight, HTTPException]:
132132
"""
133133
Get a flight from the database.
134134
@@ -161,14 +161,14 @@ async def get_flight_by_id(
161161
) from e
162162
finally:
163163
logger.info(
164-
f"Call to controllers.flight.get_flight_by_id completed; params: FlightID {flight_id}"
164+
f"Call to controllers.flight.get_flight_by_id completed for Flight {flight_id}"
165165
)
166166

167167
@classmethod
168168
async def get_rocketpy_flight_as_jsonpickle(
169169
cls,
170170
flight_id: str,
171-
) -> "Union[FlightPickle, HTTPException]":
171+
) -> Union[FlightPickle, HTTPException]:
172172
"""
173173
Get rocketpy.flight as jsonpickle string.
174174
@@ -201,12 +201,12 @@ async def get_rocketpy_flight_as_jsonpickle(
201201
)
202202
finally:
203203
logger.info(
204-
f"Call to controllers.flight.get_rocketpy_flight_as_jsonpickle completed; params: FlightID {flight_id}"
204+
f"Call to controllers.flight.get_rocketpy_flight_as_jsonpickle completed for Flight {flight_id}"
205205
)
206206

207207
async def update_flight(
208208
self, flight_id: str
209-
) -> "Union[FlightUpdated, HTTPException]":
209+
) -> Union[FlightUpdated, HTTPException]:
210210
"""
211211
Update a flight in the database.
212212
@@ -237,13 +237,13 @@ async def update_flight(
237237
return FlightUpdated(new_flight_id=str(updated_flight.flight_id))
238238
finally:
239239
logger.info(
240-
f"Call to controllers.flight.update_flight completed; params: FlightID {flight_id}"
240+
f"Call to controllers.flight.update_flight completed for Flight {flight_id}"
241241
)
242242

243243
@classmethod
244244
async def update_env(
245245
cls, flight_id: str, env: Env
246-
) -> "Union[FlightUpdated, HTTPException]":
246+
) -> Union[FlightUpdated, HTTPException]:
247247
"""
248248
Update the environment of a flight in the database.
249249
@@ -278,13 +278,13 @@ async def update_env(
278278
return FlightUpdated(new_flight_id=str(updated_flight.flight_id))
279279
finally:
280280
logger.info(
281-
f"Call to controllers.flight.update_env completed; params: FlightID {flight_id}, Env {hash(env)}"
281+
f"Call to controllers.flight.update_env completed for Flight {flight_id}; Env {hash(env)}"
282282
)
283283

284284
@staticmethod
285285
async def update_rocket(
286286
flight_id: str, rocket: Rocket, rocket_option, motor_kind
287-
) -> "Union[FlightUpdated, HTTPException]":
287+
) -> Union[FlightUpdated, HTTPException]:
288288
"""
289289
Update the rocket of a flight in the database.
290290
@@ -322,13 +322,13 @@ async def update_rocket(
322322
return FlightUpdated(new_flight_id=str(new_flight_id))
323323
finally:
324324
logger.info(
325-
f"Call to controllers.flight.update_rocket completed; params: FlightID {flight_id}, Rocket {hash(rocket)}"
325+
f"Call to controllers.flight.update_rocket completed for Flight {flight_id}; Rocket {hash(rocket)}"
326326
)
327327

328328
@staticmethod
329329
async def delete_flight(
330330
flight_id: str,
331-
) -> "Union[FlightDeleted, HTTPException]":
331+
) -> Union[FlightDeleted, HTTPException]:
332332
"""
333333
Delete a flight from the database.
334334
@@ -356,14 +356,14 @@ async def delete_flight(
356356
return FlightDeleted(deleted_flight_id=str(flight_id))
357357
finally:
358358
logger.info(
359-
f"Call to controllers.flight.delete_flight completed; params: FlightID {flight_id}"
359+
f"Call to controllers.flight.delete_flight completed for Flight {flight_id}"
360360
)
361361

362362
@classmethod
363363
async def simulate_flight(
364364
cls,
365365
flight_id: str,
366-
) -> "Union[FlightSummary, HTTPException]":
366+
) -> Union[FlightSummary, HTTPException]:
367367
"""
368368
Simulate a rocket flight.
369369
@@ -643,5 +643,5 @@ async def simulate_flight(
643643
return flight_summary
644644
finally:
645645
logger.info(
646-
f"Call to controllers.flight.simulate_flight completed; params: FlightID {flight_id}"
646+
f"Call to controllers.flight.simulate_flight completed for Flight {flight_id}"
647647
)

lib/controllers/rocket.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def get_rocketpy_rocket(cls, rocket: Rocket) -> RocketPyRocket:
132132

133133
return rocketpy_rocket
134134

135-
async def create_rocket(self) -> "Union[RocketCreated, HTTPException]":
135+
async def create_rocket(self) -> Union[RocketCreated, HTTPException]:
136136
"""
137137
Create a rocket in the database.
138138
@@ -156,13 +156,13 @@ async def create_rocket(self) -> "Union[RocketCreated, HTTPException]":
156156
return RocketCreated(rocket_id=str(created_rocket.rocket_id))
157157
finally:
158158
logger.info(
159-
f"Call to controllers.rocket.create_rocket completed; params: Rocket {hash(self.rocket)}"
159+
f"Call to controllers.rocket.create_rocket completed for Rocket {hash(self.rocket)}"
160160
)
161161

162162
@staticmethod
163163
async def get_rocket_by_id(
164164
rocket_id: str,
165-
) -> "Union[Rocket, HTTPException]":
165+
) -> Union[Rocket, HTTPException]:
166166
"""
167167
Get a rocket from the database.
168168
@@ -195,13 +195,13 @@ async def get_rocket_by_id(
195195
)
196196
finally:
197197
logger.info(
198-
f"Call to controllers.rocket.get_rocket_by_id completed; params: RocketID {rocket_id}"
198+
f"Call to controllers.rocket.get_rocket_by_id completed for Rocket {rocket_id}"
199199
)
200200

201201
@classmethod
202202
async def get_rocketpy_rocket_as_jsonpickle(
203203
cls, rocket_id: str
204-
) -> "Union[RocketPickle, HTTPException]":
204+
) -> Union[RocketPickle, HTTPException]:
205205
"""
206206
Get a rocketpy.Rocket object as jsonpickle string.
207207
@@ -234,12 +234,12 @@ async def get_rocketpy_rocket_as_jsonpickle(
234234
)
235235
finally:
236236
logger.info(
237-
f"Call to controllers.rocket.get_rocketpy_rocket_as_jsonpickle completed; params: RocketID {rocket_id}"
237+
f"Call to controllers.rocket.get_rocketpy_rocket_as_jsonpickle completed for Rocket {rocket_id}"
238238
)
239239

240240
async def update_rocket(
241241
self, rocket_id: str
242-
) -> "Union[RocketUpdated, HTTPException]":
242+
) -> Union[RocketUpdated, HTTPException]:
243243
"""
244244
Update a rocket in the database.
245245
@@ -270,13 +270,13 @@ async def update_rocket(
270270
return RocketUpdated(new_rocket_id=str(updated_rocket.rocket_id))
271271
finally:
272272
logger.info(
273-
f"Call to controllers.rocket.update_rocket completed; params: RocketID {rocket_id}"
273+
f"Call to controllers.rocket.update_rocket completed for Rocket {rocket_id}"
274274
)
275275

276276
@staticmethod
277277
async def delete_rocket(
278278
rocket_id: str,
279-
) -> "Union[RocketDeleted, HTTPException]":
279+
) -> Union[RocketDeleted, HTTPException]:
280280
"""
281281
Delete a rocket from the database.
282282
@@ -302,14 +302,14 @@ async def delete_rocket(
302302
return RocketDeleted(deleted_rocket_id=str(rocket_id))
303303
finally:
304304
logger.info(
305-
f"Call to controllers.rocket.delete_rocket completed; params: RocketID {rocket_id}"
305+
f"Call to controllers.rocket.delete_rocket completed for Rocket {rocket_id}"
306306
)
307307

308308
@classmethod
309309
async def simulate(
310310
cls,
311311
rocket_id: str,
312-
) -> "Union[RocketSummary, HTTPException]":
312+
) -> Union[RocketSummary, HTTPException]:
313313
"""
314314
Simulate a rocket rocket.
315315
@@ -477,7 +477,7 @@ async def simulate(
477477
return rocket_summary
478478
finally:
479479
logger.info(
480-
f"Call to controllers.rocket.simulate completed; params: RocketID {rocket_id}"
480+
f"Call to controllers.rocket.simulate completed for Rocket {rocket_id}"
481481
)
482482

483483
@staticmethod

0 commit comments

Comments
 (0)