@ai_match_prediction · Post #12050 · 11.05.2026 г., 13:05
England Premier League🏴 2026-05-11 19:00 UTC Tottenham vs. Leeds Predicted outcome: Leeds❌ Predicted score: 1:2 Actual: Draw 1:1 #Tottenham#Leeds #Football#PremierLeague
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
Пребарај: #leeds
@ai_match_prediction · Post #12050 · 11.05.2026 г., 13:05
England Premier League🏴 2026-05-11 19:00 UTC Tottenham vs. Leeds Predicted outcome: Leeds❌ Predicted score: 1:2 Actual: Draw 1:1 #Tottenham#Leeds #Football#PremierLeague
@ai_match_prediction · Post #11827 · 01.05.2026 г., 13:05
England Premier League🏴 2026-05-01 19:00 UTC Leeds vs. Burnley Predicted outcome: Leeds✅ Predicted score: 2:1 Actual: Leeds 3:1 #Leeds#Burnley #Football#PremierLeague
@ai_match_prediction · Post #11499 · 13.04.2026 г., 13:05
England Premier League🏴 2026-04-13 19:00 UTC Manchester United vs. Leeds Predicted outcome: Manchester United❌ Predicted score: 2:1 Actual: Leeds 1:2 #ManchesterUnited#Leeds #Football#PremierLeague
@UltimoraPOlitics · Post #38553 · 06.05.2022 г., 16:05
#Elezioni #RegnoUnito #Amministrative Consiglio di #Leeds, risultati definitivi: #LAB|S&D: 21 (+2) #CON|ECR: 6 (-2) Morley Borough Independents: 3 #LDEM|RE: 2 (-1) #Greens|G/EFA: 1 #SDP|Centro-sinistra euroscettico conservatore: 1 (+1) Attuale composizione…
@UltimoraPOlitics · Post #38550 · 06.05.2022 г., 16:00
#Elezioni#RegnoUnito#Amministrative Consiglio di #Leeds, risultati definitivi: #LAB|S&D: 21 (+2) #CON|ECR: 6 (-2) Morley Borough Independents: 3 #LDEM|RE: 2 (-1) #Greens|G/EFA: 1 #SDP|Centro-sinistra euroscettico conservatore: 1 (+1) Attuale composizione del Consiglio: #LAB|S&D: 57 #CON|ECR: 21 #LDEM|RE: 7 Morley Borough Independents: 3 Garforth & Swillington Independents: 3 #Greens|G/EFA: 3 Indipendenti: 2 #SDP|Centro-sinistra euroscettico conservatore: 1 I LAB mantengono il controllo del Consiglio. @UltimoraPolitics
@ai_match_prediction · Post #11664 · 22.04.2026 г., 13:05
England Premier League🏴 2026-04-22 19:00 UTC Bournemouth vs. Leeds Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 2:2 #Bournemouth#Leeds 2026-04-22 19:00 UTC Burnley vs. Manchester City Predicted outcome: Manchester City✅ Predicted score: 1:3 Actual: Manchester City 0:1 #Burnley#ManchesterCity #Football#PremierLeague
@ai_match_prediction · Post #11116 · 21.03.2026 г., 05:05
England Premier League🏴 2026-03-21 12:30 UTC Brighton vs. Liverpool Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Brighton 2:1 #Brighton#Liverpool 2026-03-21 15:00 UTC Fulham vs. Burnley Predicted outcome: Fulham✅ Predicted score: 2:1 Actual: Fulham 3:1 #Fulham#Burnley 2026-03-21 17:30 UTC Everton vs. Chelsea Predicted outcome: Chelsea❌ Predicted score: 1:2 Actual: Everton 3:0 #Everton#Chelsea 2026-03-21 20:00 UTC Leeds vs. Brentford Predicted outcome: Draw✅ Predicted score: 2:2 Actual: Draw 0:0 #Leeds#Brentford #Football#PremierLeague
@ai_match_prediction · Post #11558 · 18.04.2026 г., 05:05
England Premier League🏴 2026-04-18 11:30 UTC Brentford vs. Fulham Predicted outcome: Brentford❌ Predicted score: 2:1 Actual: Draw 0:0 #Brentford#Fulham 2026-04-18 14:00 UTC Newcastle vs. Bournemouth Predicted outcome: Draw❌ Predicted score: 2:2 Actual: Bournemouth 1:2 #Newcastle#Bournemouth 2026-04-18 14:00 UTC Leeds vs. Wolves Predicted outcome: Leeds✅ Predicted score: 2:1 Actual: Leeds 3:0 #Leeds#Wolves 2026-04-18 16:30 UTC Tottenham vs. Brighton Predicted outcome: Brighton❌ Predicted score: 1:2 Actual: Draw 2:2 #Tottenham#Brighton 2026-04-18 19:00 UTC Chelsea vs. Manchester United Predicted outcome: Draw❌ Predicted score: 2:2 Actual: Manchester United 0:1 #Chelsea#ManchesterUnited #Football#PremierLeague