Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass settings to the jinja template. #303

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions solara/minisettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def __get__(self, instance, owner):
return self
return instance._values[self.name]

def __set__(self, instance, value):
instance._values[self.name] = value


def convert(annotation, value: str) -> Any:
check_optional_types = [str, int, float, bool, Path]
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/settings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,10 @@ def test_settings():
assert settings.value_no_field_other == 50
assert settings.path == Path("/tmp/test")
assert settings.path_optional == Path("/tmp/test/optional")


def test_dict():
settings = MySettings()
test_value = "some-other-value"
settings.value = test_value
assert settings.dict()["value"] == test_value
Loading