2022-06-06 02:58:53 +02:00
|
|
|
""" DriverStanding class """
|
|
|
|
|
2022-06-01 15:31:52 +02:00
|
|
|
from dataclasses import dataclass
|
|
|
|
|
2022-06-06 02:58:53 +02:00
|
|
|
from ergast_py.models.constructor import Constructor
|
2022-06-01 15:31:52 +02:00
|
|
|
from ergast_py.models.driver import Driver
|
2022-06-06 02:58:53 +02:00
|
|
|
|
2022-06-01 15:31:52 +02:00
|
|
|
|
|
|
|
@dataclass
|
2022-06-06 13:20:48 +02:00
|
|
|
class DriverStanding():
|
2022-06-01 15:31:52 +02:00
|
|
|
"""
|
|
|
|
Representation of a Formula One Driver's standing in a Season
|
2022-06-06 02:58:53 +02:00
|
|
|
|
2022-06-01 15:31:52 +02:00
|
|
|
Driver Standings may contain:
|
|
|
|
position: Integer
|
2022-06-06 02:58:53 +02:00
|
|
|
position_text: String
|
2022-06-01 15:31:52 +02:00
|
|
|
points: Float
|
|
|
|
wins: Integer
|
|
|
|
driver: Driver
|
|
|
|
constructors: Constructor[]
|
|
|
|
"""
|
|
|
|
|
2022-06-06 02:58:53 +02:00
|
|
|
def __init__(self, position: int, position_text: str, points: float, wins: int, driver: Driver, #pylint: disable=too-many-arguments
|
2022-06-01 15:31:52 +02:00
|
|
|
constructors: list[Constructor]) -> None:
|
|
|
|
self.position = position
|
2022-06-06 02:58:53 +02:00
|
|
|
self.position_text = position_text
|
2022-06-01 15:31:52 +02:00
|
|
|
self.points = points
|
|
|
|
self.wins = wins
|
|
|
|
self.driver = driver
|
|
|
|
self.constructors = constructors
|
2022-06-06 13:20:48 +02: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-10 00:19:28 +02:00
|
|
|
|
|
|
|
def __eq__(self, __o: object) -> bool:
|
|
|
|
return isinstance(__o, DriverStanding) and (
|
|
|
|
self.position == __o.position and
|
|
|
|
self.position_text == __o.position_text and
|
|
|
|
self.points == __o.points and
|
|
|
|
self.wins == __o.wins and
|
|
|
|
self.driver == __o.driver and
|
|
|
|
self.constructors == __o.constructors
|
|
|
|
)
|