26 lines
		
	
	
		
			521 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			521 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from __future__ import annotations
 | |
| 
 | |
| from dataclasses import dataclass
 | |
| from typing import TYPE_CHECKING
 | |
| 
 | |
| if TYPE_CHECKING:
 | |
|     from backend.model.tribe import Tribe
 | |
| 
 | |
| 
 | |
| @dataclass
 | |
| class Student:
 | |
|     id: str
 | |
|     name: str
 | |
|     tribe: Tribe
 | |
| 
 | |
|     def __post_init__(self) -> None:
 | |
|         self.tribe.register_student(self)
 | |
| 
 | |
|     def __eq__(self, other: object) -> bool:
 | |
|         if isinstance(other, Student):
 | |
|             return self.id == other.id
 | |
|         return False
 | |
| 
 | |
|     def __hash__(self) -> int:
 | |
|         return hash(self.id)
 |