This repository has been archived on 2022-08-24. You can view files and clone it, but cannot push or open issues or pull requests.
ergast-py/ergast_py/models/pit_stop.py

40 lines
1.1 KiB
Python
Raw Normal View History

""" PitStop class """
2022-06-01 14:31:52 +01:00
import datetime
from dataclasses import dataclass
2022-06-01 14:31:52 +01:00
@dataclass
2022-06-06 12:20:48 +01:00
class PitStop():
2022-06-01 14:31:52 +01:00
"""
Representation of a single Pit Stop from a Formula One race
2022-06-01 14:31:52 +01:00
PitStops may contain:
driver_id: String
2022-06-01 14:31:52 +01:00
lap: Integer
stop: Integer
2022-06-09 23:36:19 +01:00
local_time: datetime.time
2022-06-01 14:31:52 +01:00
duration: datetime.time
"""
2022-06-09 23:36:19 +01:00
def __init__(self, driver_id: str, lap: int, stop: int, local_time: datetime.time,
2022-06-01 14:31:52 +01:00
duration: datetime.time) -> None:
self.driver_id = driver_id
2022-06-01 14:31:52 +01:00
self.lap = lap
self.stop = stop
self.local_time = local_time
2022-06-01 14:31:52 +01:00
self.duration = duration
2022-06-06 12:20:48 +01:00
def __repr__(self) -> str:
members = ', '.join(f"{key}={value}" for key, value in self.__dict__.items())
return f"{type(self).__name__}({members})"
2022-06-09 23:19:28 +01:00
def __eq__(self, __o: object) -> bool:
return isinstance(__o, PitStop) and (
self.driver_id == __o.driver_id and
self.lap == __o.lap and
self.stop == __o.stop and
self.local_time == __o.local_time and
self.duration == __o.duration
)