@ai_match_prediction · Post #11698 · 24.04.2026 г., 13:05
Spain La Liga🇪🇸 2026-04-24 19:00 UTC Real Betis vs. Real Madrid Predicted outcome: Real Madrid❌ Predicted score: 1:2 Actual: Draw 1:1 #RealBetis#RealMadrid #Football#SpainLaLiga
TGINSIGHT SIMILAR POSTS
Изворен канал @pythonotes · Post #397 · 12 ное.
Использование Pydantic сегодня стало нормой, и это правильно. Но иногда на ревью вижу, что используют его не всегда корректно. Например, метод BaseModel.model_dump() по умолчанию не преобразует стандартные типы, такие как datetime, UUID или Decimal, в простой сериализуемый для JSON вид. Тогда пишут кастмоный сериализатор для этих типов чтобы функция json.dump() не падала с ошибкой. import uuid from datetime import datetime from decimal import Decimal from uuid import UUID from pydantic import BaseModel class MyModel(BaseModel): id: UUID date: datetime value: Decimal obj = MyModel( id=uuid.uuid4(), date=datetime.now(), value='1.23' ) print(obj.model_dump()) # не подходит для json.dump # { # 'id': UUID('4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1'), # 'date': datetime.datetime(2025, 12, 12, 12, 12, 12, 111111), # 'value': Decimal('1.23') # } # добавляем свой кастомный сериализатор json.dumps(obj.model_dump(), cls=MySerializer) # { # 'id': '4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1', # 'date': '2025-12-12T12:12:12.111111', # 'value': '1.23' # } В данном случае класс MySerializer обрабатывает datetime, UUID и Decimal. Например так: class MySerializer(json.JSONEncoder): def default(self, o): if isinstance(o, Decimal): return str(o) elif isinstance(o, datetime): return o.isoformat() elif isinstance(o, UUID): return str(o) return super().default(o) Специально для тех, кто всё еще так делает - в этом нет необходимости! Pydantic может это сделать сам, просто нужно добавить параметр mode="json". json.dumps(obj.model_dump(mode="json")) # { # 'id': '4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1', # 'date': '2012-12-12T12:12:12.111111', # 'value': '1.23' # } #pydantic#libs
Пребарај: #spainlaliga
@ai_match_prediction · Post #11698 · 24.04.2026 г., 13:05
Spain La Liga🇪🇸 2026-04-24 19:00 UTC Real Betis vs. Real Madrid Predicted outcome: Real Madrid❌ Predicted score: 1:2 Actual: Draw 1:1 #RealBetis#RealMadrid #Football#SpainLaLiga
@ai_match_prediction · Post #12048 · 11.05.2026 г., 13:05
Spain La Liga🇪🇸 2026-05-11 19:00 UTC Rayo Vallecano vs. Girona Predicted outcome: Rayo Vallecano❌ Predicted score: 2:1 Actual: Draw 1:1 #RayoVallecano#Girona #Football#SpainLaLiga
@ai_match_prediction · Post #11255 · 03.04.2026 г., 13:05
Spain La Liga🇪🇸 2026-04-03 19:00 UTC Rayo Vallecano vs. Elche Predicted outcome: Rayo Vallecano✅ Predicted score: 2:1 Actual: Rayo Vallecano 1:0 #RayoVallecano#Elche #Football#SpainLaLiga
@ai_match_prediction · Post #11400 · 10.04.2026 г., 13:05
Spain La Liga🇪🇸 2026-04-10 19:00 UTC Real Madrid vs. Girona Predicted outcome: Real Madrid❌ Predicted score: 2:1 Actual: Draw 1:1 #RealMadrid#Girona #Football#SpainLaLiga
@ai_match_prediction · Post #11959 · 08.05.2026 г., 13:05
Spain La Liga🇪🇸 2026-05-08 19:00 UTC Levante vs. Osasuna Predicted outcome: Levante✅ Predicted score: 2:1 Actual: Levante 3:2 #Levante#Osasuna #Football#SpainLaLiga
@ai_match_prediction · Post #11825 · 01.05.2026 г., 13:05
Spain La Liga🇪🇸 2026-05-01 19:00 UTC Girona vs. Mallorca Predicted outcome: Girona❌ Predicted score: 2:1 Actual: Mallorca 0:1 #Girona#Mallorca #Football#SpainLaLiga
@ai_match_prediction · Post #11497 · 13.04.2026 г., 13:05
Spain La Liga🇪🇸 2026-04-13 19:00 UTC Levante vs. Getafe Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Levante 1:0 #Levante#Getafe #Football#SpainLaLiga
@ai_match_prediction · Post #11786 · 27.04.2026 г., 13:05
Spain La Liga🇪🇸 2026-04-27 19:00 UTC Espanyol vs. Levante Predicted outcome: Espanyol❌ Predicted score: 2:1 Actual: Draw 0:0 #Espanyol#Levante #Football#SpainLaLiga
@ai_match_prediction · Post #11350 · 06.04.2026 г., 13:05
Spain La Liga🇪🇸 2026-04-06 19:00 UTC Girona vs. Villarreal Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Girona 1:0 #Girona#Villarreal #Football#SpainLaLiga
@ai_match_prediction · Post #11918 · 04.05.2026 г., 13:05
Spain La Liga🇪🇸 2026-05-04 19:00 UTC Sevilla vs. Real Sociedad Predicted outcome: Real Sociedad❌ Predicted score: 1:2 Actual: Sevilla 1:0 #Sevilla#RealSociedad #Football#SpainLaLiga
@ai_match_prediction · Post #12059 · 12.05.2026 г., 09:05
Spain La Liga🇪🇸 2026-05-12 17:00 UTC Celta Vigo vs. Levante Predicted outcome: Celta Vigo❌ Predicted score: 2:1 Actual: Levante 2:3 #CeltaVigo#Levante 2026-05-12 18:00 UTC Real Betis vs. Elche Predicted outcome: Real Betis✅ Predicted score: 2:1 Actual: Real Betis 2:1 #RealBetis#Elche 2026-05-12 19:30 UTC Osasuna vs. Atletico Madrid Predicted outcome: Osasuna❌ Predicted score: 2:1 Actual: Atletico Madrid 1:2 #Osasuna#AtleticoMadrid #Football#SpainLaLiga
@ai_match_prediction · Post #11973 · 09.05.2026 г., 05:05
Spain La Liga🇪🇸 2026-05-09 12:00 UTC Elche vs. Alaves Predicted outcome: Elche❌ Predicted score: 3:2 Actual: Draw 1:1 #Elche#Alaves 2026-05-09 16:30 UTC Atletico Madrid vs. Celta Vigo Predicted outcome: Atletico Madrid❌ Predicted score: 2:1 Actual: Celta Vigo 0:1 #AtleticoMadrid#CeltaVigo 2026-05-09 19:00 UTC Real Sociedad vs. Real Betis Predicted outcome: Real Sociedad❌ Predicted score: 3:2 Actual: Draw 2:2 #RealSociedad#RealBetis #Football#SpainLaLiga