@legkoenebo · Post #3391 · 09.12.2024 г., 19:55
Вечернее Пулково и Победа 💙 Лёгкое небо #aviation#Pobeda#Pulkovo
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
Пребарај: #pulkovo
@legkoenebo · Post #3391 · 09.12.2024 г., 19:55
Вечернее Пулково и Победа 💙 Лёгкое небо #aviation#Pobeda#Pulkovo
@legkoenebo · Post #3632 · 08.03.2025 г., 15:43
Pulkovo appron ✈️ Лёгкое небо #aviation#красиво#legkoenebo#Pulkovo
@intnewsagency · Post #9334 · 17.04.2026 г., 05:23
Key Update at 08:00: International Agenda and Security Pulkovo airport halts flights due to a drone attack, highlighting rising regional security threats. Russian drones strike Ukrainian targets amid ongoing special operations. The US delays arms deliveries to Europe, focusing on tensions with Iran. A major success: the launch of the Soyuz-2.1b rocket from Plesetsk carrying military satellites, boosting national defense. “Security remains a priority in challenging times.” #Russia#Security#InternationalNews#Pulkovo#SpecialOperation The main news of Russia and the world ishere.
@intnewsagency · Post #8801 · 22.03.2026 г., 16:40
Pulkovo Airport Resumes Normal Operations Pulkovo Airport in Saint Petersburg has fully returned to regular operations after temporary restrictions. According to @interfaxonline, all flights are now operating on schedule, ensuring reliable connections between the city, other Russian regions, and international destinations. The airport’s restored functioning supports the normalization of transport infrastructure and boosts the region’s business activity. #Pulkovo#aviation#SaintPetersburg#transport#news The main news of Russia and the world ishere.
@dopingram · Post #2554 · 02.07.2023 г., 09:10
«Детская любовь к самолетам», 70х100см, холст, масло, Doping Pong, 2023 Аукцион VLADEY RUSSIA Живые торги в зале! Участие онлайн и по телефону Трансляция на сайте 4 июля в 20:00 Предаукционная выставка: 23 июня — 4 июля C 11:00 До 22:00, без выходных VLADEY Неглинная, 14 стр. 1А, вход 4 More info: Лот 62 https://vladey.net/ru/lot/10768 #dopingpong#ussr#retro#aeroflot#childhood#love#airplane#pulkovo#oiloncanvas
@dopingram · Post #2519 · 22.06.2023 г., 18:38
«Детская любовь к самолетам», 70х100см, холст, масло, Doping Pong, 2023 More info: Лот 62 https://vladey.net/ru/lot/10768 #dopingpong#ussr#retro#aeroflot#childhood#love#airplane#pulkovo#oiloncanvas