@davidstocknew · Post #50755 · 28.04.2026 г., 07:52
[GIVE ME 컨콜☎️] OCI, 반도체용 과산화수소와 인산 증설이 의미 있을까? ➡️https://naver.me/5zUvdZ3J #OCI 🔗큐리어스IR 텔레그램 링크: https://t.me/curiousir
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
Пребарај: #oci
@davidstocknew · Post #50755 · 28.04.2026 г., 07:52
[GIVE ME 컨콜☎️] OCI, 반도체용 과산화수소와 인산 증설이 의미 있을까? ➡️https://naver.me/5zUvdZ3J #OCI 🔗큐리어스IR 텔레그램 링크: https://t.me/curiousir
Hashtags
@githubtrending · Post #15595 · 01.04.2026 г., 11:30
#go#distribution_spec#helm#kubernetes#oci#oci_distribution#opencontainers#zot Zot is a lightweight, production-ready OCI-native container registry for storing images, Helm charts, SBOMs, and other artifacts without vendor lock-in. It offers built-in authentication (OIDC, LDAP), storage options (S3, Azure), scanning, caching to cut Docker Hub limits/latency, and ARM/edge support as a single binary. You benefit by easily self-hosting a secure, scalable alternative to Docker Hub, saving costs, boosting speed, and enabling secret-less workflows on any device. https://github.com/project-zot/zot
@githubtrending · Post #14660 · 01.05.2025 г., 16:00
#go#containers#cyclonedx#docker#go#golang#hacktoberfest#oci#sbom#spdx#static_analysis#tool Syft is a tool that helps create a list of all the software components used in your applications, known as a Software Bill of Materials (SBOM). This list is important for finding vulnerabilities and ensuring that your software complies with licensing rules. By using Syft, you can better manage your software's security and compliance. It works with many types of software and can be used with other tools like Grype to check for vulnerabilities. This helps keep your software safe and up-to-date. https://github.com/anchore/syft