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

Резултати

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

Пребарај: #lunaris

当前筛选 #lunaris清除筛选
Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #694 · 23.11.2025 г., 14:26

LunarisAOSP - Official | A16 | Nothing Phone 2 (Pong) ✍️ Details: - Version: 3.5 - Codename: #Pong - Updated : 23/11/'25 🔽 Download: Here | Mirror 🆘 Support : Here 📖 Changelogs: Here 📸 Screenshots:Here 💰 Donation: steinsgate007@axl | BMC | Paypal 🔖 Tags : #ROM#AOSP#lunaris ✍️ Note: • Latest base firmware is recommended • Strong integrity by default • Ksu inbuild • If you face any bugs, report with logs. • Initial NTcamera and dolby support available 🏆 Credits: - Hellboy for kernel - Fabian and Hellboy for Glyph Implementation 👤 Maintainer : @Ghosutox 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #683 · 14.10.2025 г., 16:23

LunarisAOSP - Official | A16 | Nothing Phone 2 (Pong) ✍️ Details: - Version: 3.4 - Codename: #Pong - Updated : 14/10/'25 🔽 Download: Here | Mirror 🆘 Support : Here 📖 Changelogs: Here 📸 Screenshots:Here 💰 Donation: steinsgate007@axl | BMC | Paypal 🔖 Tags : #ROM#AOSP#lunaris 📚 Device: - Custom Call glyph pattern implementation - Add shake to toggle glyph torch - Tune powerhint - Enable WiFi 6 - Add configurable ringer mode for flip to glyph ✍️ Note: • Latest base firmware is recommended. • Strong integrity by default • If you face any bugs, report with logs. • Initial NTcamera and dolby support available 🏆 Credits: - Hellboy for kernel - Fabian and Hellboy for Glyph Implementation 👤 Maintainer : @Ghosutox 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #672 · 15.09.2025 г., 14:41

LunarisAOSP - Official | A16 | Nothing Phone 2 (Pong) ✍️ Details: - Version: 3.2 - Codename: #Pong - Updated : 15/09/'25 🔽 Download: Here | Mirror 🆘 Support : Here ⚙️ Installation: Here 📖 Changelogs: Here 📸 Screenshots:Here 💰 Donation: steinsgate007@axl | BMC 🔖 Tags : #ROM#AOSP#lunaris ✍️ Note: • Latest base firmware is recommended. • If you face any bugs, report with logs. • Initial NTcamera and dolby support available 🏆 Credits: - Hellboy for kernel - Fabian and Hellboy for Glyph Implementation 👤 Maintainer : @Ghosutox 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #661 · 16.08.2025 г., 12:42

LunarisAOSP - Official | A16 | Nothing Phone 2 (Pong) ✍️ Details: - Version: 3.2 - Codename: #Pong - Updated : 16/08/'25 🔽 Download: Here | Mirror 🆘 Support : Here ⚙️ Installation: Here 📖 Changelogs: Here 📸 Screenshots:Here 💰 Donation: steinsgate007@axl | BMC 🔖 Tags : #ROM#AOSP#lunaris ✍️ Note: • Latest base firmware is recommended. • If you face any bugs, report with logs. • NTcamera and dolby support available 👤 Maintainer : @Ghosutox 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #655 · 27.07.2025 г., 16:03

LunarisAOSP | A16 | Nothing Phone 2 (Pong) Updated : 27/07/'25 ✍️ Details: - Version: Official - Codename: #Pong 🔽 Download: Here | Mirror 🆘 Support : Here ⚙️ Installation: Here 📖 Changelogs: Here 📸 Screenshots:Here 🔖 Tags : #ROM#AOSP#lunaris 📚 Changelogs - 15-08 - Add Simulated Nothing Charging service - FlipToGlyph: Vibrate instad of silent - Enable AIDL fastboot HAL - Sync props from stock ✍️ Note: - Kernel is prepatched KSU - Dirty/ota flash possible from previous build - Latest base firmware recommended - Update inbuilt pif and import keybox xml for integrity 😎 Maintainer : @Ghosutox 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #647 · 03.07.2025 г., 04:48

LunarisAOSP | A16 | Nothing Phone 2 (Pong) Updated : 03/07/'25 ✍️ Details: - Version: Official - Codename: #Pong 🔽 Download: Here | Mirror 🆘 Support : Here ⚙️ Installation: Here 📸Screenshots:Here 🔖 Tags : #ROM#AOSP#lunaris 📑Changelogs - 16/07/25 - Use expressive design for Singularuty icons - Add QuickTap service - Tune QS round tile - Fix cloned profile issues - Fix Keyguard slice - Screenrecord: Add delete action to the notification - Update PIF - Fix bluetooth time out ✍️ Note: 16/07/25 - Kernel is prepatched KSU - Dirty/ota flash possible from previous build - Base firmware 3.0 is recommended - Update inbuilt pif and import keybox xml for integrity 😎 Maintainer : @Ghosutox 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Xiaomi 12T Pro | K50U | Updates

@xiaomi_12tpro_updates · Post #453 · 17.10.2025 г., 21:33

#Lunaris#AOSP#UNOFFICIAL#A16#BKA#Diting Lunaris-AOSP UNOFFICIAL V3.4 | A16 Released: 17/10/2025 Download : SF | Mirror Screenshots : Here Changelog : Here Support:Group Changelogs: • Initial build • Hyper Camera by default • Dolby Audio by default • Support KernelSU Notes: If you want to receive regular updates, you can donate and we will add you to VIP support. Credits:Here By@Jezzay97 | Donate Follow@xiaomi_12tpro_updates Join@xiaomi12tpro_chat