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

Резултати

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

Пребарај: #transparency

当前筛选 #transparency清除筛选
PizzApp Design - Wallpapers & Icon Packs

@pizzapp_design · Post #7729 · 14.05.2026 г., 10:50

♾️#Transparency#IconPack Limited Time SALE 🎉 📲 Codes WLH0A5YS6KL0M6MMAWXH9NZ 6Y3T4E6KJTW3BPSQ40GB2X7 7KX00KFBLVMEHMS7JCX8DVU GDX1LQ8SARD78Q85MR51WPC STBJNPFEP3QNBE0XYVKVYZN FYLFUE2ZPW2MMBP2Q9S9TTF KJSEPH59SDYGAM9T28Q7Z9G NFTCRKMP8057CL9054DAT2Q 1M6PDFEXWHL0EW80P2AMNHU 09BBT4LBN8048BK0H68WH6D 🖥Download Here ⭐️Rate & Review to support me!

America 🇺🇸 News & Politics

@America · Post #10401 · 20.03.2026 г., 13:03

🚨💰IRS GLITCH HIDES $51M IN POLITICAL DONATIONS 🔹 Technical error masks campaign contributions to state-level groups for Q4 2025 📊 🔹 Republican Attorney General's Association, RSLC affected - $41M in donations missing 💸 🔹 IRS workforce cut 27% by DOGE efficiency drive - system failures mounting rapidly 🏛️ 🔹 527 organizations face April 15 deadline with completely broken e-filing system ⏰ 🔹 Center for Political Accountability warns of "complete black hole" in transparency 🕳️ 🔹 Affected groups include RGA ($32M), DLCC - major election funding obscured 📋 The most transparent democracy? More like broken bureaucracy failing voters 😤🇺🇸 #USNews#politics#transparency @america

AI & Law

@ai_and_law · Post #308 · 16.05.2024 г., 07:04

Microsoft Touts Responsible AI Efforts in New Report Microsoft released a comprehensive report, the "Responsible AI Transparency Report," detailing its initiatives for developing and deploying responsible Artificial Intelligence technologies. The report highlights Microsoft's commitment to building safe and responsible generative AI, a field where the company has actively pursued innovation. Microsoft emphasizes its safety efforts, including: ✅ Launching over 30 tools to empower developers with responsible AI practices. ✅ Providing more than 100 features within Azure to assist customers in deploying safe AI solutions. ✅ Expanding its responsible AI community by 17%, now exceeding 400 members. ✅ Mandating responsible AI training for all employees, with a 99% completion rate for relevant modules. The report concludes with a commitment from Microsoft to invest further in responsible AI development tools for its customers. #ResponsibleAI#Transparency

AI & Law

@ai_and_law · Post #593 · 17.06.2025 г., 07:04

🇺🇸When “AI-First” Means 700 Humans Behind the Curtain BuilderAI, a Microsoft-backed startup once hailed as a pioneer in “AI-powered app creation,” has reportedly gone bankrupt — and not for lack of demand. While the company promoted itself as using artificial intelligence to automate software development, recent revelations show that it relied heavily on a workforce of 700 people in India to do the work manually. #AI ##ResponsibleAI#Transparency

123•••56
ПретходнаСтраница 1 од 6Следна