CycloneDX / CycloneDX/cyclonedx-python-lib

feat(deps)!: make all de/serialization libraries optional

Đang mở
#979 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
breaking change dependencies
Ngôn ngữ chính
Python
Star
116
Fork
67
Merge trung bình
8 ngày 2 giờ
Pull request đã merge (30 ngày)
2

Mô tả

when using this library for validation, i dont need to have the de/serialization dependencies installed.

## goal
make all de/serialization libraries optional

## solution
- make de/serialization dependnecies optional, and installable in an extra called "de/serialization" orsomething
- have a private module that tries to load optional de/serialization libs, and if this fails, then provide stubs.
- runtime shall not use any de/serialization dependencies directly, but use the own optionally loaded ones (see above)

## possible implementation (pseudo)

```py
# file: _opt/serialization.py

__all__ = ['Serializer']

try:
from serializaers import Serializer
except:
# stubs
class Serializer:
def to_json() -> Never:
raise Error('missing serializer, install optional dependnecy "serializaers"')
def from_json() -> Never:
raise Error('missing serializer, install optional dependnecy "serializaers"')
```

```py
# file: models/bom.py

from .._opt.serialization import Serializer

class Bom(Serializer):
...

```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.