Skip to main content

Classic Components

Предоставляет утилиты для удобного описания классов.

Главное, что предоставляет пакет - это декоратор component для обертывания классов. Класс, обернутый таким декоратором, называется далее компонентом, и обладает рядом свойств:

  • автоматически сгенерированный конструктор на базе аннотаций (dataclass).
  • добавляет "дополнительные аннотации" к аннотациям класса (подробности далее)
  • добавляет автоматическую регистрацию инстансов в указанных реестрах

Простой пример:

from classic.components import component


@component
class SomeService:
    prop: int
    
    def action(self):
        print(self.prop)


service = SomeService(prop=1)
service.action()  # prints 1

Генерацию конструктора можно отключить:

from classic.components import component


@component(init=False)
class SomeService:
    prop: int
    
    def action(self):
        print(self.prop)


service = SomeService(prop=1)  # TypeError: SomeService() takes no arguments

Реестры

Также пакет предоставляет интерфейс для создания реестров и базовую реализацию реестра со слабыми ссылками. Это нужно не столько для кода приложений, сколько для других библиотек в платформе.

from classic.components import component, Registry, WeakSetRegistry


@component(init=False)
class SomeService:
    registry: Registry
    
    def action(self):
        print(self.prop)


registry = WeakSetRegistry()
service = SomeService(registry=registry)

print(registry.storage)
# {<weakref at 0x109390fe0; to 'SomeService' at 0x10933ec50>}

Алиасы для dataclasses.field

Также есть алиасы для часто используемых параметров field из dataclasses:

from dataclasses import field
from classic.components import component, no_init, factory, default


@component
class SomeLogic:
    some_list: field(default_factory=list)
    analog: factory(list)  # то же самое
    
    some_str: str = field(default='Hello')
    analog_str: str = default('Hello')

    _some_field: int = field(default=0, init=False)
    _analog: int = no_init(0)  # то же самое

Metadata

Release files for classic-components 1.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for classic-components 1.3.2
File Size Uploaded Provenance
classic_components-1.3.2.tar.gz 9.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for classic-components 1.3.2
File Interpreter ABI Platform
classic_components-1.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 19.0 kB

Release files / classic_components-1.3.2.tar.gz

Download URL classic_components-1.3.2.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0e97d3c28fa6584cc4c5f0bd5ef3a534c96673a2daa120ed8d98eb0e06e190d9
BLAKE2b-256 checksum
How to use checksums
d75906b546c6355e35dfae1ce90432c490e8aa171c07056e770a0e8e622143b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2025.

Transparency log

Release files / classic_components-1.3.2-py3-none-any.whl

Download URL classic_components-1.3.2-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f18aecad07603a97bfa123baba18a45857e076fad5cfa73664dcecfeeed13cd
BLAKE2b-256 checksum
How to use checksums
8041f7025c9ce728ac6037c1ab8f9dbd81351cff6c695264b962096dc7752927
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2025.

Transparency log

Security for classic-components 1.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for classic_components-1.3.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page