Skip to content

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

Description

@jkowalleck

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)

# 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"')
# file: models/bom.py

from .._opt.serialization import Serializer

class Bom(Serializer):
  ...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions