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

Резултати

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

Пребарај: #us30

当前筛选 #us30清除筛选
NAS100 PRO SIGNALS

@free_nasdaqsignals_team · Post #44839 · 15.03.2026 г., 00:00

⭐️#US30: Bulls Will Push Higher It is essential that we apply multitimeframe technical analysis and there is no better example of why that is the case than the current 📈US30 chart which, if analyzed properly, clearly points in the upward direction.

Hashtags

🔅US30 Will Fall! Sell!📉 - - - - - - - - Here is our detailed technical review for 📊US30. The market is approaching a significant resistance area 49,454.8. Due to the fact that we see a positive bearish reaction from the underlined area, I strongly believe that sellers will manage to push the price all the way down to 47,742.6 level. - - - - - - - - #freesignal#us30 - - - - - - - - 🌐Free Copy Trading: Link 📲Join VIP via Bot:Link ❓Official Contact:@signalprovidercontact

🔅US30 Is Bullish! Buy!📈 - - - - - - - Here is our detailed technical review for 📊US30. The market is testing a major horizontal structure 45,691.7. Taking into consideration the structure & trend analysis, I believe that the market will reach 46,550.5 level soon. - - - - - - - - #freesignal#us30 - - - - - - - - 🌐Free Copy Trading: Link 📲Join VIP via Bot:Link ❓Official Contact:@signalprovidercontact

🔅US30 Will Grow! Long!📈 - - - - - - - Here is our detailed technical review for 📊US30. The market is trading around a solid horizontal structure 48,884.2. The above observations make me that the market will inevitably achieve 49,692.2 level. - - - - - - - - #freesignal#us30 - - - - - - - - 🌐Free Copy Trading: Link 📲Join VIP via Bot:Link ❓Official Contact:@signalprovidercontact

🔅US30 Is Very Bearish! Short!📉 - - - - - - - - Here is our detailed technical review for 📊US30. The market is trading around a solid horizontal structure 50,088.7. The above observations make me that the market will inevitably achieve 49,623.5 level. - - - - - - - - #freesignal#us30 - - - - - - - - 🌐Free Copy Trading: Link 📲Join VIP via Bot:Link ❓Official Contact:@signalprovidercontact

🔅US30 Will Move Lower! Sell!📉 - - - - - - - - Take a look at our analysis for 📊US30. The market is approaching a significant resistance area 49,481.0. Due to the fact that we see a positive bearish reaction from the underlined area, I strongly believe that sellers will manage to push the price all the way down to 49,076.8 level. - - - - - - - - #freesignal#us30 - - - - - - - - 🌐Free Copy Trading: Link 📲Join VIP via Bot:Link ❓Official Contact:@signalprovidercontact

🔅US30 Is Bearish! Sell!📉 - - - - - - - - Here is our detailed technical review for 📊US30. The market is on a crucial zone of supply 49,331.6. The above-mentioned technicals clearly indicate the dominance of sellers on the market. I recommend shorting the instrument, aiming at 48,745.5 level. - - - - - - - - #freesignal#us30 - - - - - - - - 🌐Free Copy Trading: Link 📲Join VIP via Bot:Link ❓Official Contact:@signalprovidercontact

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