@coinlegs · Post #10031 · 29.02.2024 г., 20:43
#WAVES🧐
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
Пребарај: #waves
@coinlegs · Post #10031 · 29.02.2024 г., 20:43
#WAVES🧐
Hashtags
@michaelvandepoppeanalyst · Post #4232 · 19.07.2024 г., 09:24
#WAVES Close 1/4 Position✅ Profit: +172% 🚀🚀🚀🚀
Hashtags
@michaelvandepoppeanalyst · Post #3379 · 04.05.2024 г., 12:41
#WAVES Close 1/4 Position✅ Profit: +156% 🚀🚀🚀🚀
Hashtags
@sublimetraders · Post #2135 · 10.12.2023 г., 00:41
Binance Futures, ByBit USDT, KuCoin Futures, OKX Futures #WAVES/USDT Take-Profit target 2 ✅ Profit: 11.7373% 📈 Period: 1 Days 12 Hours 10 Minutes ⏰
Hashtags
@sublimetraders · Post #2130 · 08.12.2023 г., 23:25
Binance Futures, ByBit USDT, KuCoin Futures, OKX Futures #WAVES/USDT Take-Profit target 1 ✅ Profit: 6.6949% 📈 Period: 10 Hours 44 Minutes ⏰
Hashtags
@sublimetraders · Post #2072 · 05.11.2023 г., 10:38
Binance Futures, ByBit USDT, KuCoin Futures, OKX Futures #WAVES/USDT All take-profit targets achieved 😎 Profit: 20.5036% 📈 Period: 6 Days 1 Hours 17 Minutes ⏰
Hashtags
@sublimetraders · Post #2071 · 05.11.2023 г., 10:24
Binance Futures, ByBit USDT, KuCoin Futures, OKX Futures #WAVES/USDT Take-Profit target 4 ✅ Profit: 15.5848% 📈 Period: 6 Days 1 Hours 3 Minutes ⏰
Hashtags
@sublimetraders · Post #2067 · 05.11.2023 г., 00:42
Binance Futures, ByBit USDT, KuCoin Futures, OKX Futures #WAVES/USDT Take-Profit target 3 ✅ Profit: 11.565% 📈 Period: 5 Days 15 Hours 21 Minutes ⏰
Hashtags
@sublimetraders · Post #2066 · 05.11.2023 г., 00:30
Binance Futures, ByBit USDT, KuCoin Futures, OKX Futures #WAVES/USDT Take-Profit target 2 ✅ Profit: 8.282% 📈 Period: 5 Days 15 Hours 9 Minutes ⏰
Hashtags
@sublimetraders · Post #2057 · 01.11.2023 г., 21:03
Binance Futures, ByBit USDT, KuCoin Futures, OKX Futures #WAVES/USDT Take-Profit target 1 ✅ Profit: 5.7079% 📈 Period: 2 Days 11 Hours 43 Minutes ⏰
Hashtags
@signal_bitcoins · Post #1883 · 17.12.2023 г., 07:38
💰#WAVES is trying to break up the triangle pattern on Weekly Time frame,in the case of breakout we will have another good pump💎 ❄️@signals_bitcoin_crypto❄️ ❄️@Shadow_support0o❄️
Hashtags
@signal_bitcoins · Post #1468 · 09.09.2023 г., 21:00
💰#WAVES is moving in a descending triangle. It bounced from the horizontal support with a decent volume. Currently, it is facing the MA 50 resistance. MACD crossover is losing bearish momentum and seems like it is going to turn bullish. A solid breakout of the descending triangle would be the bullish confirmation.💎 ❄️@signals_bitcoin_crypto❄️ ❄️@Shadow_support0o❄️
Hashtags