TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

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

Резултати

Пронајдени 723 слични објави

Пребарај: #full

当前筛选 #full清除筛选
Найс хуйня

@hz_nice · Post #45705 · 04.05.2026 г., 07:08

#full Внезапный дроп без випки, картинка была заспидранена за ±4 часа. Happy golden week + Too Lily nation rise up!!!! Гантесс счастливый сукин сын П. С. Буду рада активу и репостам🥺

Hashtags

Найс хуйня

@hz_nice · Post #45450 · 30.04.2026 г., 13:28

представьте, что сзади бассейн (да, я думаю, что вы будете смотреть на задний фон 🤦‍♂️) #full

Hashtags

⭐️ Melo|26 years old|165cm|F cup #Elegant sister #Active licking #Full of milk 💋 A mature sister type, with a gentle and flirtatious voice~ 💋 The milk is soft and feels good, and the licking and blowing skills are first-class, making you feel so soft/// 💋 I like to make you relax, feel comfortable, and keep shouting don’t stop~ "Come on~ I'll take care of you tonight, okay? I'll make your whole body melt♡" 🍼TG:@aa11603 🍼Gleezy:aa1160 3 🇯🇵東京出張:@aa11605 🇯🇵大阪出張:@aa11604

Найс хуйня

@hz_nice · Post #45138 · 25.04.2026 г., 16:43

Заказ Набрали сразу на обе версии, как и обещала ❤️ ™️Приватка | 💰 Boosty |⭐️Буст 🩷Ссылка для друга | Заказать арт #Commission#Jinx#Full

OnePlus OS Update Tracker

@OnePlusOTA · Post #378 · 25.11.2021 г., 04:28

OnePlus 9 Pro OxygenOS 11.2.10.10.LE15DA System • Optimized the third-party app experience • Updated Android security patch to 2021.11 • Improved System stability and fixed known issues MD5 Full: 09c31b70fc4e9fe534f31650d9f571e1 Size Full: 3.09 GB (3314455894) Downloads Oxygen OS Server 1: Full Oxygen OS Server 2: Full Oxygen OS Server 3: Full Color OS Global Server 1: Full Color OS Global Server 2: Full Color OS Global Server 3: Full Color OS Global Server 4: Full Exported by MlgmXyysd Color OTA Bot@OnePlusOTA #Oxygen#lemonadep#India#Full

OnePlus OS Update Tracker

@OnePlusOTA · Post #301 · 17.09.2021 г., 14:54

OnePlus 9 Pro Oxygen OS 11.2.9.9.LE15DA System • Optimized the wireless charging experience • Updated Android security patch to 2021.09 • Fixed known issues and improved stability Camera • Newly added XPan Mode, reproduces the preview box and unique aspect ratio of the legendary camera series "XPan". It includes two unique filter styles - 'color film', 'black and white film' and a 'film processing imitation' effect that recreates the classic elements of retro shooting experiences MD5 Full: ffd3fdf79fa8386dcfd4583bf8fb5248 Size Full: 3.08 GB (3306203523) Downloads Oxygen OS Server 1: Full Oxygen OS Server 2: Full Color OS Global Server 1: Full Color OS Global Server 2: Full Exported by MlgmXyysd Color OTA Bot@OnePlusOTA #Oxygen#lemonadep#India#Full

OnePlus OS Update Tracker

@OnePlusOTA · Post #242 · 27.07.2021 г., 15:36

OnePlus 9 Pro Oxygen OS 11.2.8.8.LE15DA System • Updated Android security patch to 2021.07 • Fixed known issues and improved stability Ambient Display • Newly added Bitmoji AOD, co-designed by Snapchat & Bitmoji, which will liven up the ambient display with your personal Bitmoji avatar. Your avatar will update throughout the day based on your activity and things happening around you ( Path: Settings - Customization - Clock on ambient display - Bitmoji ) OnePlus Store • An intuitive and convenient way to manage your OnePlus account, get easy-to-access support, discover exciting members-only benefits, and shop for OnePlus products. (Please note that it can be uninstalled) MD5 Full: 62368ae1f660dca13c65f00828379b0c Size Full: 3.08 GB (3305763243) Downloads Oxygen OS Server: Full Color OS Server: Full Exported by MlgmXyysd Color OTA Bot@OnePlusOTA #Oxygen#lemonadep#India#Full

OnePlus OS Update Tracker

@OnePlusOTA · Post #187 · 05.06.2021 г., 13:17

OnePlus 9 Pro Oxygen OS 11.2.7.7.LE15DA System • Reduced power consumption in specific scenarios • Fixed known issues and improved stability Camera • Newly added HDR option in video recording interface(Path: Menu options in the upper right corner of the screen-Dynamic video) • Improved the shooting and recording experience MD5 Full: e4d3cf62015c3e9d22a332c0fe2bff48 Size Full: 3.05 GB (3270655770) Downloads Oxygen OS Server: Full Color OS Server: Full Exported by MlgmXyysd Color OTA Bot@OnePlusOTA #Oxygen#lemonadep#India#Full

123•••5•••10•••15•••20•••25•••30•••35•••40•••45•••50•••55•••6061
ПретходнаСтраница 1 од 61Следна