Использование 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
#Update
Claim Your $CRTR Now
If you’re eligible, you can claim your $CRTR right now.
Act fast.
Link : fandora.ai/claim
Sc (BSC) :
0xb150e91Cb40909F47d45115eE9E90667D807464B
#Update
Pacifica Perp War Competition (Original Article)
There's a Perp War competition going on in Pacifica
You can choose one of the two teams to participate, and the winning team will receive a total of 500,000 points. So, Pacifica users, let's definitely register to participate!
- Total prize pool: 500,000 points
- Duration: ~ March 4th
- Teams: Bulls / Bears (choose one)
- Participation eligibility: Anyone
- Scoring method: (Trading volume ranking + PnL ranking) ÷ 2
* Only trading activities from after registration will be recognized, so please register on the Event tab first 🤲
Go directly to Pacifica
#Update
This week, 150 SafePal x Morpho co-branded X1 hardware wallets will be drawn from users who deposited ≥100 USDT
Meanwhile
• Top 50 depositors get the limited-edition wallet directly
• Depositors with ≥1,000 USDT will share $5,000 in $MORPHO
Huge congrats to all the winners!
#Update on BTC/USDT Analysis-
According to the analysis, after falling more than 30% in just one week, BTC has found support precisely at 49,000.
There are five psychological probabilities following this significant drop:
1. BTC could make a V-shaped recovery from this price level.
2. BTC could consolidate for more than 2-3 weeks before breaking out or breaking down.
3. BTC could break down below 49,000 and resume its downtrend.
4. BTC could initially break down, giving a false signal, and then rise.
5. BTC could consolidate for 2-3 weeks, then give a false breakout or breakdown and move in the opposite direction of breakout or breakdown.
📱│Remini v3.7.1305.202520468 (Pro)
⚙│ Android: 7.0 and up #update
🔔
🅿️ │ Play Store / Official Site Link
━━━━━━━━━━━━━━━━━━━
☑ | Features & Mod Info⭐
◉ Powerful Photo enhancer app in World
◉ Enhance blurry, pixelated photos to HD
◉ Auto recognize > enhance facial details
◉ Unblur photo and make photo clearer
◉ Repair old, blurry, scratched photos
◉ Enhance background and colors
◉ Pro Features Unlocked, No Ads
◉ Multi Languages & CPUs: Arm32/64
⚠️ Video Enhance feature is server-side
✍️ | Release by Mixroot
━━━━━━━━━━━━━━━━━━━
📥Link : CLICK HERE TO DOWNLOAD
━━━━━━━━━━━━━━━━━━━
▶️Tutorial : How To Download Mod
━━━━━━━━━━━━━━━━━━━
🔄Official Channel ➜ @Mixrootmods
📱│Picsart v29.7.7 (Gold / Premium)
⚙ │ Android: 6.0 and up #update
🔔
🅿️ │ Play Store / Official Site Link
━━━━━━━━━━━━━━━━━━━
☑ | Features & Mod Info
✅
◉ The best all-in-one photo & video editor
◉ beautify / drawing tools and more!
◉ No professional experience needed!
◉ Gold / Premium Membership Unlocked
◉ Al Avatar not works as it's server-sided
◉ Sign-in No Required / Bypassed
◉ Multi Languages & CPUs: Arm32/64
⚠️Ai features require login
✍️ | Release by Mixroot
━━━━━━━━━━━━━━━━━━━
📥Link : CLICK HERE TO DOWNLOAD
━━━━━━━━━━━━━━━━━━━
▶️Tutorial : How To Download Mod
━━━━━━━━━━━━━━━━━━━
🔄Official Channel ➜ @Mixrootmods
📱│ SnapTube v7.57.0.75750310 (VIP)
⚙│ Android: 5.0 and up #update
🔔
🅿️ │ Play Store / Official Site Link
━━━━━━━━━━━━━━━━━━━
☑ | Features & Mod Info⭐
◉ Ability to download from many sites
◉ IG, Fb post downloader, Status Saver
◉ Download in multiple resolutions
◉ Download any video as an MP3 file
◉ Explore videos in Ur favorite categories
◉ Pause, Cancel or resume downloads
◉ VIP features unlocked / No ads
◉ Multi Languages & CPUs: Arm32/64
➡️Read Full Mod info (Click here)
✍️ | Release by Balatan
━━━━━━━━━━━━━━━━━━━
📥Link : CLICK HERE TO DOWNLOAD
━━━━━━━━━━━━━━━━━━━
▶️Tutorial : How To Download Mod
━━━━━━━━━━━━━━━━━━━
🔄Official Channel ➜ @Mixrootmods
📱 Truecaller v26.8.6 [Gold] [Mod]
⚙│ Android: 8.0 and up #update
🔔
🅿️ │ Play Store / Official Site Link
━━━━━━━━━━━━━━━━━━━
☑ | Features & Mod Info ⭐
◉ Powerful Caller ID » know who’s calling
◉ Block spam + scam calls and SMS
◉ Stay protected from Scammerscallers
◉ Search for phone numbers with Dialer
◉ Advanced blocking & filtering options
◉ Can Use it as your text messaging app
◉ Know who viewed your profile
◉ Get the Premium badge on your profile
◉ Gold Features Unlocked, No ads
◉ Multi Languages & CPUs: Arm32/64
➡️Read Full Mod info(Click here)
✍️ | Release by Balatan
━━━━━━━━━━━━━━━━━━━
📥Link : CLICK HERE TO DOWNLOAD
━━━━━━━━━━━━━━━━━━━
▶️Tutorial : How To Download Mod
━━━━━━━━━━━━━━━━━━━
🔄Official Channel ➜ @Mixrootmods
📱│Remini v3.7.1299.202520143 (Pro)
⚙│ Android: 7.0 and up #update
🔔
🅿️ │ Play Store / Official Site Link
━━━━━━━━━━━━━━━━━━━
☑ | Features & Mod Info⭐
◉ Powerful Photo enhancer app in World
◉ Enhance blurry, pixelated photos to HD
◉ Auto recognize > enhance facial details
◉ Unblur photo and make photo clearer
◉ Repair old, blurry, scratched photos
◉ Enhance background and colors
◉ Pro Features Unlocked, No Ads
◉ Multi Languages & CPUs: Arm32/64
⚠️ Video Enhance feature is server-side
✍️ | Release by Mixroot
━━━━━━━━━━━━━━━━━━━
📥Link : CLICK HERE TO DOWNLOAD
━━━━━━━━━━━━━━━━━━━
▶️Tutorial : How To Download Mod
━━━━━━━━━━━━━━━━━━━
🔄Official Channel ➜ @Mixrootmods
📱 VPN - Super Unlimited Proxy v2.22.1 (Premium)
⚙│ Android: 8.0 and up #update
🔔
🅿️ │ Play Store / Official Site Link
━━━━━━━━━━━━━━━━━━━
☑ | Features & Mod Info⭐
◉ Worldwide stable and fast servers
◉ Best VPN app for Android device
◉ Secure your all online activities
◉ Remain anonymous online, safe
◉ Hide your ip address and location
◉ Unblock websites & applications
◉ Premium / Paid Features Unlocked
◉ Multi Languages & CPUs: Arm32/64
✍️ | Release by Mixroot
━━━━━━━━━━━━━━━━━━━
📥Link : CLICK HERE TO DOWNLOAD
━━━━━━━━━━━━━━━━━━━
▶️Tutorial : How To Download Mod
━━━━━━━━━━━━━━━━━━━
🔄Official Channel ➜ @Mixrootmods