не могу разобраться с переменными в классах pydantic и fastapi

from typing import Union
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

Mlist = (0, 770, 1540, 2310, 3080, 3850, 4620, 5620)

Mtable = {
    1: "Herald",
    2: "Guardin",
    3: "Crusader",
    4: "Archon",
    5: "Legend",
    6: "Ancient",
    7: "Divine",
    8: "Immortal"
}

class Dota_Diller():
    name: str
    mmr: int
    cnt = 0

    for i in range(len(Mlist)- 1):
       if mmr <= Mlist[i]:
          rank: Mtable[cnt]
          break
       cnt += 1

    def __str__(self):
        return f"{self.name} is {self.rank} with {self.mmr} mmr"

player1 = Dota_Diller(name="Pavel", mmr=1900)
player2 = Dota_Diller(name="Sanya", mmr=700)
player3 = Dota_Diller(name="Arheep",mmr= 1300)
player4 = Dota_Diller(name="Danil", mmr=4300)

print(f"{player1}\n{player2}\n{player3}\n{player4}")

@app.get("/rank")
def get_rank(player: Dota_Diller):
    return {"data":player1}

не дает мне инициализировать 'rank'


Ответы (0 шт):