mirror of
https://github.com/rio-labs/rio.git
synced 2026-05-04 18:09:26 -05:00
added check to ensure default attachments are instances
This commit is contained in:
@@ -262,6 +262,14 @@ class App:
|
||||
if theme is None:
|
||||
theme = rio.Theme.from_colors()
|
||||
|
||||
# A common mistake is to pass types instead of instances to
|
||||
# `default_attachments`. Catch that, scream and die.
|
||||
for attachment in default_attachments:
|
||||
if isinstance(attachment, type):
|
||||
raise TypeError(
|
||||
f"Default attachments should be instances, not types. Did you mean to type `{attachment.__name__}()`?"
|
||||
)
|
||||
|
||||
# The `main_file` isn't detected correctly if the app is launched via
|
||||
# `rio run`. We'll store the user input so that `rio run` can fix the
|
||||
# assets dir.
|
||||
|
||||
@@ -104,9 +104,8 @@ class UserSettings(metaclass=RioDataclassMeta):
|
||||
settings_json: uniserde.JsonDoc,
|
||||
defaults: Self,
|
||||
) -> Self:
|
||||
# Create the instance for this attachment. Bypass the constructor so
|
||||
# the instance doesn't immediately try to synchronize with the
|
||||
# frontend.
|
||||
# Create the instance for this attachment. Bypass the constructor so the
|
||||
# instance doesn't immediately try to synchronize with the frontend.
|
||||
self = object.__new__(cls)
|
||||
settings_vars = vars(self)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user