@WorldNews · Post #74218 · 19.04.2026 г., 02:59
Pope Leo Speaks Out Against Exploitation of Africa’s Resources [Read FullArticle] @WorldNews#WorldNews#Africa#Pope
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
Пребарај: #pope
@WorldNews · Post #74218 · 19.04.2026 г., 02:59
Pope Leo Speaks Out Against Exploitation of Africa’s Resources [Read FullArticle] @WorldNews#WorldNews#Africa#Pope
Hashtags
@trumpsear_tg · Post #1811 · 21.11.2025 г., 18:02
Catholics believe in holy water. How about holy beer? Pope Leo received a special gift on Wednesday from Illinois Governor JB Pritzker, a four-pack of American mild ale from a Chicago brewery. Pritzker, visiting Leo at the Vatican, handed the beers over to the pope as part of a gift exchange. He suggested Leo, originally from Chicago and the first U.S. pope, might enjoy a local brew. "We'll put that in the fridge," Leo responded, taking the beers and putting them on a table. #Catholics#Pope 👂More on Trump's Ear
Hashtags
@WorldNews · Post #74161 · 16.04.2026 г., 12:49
Pope: World is being ravaged by a handful of tyrants [Read FullArticle] @WorldNews#Pope#WorldNews#GlobalPolitics
Hashtags
@WorldNews · Post #74144 · 15.04.2026 г., 16:49
Pope Leo, attacked again by Trump, says world needs message of peace [Read FullArticle] @WorldNews#Pope#Peace#WorldNews
Hashtags
@american_observer · Post #5765 · 02.05.2026 г., 18:00
#pope#us#peru 📱American Оbserver - Stay up to date on all important events 🇺🇸
@googlefactss · Post #40570 · 22.01.2026 г., 11:02
The Swiss Guard is a small group of soldiers who protect the Pope and the Vatican. They were officially established on January 22, 1506, when the first Swiss soldiers arrived in Rome. Known for their colorful uniforms and fierce loyalty, the Swiss Guard has been keeping the Pope safe every day for over 500 years. 🇻🇦🛡️⚔️ [Read more] @googlefactss#SwissGuard#Vatican#Pope#History#Security #1506