@ai_match_prediction · Post #11962 · 08.05.2026 г., 13:05
Italy Serie A🇮🇹 2026-05-08 18:45 UTC Torino vs. Sassuolo Predicted outcome: Torino✅ Predicted score: 2:1 Actual: Torino 2:1 #Torino#Sassuolo #Football#ItalySerieA
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
Пребарај: #sassuolo
@ai_match_prediction · Post #11962 · 08.05.2026 г., 13:05
Italy Serie A🇮🇹 2026-05-08 18:45 UTC Torino vs. Sassuolo Predicted outcome: Torino✅ Predicted score: 2:1 Actual: Torino 2:1 #Torino#Sassuolo #Football#ItalySerieA
@ai_match_prediction · Post #11536 · 17.04.2026 г., 09:05
Italy Serie A🇮🇹 2026-04-17 16:30 UTC Sassuolo vs. Como Predicted outcome: Como❌ Predicted score: 1:2 Actual: Sassuolo 2:1 #Sassuolo#Como 2026-04-17 18:45 UTC Inter vs. Cagliari Predicted outcome: Inter✅ Predicted score: 3:1 Actual: Inter 3:0 #Inter#Cagliari #Football#ItalySerieA
@ai_match_prediction · Post #11273 · 04.04.2026 г., 05:05
Italy Serie A🇮🇹 2026-04-04 13:00 UTC Sassuolo vs. Cagliari Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Sassuolo 2:1 #Sassuolo#Cagliari 2026-04-04 16:00 UTC Hellas Verona vs. Fiorentina Predicted outcome: Fiorentina✅ Predicted score: 1:2 Actual: Fiorentina 0:1 #HellasVerona#Fiorentina 2026-04-04 18:45 UTC Lazio vs. Parma Predicted outcome: Lazio❌ Predicted score: 1:0 Actual: Draw 1:1 #Lazio#Parma #Football#ItalySerieA
@ai_match_prediction · Post #11122 · 21.03.2026 г., 09:05
Italy Serie A🇮🇹 2026-03-21 14:00 UTC Parma vs. Cremonese Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Cremonese 0:2 #Parma#Cremonese 2026-03-21 17:00 UTC AC Milan vs. Torino Predicted outcome: AC Milan✅ Predicted score: 2:1 Actual: AC Milan 3:2 #Milan#Torino 2026-03-21 19:45 UTC Juventus vs. Sassuolo Predicted outcome: Juventus❌ Predicted score: 2:1 Actual: Draw 1:1 #Juventus#Sassuolo #Football#ItalySerieA
@ai_match_prediction · Post #11878 · 03.05.2026 г., 05:05
Italy Serie A🇮🇹 2026-05-03 10:30 UTC Bologna vs. Cagliari Predicted outcome: Bologna❌ Predicted score: 2:1 Actual: Draw 0:0 #Bologna#Cagliari 2026-05-03 13:00 UTC Sassuolo vs. AC Milan Predicted outcome: AC Milan❌ Predicted score: 1:2 Actual: Sassuolo 2:0 #Sassuolo#Milan 2026-05-03 16:00 UTC Juventus vs. Hellas Verona Predicted outcome: Juventus❌ Predicted score: 2:0 Actual: Draw 1:1 #Juventus#HellasVerona 2026-05-03 18:45 UTC Inter vs. Parma Predicted outcome: Inter✅ Predicted score: 3:1 Actual: Inter 2:0 #Inter#Parma #Football#ItalySerieA
@ai_match_prediction · Post #11752 · 26.04.2026 г., 09:06
Italy Serie A🇮🇹 2026-04-26 10:30 UTC Fiorentina vs. Sassuolo Predicted outcome: Sassuolo❌ Predicted score: 1:2 Actual: Draw 0:0 #Fiorentina#Sassuolo 2026-04-26 13:00 UTC Genoa vs. Como Predicted outcome: Como✅ Predicted score: 1:2 Actual: Como 0:2 #Genoa#Como 2026-04-26 16:00 UTC Torino vs. Inter Predicted outcome: Inter❌ Predicted score: 1:3 Actual: Draw 2:2 #Torino#Inter 2026-04-26 18:45 UTC AC Milan vs. Juventus Predicted outcome: Juventus❌ Predicted score: 1:2 Actual: Draw 0:0 #Milan#Juventus #Football#ItalySerieA
@ai_match_prediction · Post #11459 · 12.04.2026 г., 05:05
Italy Serie A🇮🇹 2026-04-12 10:30 UTC Genoa vs. Sassuolo Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Genoa 2:1 #Genoa#Sassuolo 2026-04-12 13:00 UTC Parma vs. Napoli Predicted outcome: Napoli❌ Predicted score: 0:1 Actual: Draw 1:1 #Parma#Napoli 2026-04-12 16:00 UTC Bologna vs. Lecce Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Bologna 2:0 #Bologna#Lecce 2026-04-12 18:45 UTC Como vs. Inter Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Inter 3:4 #Como#Inter #Football#ItalySerieA