Skip to content

Instantly share code, notes, and snippets.

@naturalwarren
Last active April 8, 2023 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naturalwarren/3a7b3d717dd445efe8d4f2a1035e3211 to your computer and use it in GitHub Desktop.
Save naturalwarren/3a7b3d717dd445efe8d4f2a1035e3211 to your computer and use it in GitHub Desktop.
SDUI Base Component Compatibility
class UIComponent(BaseModel, ABC):
# ...
def __init__(self, **data) -> None:
# SDUIContext is set as a context var when handling any request on the backend
current_context = SDUIContext.current()
if current_context is not None:
# Will raise an error if incompatible
current_context.validate_compatibility(
self.platform_compatibility()
)
else:
raise MissingContextError(...)
# ...
@classmethod
@abstractmethod
def platform_compatibility(cls) -> Dict[Platform, Version]:
pass
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment