CycloneDX / CycloneDX/cyclonedx-python-lib

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

Offen
#979 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
breaking change dependencies
Vorherrschende Sprache
Python
Sterne
116
Forks
67
Ø Merge
8 T. 2 Std.
Gemergte PRs (30 T.)
2

Beschreibung

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):
...

```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start by checking the dependency declarations and the runtime serialization imports, then compare the proposed _opt/serialization.py and models/bom.py entry points. Verify that validation-only usage works without serialization dependencies, while serialization reports the missing optional dependency clearly; test both installed and absent-dependency cases.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
backend
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.