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/constructor.py

35 lines
961 B
Python
Raw Normal View History

""" Constructor class """
2022-06-01 15:31:52 +02:00
from dataclasses import dataclass
2022-06-01 15:31:52 +02:00
@dataclass
2022-06-06 13:20:48 +02:00
class Constructor():
2022-06-01 15:31:52 +02:00
"""
Representation of a Formula One Team
2022-06-01 15:31:52 +02:00
Constructors may contain:
constructor_id: String
2022-06-01 15:31:52 +02:00
url: String
name: String
nationality: String
"""
def __init__(self, constructor_id: str, url: str, name: str, nationality: str) -> None:
self.constructor_id = constructor_id
2022-06-01 15:31:52 +02:00
self.url = url
self.name = name
self.nationality = nationality
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, Constructor) and (
self.constructor_id == __o.constructor_id and
self.url == __o.url and
self.name == __o.name and
self.nationality == __o.nationality
)