@instavine · Post #1306 · 19.12.2017 г., 14:00
Relationship Goals💁🏻♀️ ------- #christian
Hashtags
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
Пребарај: #christian
@instavine · Post #1306 · 19.12.2017 г., 14:00
Relationship Goals💁🏻♀️ ------- #christian
Hashtags
@instavine · Post #522 · 28.06.2016 г., 11:14
When your mom asked you to clean your room 3 weeks ago but you forgot😂 Когда мама попросила убраться в комнате 3 недели назад, но ты забыл😂 #christian
Hashtags
@instavine · Post #471 · 18.06.2016 г., 11:45
What you're supposed to do during a fire VS Reality Что вы должны сделать при пожаре VS Реальность #christian
Hashtags
@fight4f · Post #8534 · 09.07.2024 г., 10:52
West Bank 巴勒斯坦基督徒在伯利恆北入口懸掛耶路撒冷十字旗, 並向以色列士兵投擲石塊。 https://t.me/Hezbollah_ru/2646?single #Christian #Palestine
Hashtags
@instavine · Post #690 · 17.08.2016 г., 04:09
The Hypnotist. 🙈😂 ----------------------- #kingbach w/ #christian
Hashtags
@instavine · Post #685 · 12.08.2016 г., 09:08
That helpful friend. 😎😂 --------------------------- "Полезный" друг. --------------------------- #kingbach w/ #christian
Hashtags
@moscowphotog · Post #2270 · 15.10.2025 г., 17:04
🚨🇮🇷 There is about 1 million Christians in Iran and over 600 churches in cities like Tehran, Isfahan, Tabriz, Urmia, and Shiraz. Christianity is officially recognized in #Iran unlike in Israel, where #Christian communities face discrimination and shrinking numbers. The more you know.
Hashtags
@instavine · Post #1268 · 26.09.2017 г., 02:34
The sick robber. 😷😂 ---------- Больной грабитель ---------- #kingbach w/ #christian#curtislepore
Hashtags
@EvaKarene_Bartlett · Post #30203 · 28.03.2026 г., 07:36
#Christian neighborhoods in #Damascus protesting in the middle of the night after targeting the Christians in #Hama by the Islamist gangs calling themselves a government @TheAlawiteEcho The Syrian barbaric islamist gangs are now raiding and vandalizing the #Christian city of Skailbiyah in #Hama after they attacked every single non-Sunni sect and religion https://t.co/GX12QdO06L View tweet
Hashtags
@instavine · Post #830 · 08.10.2016 г., 14:01
If you go thru my phone I'll know. 🕵😂 --------------------- Если ты тронешь мой телефон, я узнаю об этом. 🕵😂 ---------------------- #kingbach w/ #loulou_gonzalez#christian
@instavine · Post #764 · 12.09.2016 г., 14:11
💀😂 ------------------------ #curtislepore w/ #christian#brentrivera
@instavine · Post #757 · 08.09.2016 г., 12:29
#curtislepore w/ #brentrivera#christian