streambricks 1.0.0__tar.gz → 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. streambricks-1.1.0/PKG-INFO +207 -0
  2. streambricks-1.1.0/README.md +169 -0
  3. streambricks-1.1.0/pyproject.toml +292 -0
  4. streambricks-1.0.0/pyproject.toml → streambricks-1.1.0/pyproject.toml.orig +75 -21
  5. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/auth/decorator.py +1 -1
  6. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/auth/profile_widget.py +1 -3
  7. streambricks-1.1.0/src/streambricks/log.py +25 -0
  8. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/state.py +3 -5
  9. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/widgets/bind_kwargs.py +4 -5
  10. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/widgets/model_widget/main.py +31 -29
  11. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/widgets/model_widget/type_renderers.py +1 -3
  12. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/widgets/type_helpers.py +3 -8
  13. streambricks-1.0.0/PKG-INFO +0 -79
  14. streambricks-1.0.0/README.md +0 -26
  15. {streambricks-1.0.0 → streambricks-1.1.0}/LICENSE +0 -0
  16. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/__init__.py +0 -0
  17. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/auth/__init__.py +0 -0
  18. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/auth/helpers.py +0 -0
  19. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/auth/models.py +0 -0
  20. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/helpers.py +0 -0
  21. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/py.typed +0 -0
  22. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/sidebar.py +0 -0
  23. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/widgets/__init__.py +0 -0
  24. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/widgets/image_capture.py +0 -0
  25. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/widgets/model_selector.py +0 -0
  26. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/widgets/model_widget/__init__.py +0 -0
  27. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/widgets/model_widget/field_metadata_renderers.py +0 -0
  28. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/widgets/multi_select.py +0 -0
  29. {streambricks-1.0.0 → streambricks-1.1.0}/src/streambricks/widgets/sequence.py +0 -0
@@ -0,0 +1,207 @@
1
+ Metadata-Version: 2.4
2
+ Name: streambricks
3
+ Version: 1.1.0
4
+ Summary: Streamlit widgets and helpers: auto-generated forms for Pydantic models, typed session state and login helpers
5
+ Keywords: authentication,components,dataclasses,forms,pydantic,session-state,streamlit,ui,widgets
6
+ Author: Philipp Temminghoff
7
+ Author-email: Philipp Temminghoff <philipptemminghoff@googlemail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Framework :: Pydantic :: 2
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Topic :: Software Development
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Topic :: Software Development :: User Interfaces
21
+ Classifier: Topic :: Utilities
22
+ Classifier: Typing :: Typed
23
+ Requires-Dist: fieldz>=0.1.0
24
+ Requires-Dist: pillow>=10.0
25
+ Requires-Dist: pydantic>=2.0
26
+ Requires-Dist: streamlit>=1.43.2
27
+ Requires-Dist: authlib ; extra == 'auth'
28
+ Requires-Dist: tokonomics>=1.0.0 ; extra == 'llm'
29
+ Requires-Python: >=3.13
30
+ Project-URL: Code coverage, https://app.codecov.io/gh/phil65/streambricks
31
+ Project-URL: Documentation, https://phil65.github.io/streambricks/
32
+ Project-URL: Homepage, https://phil65.github.io/streambricks/
33
+ Project-URL: Issues, https://github.com/phil65/streambricks/issues
34
+ Project-URL: Source, https://github.com/phil65/streambricks
35
+ Provides-Extra: auth
36
+ Provides-Extra: llm
37
+ Description-Content-Type: text/markdown
38
+
39
+ # StreamBricks
40
+
41
+ [![PyPI License](https://img.shields.io/pypi/l/streambricks.svg)](https://pypi.org/project/streambricks/)
42
+ [![Package status](https://img.shields.io/pypi/status/streambricks.svg)](https://pypi.org/project/streambricks/)
43
+ [![Monthly downloads](https://img.shields.io/pypi/dm/streambricks.svg)](https://pypi.org/project/streambricks/)
44
+ [![Distribution format](https://img.shields.io/pypi/format/streambricks.svg)](https://pypi.org/project/streambricks/)
45
+ [![Wheel availability](https://img.shields.io/pypi/wheel/streambricks.svg)](https://pypi.org/project/streambricks/)
46
+ [![Python version](https://img.shields.io/pypi/pyversions/streambricks.svg)](https://pypi.org/project/streambricks/)
47
+ [![Implementation](https://img.shields.io/pypi/implementation/streambricks.svg)](https://pypi.org/project/streambricks/)
48
+ [![Releases](https://img.shields.io/github/downloads/phil65/streambricks/total.svg)](https://github.com/phil65/streambricks/releases)
49
+ [![Github Contributors](https://img.shields.io/github/contributors/phil65/streambricks)](https://github.com/phil65/streambricks/graphs/contributors)
50
+ [![Github Forks](https://img.shields.io/github/forks/phil65/streambricks)](https://github.com/phil65/streambricks/forks)
51
+ [![Github Issues](https://img.shields.io/github/issues/phil65/streambricks)](https://github.com/phil65/streambricks/issues)
52
+ [![Github Issues](https://img.shields.io/github/issues-pr/phil65/streambricks)](https://github.com/phil65/streambricks/pulls)
53
+ [![Github Watchers](https://img.shields.io/github/watchers/phil65/streambricks)](https://github.com/phil65/streambricks/watchers)
54
+ [![Github Stars](https://img.shields.io/github/stars/phil65/streambricks)](https://github.com/phil65/streambricks/stars)
55
+ [![Github Repository size](https://img.shields.io/github/repo-size/phil65/streambricks)](https://github.com/phil65/streambricks)
56
+ [![Github last commit](https://img.shields.io/github/last-commit/phil65/streambricks)](https://github.com/phil65/streambricks/commits)
57
+ [![Github release date](https://img.shields.io/github/release-date/phil65/streambricks)](https://github.com/phil65/streambricks/releases)
58
+ [![Github language count](https://img.shields.io/github/languages/count/phil65/streambricks)](https://github.com/phil65/streambricks)
59
+ [![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/streambricks)](https://github.com/phil65/streambricks)
60
+ [![Package status](https://codecov.io/gh/phil65/streambricks/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/streambricks/)
61
+ [![PyUp](https://pyup.io/repos/github/phil65/streambricks/shield.svg)](https://pyup.io/repos/github/phil65/streambricks/)
62
+
63
+ [Read the documentation!](https://phil65.github.io/streambricks/)
64
+
65
+ Reusable widgets and helpers for [Streamlit](https://streamlit.io/) apps. The core
66
+ feature is automatic form generation: pass a Pydantic model (or a dataclass or another
67
+ [fieldz](https://github.com/pyapp-kit/fieldz)-supported class) and get an editable or
68
+ read-only form back, including nested models, unions, enums, literals, lists and sets.
69
+
70
+ ## Installation
71
+
72
+ ```bash
73
+ pip install streambricks
74
+ # optional extras
75
+ pip install "streambricks[auth]" # Google / Microsoft login via st.login
76
+ pip install "streambricks[llm]" # LLM model selector (tokonomics)
77
+ ```
78
+
79
+ ## Quickstart
80
+
81
+ ```python
82
+ from typing import Literal
83
+
84
+ from pydantic import BaseModel, Field
85
+ import streamlit as st
86
+
87
+ import streambricks as sb
88
+
89
+
90
+ class Settings(BaseModel):
91
+ name: str = Field(default="World", description="Who to greet")
92
+ retries: int = Field(default=3, ge=0, le=10)
93
+ mode: Literal["fast", "safe"] = "fast"
94
+ tags: list[str] = Field(default_factory=list)
95
+
96
+
97
+ def main():
98
+ settings = sb.model_edit(Settings) # returns an updated Settings instance
99
+ st.write(f"Hello, {settings.name}!")
100
+ sb.model_display(Settings, settings) # read-only view
101
+
102
+
103
+ sb.run(main)
104
+ ```
105
+
106
+ Run it with `streamlit run app.py`, or with `python app.py`: `sb.run` starts
107
+ Streamlit for you when called outside of it.
108
+
109
+ ## Features
110
+
111
+ ### Model forms
112
+
113
+ - `model_edit(model_or_instance, *, readonly=False, exclude=None)`: render a form for a
114
+ class (defaults are used) or an instance, return the edited instance.
115
+ - `model_display(model_class, instance)`: read-only rendering.
116
+ - Field descriptions (`Field(description=...)`, or attribute docstrings with
117
+ `ConfigDict(use_attribute_docstrings=True)`) become help texts;
118
+ fields with `json_schema_extra={"category": ...}` are grouped into tabs.
119
+
120
+ ### Typed session state
121
+
122
+ ```python
123
+ # app_state.py
124
+ import streambricks as sb
125
+
126
+
127
+ class AppState(sb.State):
128
+ counter: int = 0
129
+ ```
130
+
131
+ ```python
132
+ # app.py
133
+ import streamlit as st
134
+
135
+ from app_state import AppState
136
+
137
+ state = AppState.get() # stored in st.session_state, survives reruns
138
+ if st.button("Increment"):
139
+ state.counter += 1
140
+ st.write(state.counter)
141
+ state.form() # edit the state with a generated form
142
+ ```
143
+
144
+ `State` subclasses also provide `set_state(value=...)` and `reset()`. Define them in a
145
+ separate module: classes defined in the main script are recreated on every rerun, which
146
+ resets the stored state.
147
+
148
+ ### Function kwargs as widgets
149
+
150
+ ```python
151
+ import streamlit as st
152
+ import streambricks as sb
153
+
154
+
155
+ def plot(title: str, points: int = 10, smooth: bool = False) -> str:
156
+ return f"{title}: {points} points, smooth={smooth}"
157
+
158
+
159
+ configured = sb.bind_kwargs_as_widget(
160
+ plot, kwargs_to_bind=["points", "smooth"], title="Plot options"
161
+ )
162
+ st.write(configured("My plot"))
163
+ ```
164
+
165
+ ### Other widgets
166
+
167
+ ```python
168
+ import streambricks as sb
169
+
170
+ items = [
171
+ sb.MultiSelectItem("Apple", "apple", description="Red fruit"),
172
+ sb.MultiSelectItem("Banana", "banana"),
173
+ ]
174
+ selected = sb.multiselect("Fruits", items, state_key="fruits") # list[MultiSelectItem]
175
+
176
+ image = sb.image_capture() # file upload or camera, returns UploadedFile | None
177
+
178
+ model = sb.model_selector(providers=["openai"]) # needs the "llm" extra
179
+
180
+ sb.set_sidebar_width(400)
181
+ sb.hide_sidebar()
182
+ ```
183
+
184
+ ### Authentication
185
+
186
+ Thin, typed wrappers around Streamlit's built-in authentication (`st.login`, configured
187
+ in `.streamlit/secrets.toml`; requires the `auth` extra):
188
+
189
+ ```python
190
+ import streamlit as st
191
+ import streambricks as sb
192
+
193
+ user = sb.google_login("Login with Google") # GoogleUser | None
194
+ # user = sb.microsoft_login() # MicrosoftUser | None
195
+ if user:
196
+ sb.profile_widget(user, size="medium")
197
+
198
+
199
+ @sb.requires_login(unauthorized_handler="Please log in first")
200
+ def dashboard():
201
+ st.write("Protected content")
202
+
203
+
204
+ dashboard()
205
+ ```
206
+
207
+ `get_current_user()` returns the logged-in user (or `None`) without rendering anything.
@@ -0,0 +1,169 @@
1
+ # StreamBricks
2
+
3
+ [![PyPI License](https://img.shields.io/pypi/l/streambricks.svg)](https://pypi.org/project/streambricks/)
4
+ [![Package status](https://img.shields.io/pypi/status/streambricks.svg)](https://pypi.org/project/streambricks/)
5
+ [![Monthly downloads](https://img.shields.io/pypi/dm/streambricks.svg)](https://pypi.org/project/streambricks/)
6
+ [![Distribution format](https://img.shields.io/pypi/format/streambricks.svg)](https://pypi.org/project/streambricks/)
7
+ [![Wheel availability](https://img.shields.io/pypi/wheel/streambricks.svg)](https://pypi.org/project/streambricks/)
8
+ [![Python version](https://img.shields.io/pypi/pyversions/streambricks.svg)](https://pypi.org/project/streambricks/)
9
+ [![Implementation](https://img.shields.io/pypi/implementation/streambricks.svg)](https://pypi.org/project/streambricks/)
10
+ [![Releases](https://img.shields.io/github/downloads/phil65/streambricks/total.svg)](https://github.com/phil65/streambricks/releases)
11
+ [![Github Contributors](https://img.shields.io/github/contributors/phil65/streambricks)](https://github.com/phil65/streambricks/graphs/contributors)
12
+ [![Github Forks](https://img.shields.io/github/forks/phil65/streambricks)](https://github.com/phil65/streambricks/forks)
13
+ [![Github Issues](https://img.shields.io/github/issues/phil65/streambricks)](https://github.com/phil65/streambricks/issues)
14
+ [![Github Issues](https://img.shields.io/github/issues-pr/phil65/streambricks)](https://github.com/phil65/streambricks/pulls)
15
+ [![Github Watchers](https://img.shields.io/github/watchers/phil65/streambricks)](https://github.com/phil65/streambricks/watchers)
16
+ [![Github Stars](https://img.shields.io/github/stars/phil65/streambricks)](https://github.com/phil65/streambricks/stars)
17
+ [![Github Repository size](https://img.shields.io/github/repo-size/phil65/streambricks)](https://github.com/phil65/streambricks)
18
+ [![Github last commit](https://img.shields.io/github/last-commit/phil65/streambricks)](https://github.com/phil65/streambricks/commits)
19
+ [![Github release date](https://img.shields.io/github/release-date/phil65/streambricks)](https://github.com/phil65/streambricks/releases)
20
+ [![Github language count](https://img.shields.io/github/languages/count/phil65/streambricks)](https://github.com/phil65/streambricks)
21
+ [![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/streambricks)](https://github.com/phil65/streambricks)
22
+ [![Package status](https://codecov.io/gh/phil65/streambricks/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/streambricks/)
23
+ [![PyUp](https://pyup.io/repos/github/phil65/streambricks/shield.svg)](https://pyup.io/repos/github/phil65/streambricks/)
24
+
25
+ [Read the documentation!](https://phil65.github.io/streambricks/)
26
+
27
+ Reusable widgets and helpers for [Streamlit](https://streamlit.io/) apps. The core
28
+ feature is automatic form generation: pass a Pydantic model (or a dataclass or another
29
+ [fieldz](https://github.com/pyapp-kit/fieldz)-supported class) and get an editable or
30
+ read-only form back, including nested models, unions, enums, literals, lists and sets.
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install streambricks
36
+ # optional extras
37
+ pip install "streambricks[auth]" # Google / Microsoft login via st.login
38
+ pip install "streambricks[llm]" # LLM model selector (tokonomics)
39
+ ```
40
+
41
+ ## Quickstart
42
+
43
+ ```python
44
+ from typing import Literal
45
+
46
+ from pydantic import BaseModel, Field
47
+ import streamlit as st
48
+
49
+ import streambricks as sb
50
+
51
+
52
+ class Settings(BaseModel):
53
+ name: str = Field(default="World", description="Who to greet")
54
+ retries: int = Field(default=3, ge=0, le=10)
55
+ mode: Literal["fast", "safe"] = "fast"
56
+ tags: list[str] = Field(default_factory=list)
57
+
58
+
59
+ def main():
60
+ settings = sb.model_edit(Settings) # returns an updated Settings instance
61
+ st.write(f"Hello, {settings.name}!")
62
+ sb.model_display(Settings, settings) # read-only view
63
+
64
+
65
+ sb.run(main)
66
+ ```
67
+
68
+ Run it with `streamlit run app.py`, or with `python app.py`: `sb.run` starts
69
+ Streamlit for you when called outside of it.
70
+
71
+ ## Features
72
+
73
+ ### Model forms
74
+
75
+ - `model_edit(model_or_instance, *, readonly=False, exclude=None)`: render a form for a
76
+ class (defaults are used) or an instance, return the edited instance.
77
+ - `model_display(model_class, instance)`: read-only rendering.
78
+ - Field descriptions (`Field(description=...)`, or attribute docstrings with
79
+ `ConfigDict(use_attribute_docstrings=True)`) become help texts;
80
+ fields with `json_schema_extra={"category": ...}` are grouped into tabs.
81
+
82
+ ### Typed session state
83
+
84
+ ```python
85
+ # app_state.py
86
+ import streambricks as sb
87
+
88
+
89
+ class AppState(sb.State):
90
+ counter: int = 0
91
+ ```
92
+
93
+ ```python
94
+ # app.py
95
+ import streamlit as st
96
+
97
+ from app_state import AppState
98
+
99
+ state = AppState.get() # stored in st.session_state, survives reruns
100
+ if st.button("Increment"):
101
+ state.counter += 1
102
+ st.write(state.counter)
103
+ state.form() # edit the state with a generated form
104
+ ```
105
+
106
+ `State` subclasses also provide `set_state(value=...)` and `reset()`. Define them in a
107
+ separate module: classes defined in the main script are recreated on every rerun, which
108
+ resets the stored state.
109
+
110
+ ### Function kwargs as widgets
111
+
112
+ ```python
113
+ import streamlit as st
114
+ import streambricks as sb
115
+
116
+
117
+ def plot(title: str, points: int = 10, smooth: bool = False) -> str:
118
+ return f"{title}: {points} points, smooth={smooth}"
119
+
120
+
121
+ configured = sb.bind_kwargs_as_widget(
122
+ plot, kwargs_to_bind=["points", "smooth"], title="Plot options"
123
+ )
124
+ st.write(configured("My plot"))
125
+ ```
126
+
127
+ ### Other widgets
128
+
129
+ ```python
130
+ import streambricks as sb
131
+
132
+ items = [
133
+ sb.MultiSelectItem("Apple", "apple", description="Red fruit"),
134
+ sb.MultiSelectItem("Banana", "banana"),
135
+ ]
136
+ selected = sb.multiselect("Fruits", items, state_key="fruits") # list[MultiSelectItem]
137
+
138
+ image = sb.image_capture() # file upload or camera, returns UploadedFile | None
139
+
140
+ model = sb.model_selector(providers=["openai"]) # needs the "llm" extra
141
+
142
+ sb.set_sidebar_width(400)
143
+ sb.hide_sidebar()
144
+ ```
145
+
146
+ ### Authentication
147
+
148
+ Thin, typed wrappers around Streamlit's built-in authentication (`st.login`, configured
149
+ in `.streamlit/secrets.toml`; requires the `auth` extra):
150
+
151
+ ```python
152
+ import streamlit as st
153
+ import streambricks as sb
154
+
155
+ user = sb.google_login("Login with Google") # GoogleUser | None
156
+ # user = sb.microsoft_login() # MicrosoftUser | None
157
+ if user:
158
+ sb.profile_widget(user, size="medium")
159
+
160
+
161
+ @sb.requires_login(unauthorized_handler="Please log in first")
162
+ def dashboard():
163
+ st.write("Protected content")
164
+
165
+
166
+ dashboard()
167
+ ```
168
+
169
+ `get_current_user()` returns the logged-in user (or `None`) without rendering anything.
@@ -0,0 +1,292 @@
1
+ [project]
2
+ name = "streambricks"
3
+ version = "1.1.0"
4
+ description = "Streamlit widgets and helpers: auto-generated forms for Pydantic models, typed session state and login helpers"
5
+ readme = "README.md"
6
+ requires-python = ">=3.13"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ keywords = [
10
+ "authentication",
11
+ "components",
12
+ "dataclasses",
13
+ "forms",
14
+ "pydantic",
15
+ "session-state",
16
+ "streamlit",
17
+ "ui",
18
+ "widgets",
19
+ ]
20
+ classifiers = [
21
+ "Development Status :: 4 - Beta",
22
+ "Framework :: Pydantic :: 2",
23
+ "Intended Audience :: Developers",
24
+ "Operating System :: OS Independent",
25
+ "Programming Language :: Python :: 3",
26
+ "Programming Language :: Python :: 3 :: Only",
27
+ "Programming Language :: Python :: 3.13",
28
+ "Programming Language :: Python :: 3.14",
29
+ "Topic :: Software Development",
30
+ "Topic :: Software Development :: Libraries :: Python Modules",
31
+ "Topic :: Software Development :: User Interfaces",
32
+ "Topic :: Utilities",
33
+ "Typing :: Typed",
34
+ ]
35
+ dependencies = [
36
+ "fieldz>=0.1.0",
37
+ "pillow>=10.0",
38
+ "pydantic>=2.0",
39
+ "streamlit>=1.43.2",
40
+ ]
41
+
42
+ [[project.authors]]
43
+ name = "Philipp Temminghoff"
44
+ email = "philipptemminghoff@googlemail.com"
45
+
46
+ [project.urls]
47
+ "Code coverage" = "https://app.codecov.io/gh/phil65/streambricks"
48
+ Documentation = "https://phil65.github.io/streambricks/"
49
+ Homepage = "https://phil65.github.io/streambricks/"
50
+ Issues = "https://github.com/phil65/streambricks/issues"
51
+ Source = "https://github.com/phil65/streambricks"
52
+
53
+ [project.optional-dependencies]
54
+ auth = ["authlib"]
55
+ llm = ["tokonomics>=1.0.0"]
56
+
57
+ [dependency-groups]
58
+ dev = [
59
+ "deptry",
60
+ "devtools",
61
+ "pyreadline3",
62
+ "pytest",
63
+ "pytest-cov",
64
+ ]
65
+ benchmark = ["pyinstrument"]
66
+ docs = [
67
+ "mkdocs-material",
68
+ "mkdocs-mknodes",
69
+ ]
70
+ lint = [
71
+ "ruff",
72
+ "ty",
73
+ ]
74
+
75
+ [build-system]
76
+ requires = ["uv_build>=0.8.22"]
77
+ build-backend = "uv_build"
78
+
79
+ [tool.coverage.report]
80
+ exclude_lines = [
81
+ "pragma: no cover",
82
+ "if TYPE_CHECKING:",
83
+ "@overload",
84
+ "except ImportError",
85
+ 'if __name__ == "__main__":',
86
+ ]
87
+
88
+ [tool.deptry.per_rule_ignores]
89
+ DEP002 = ["authlib"]
90
+
91
+ [tool.mknodes]
92
+ allowed-commit-types = [
93
+ "fix",
94
+ "feat",
95
+ "refactor",
96
+ "docs",
97
+ "test",
98
+ "build",
99
+ "chore",
100
+ ]
101
+ docstring-style = "google"
102
+
103
+ [tool.pyright]
104
+ venvPath = "."
105
+ venv = ".venv"
106
+ pythonVersion = "3.13"
107
+ pythonPlatform = "All"
108
+ typeCheckingMode = "basic"
109
+ deprecateTypingAliases = true
110
+ reportMissingTypeStubs = false
111
+ reportUnusedCallResult = false
112
+ reportUnknownVariableType = false
113
+ reportAny = false
114
+ reportImplicitOverride = false
115
+ reportUnusedFunction = false
116
+ reportImplicitStringConcatenation = false
117
+ reportIgnoreCommentWithoutRule = false
118
+ reportUnannotatedClassAttribute = false
119
+ reportSelfClsParameterName = false
120
+ reportPrivateImportUsage = false
121
+
122
+ [tool.pytest]
123
+ log_cli = true
124
+ log_date_format = "%Y-%m-%d %H:%M:%S"
125
+ log_format = "%(asctime)s %(levelname)s %(message)s"
126
+ minversion = "9.0"
127
+ testpaths = ["tests/"]
128
+ asyncio_mode = "auto"
129
+
130
+ [tool.ruff]
131
+ line-length = 100
132
+ extend-exclude = ["docs"]
133
+ target-version = "py313"
134
+
135
+ [tool.ruff.lint]
136
+ future-annotations = true
137
+ select = [
138
+ "A",
139
+ "B",
140
+ "BLE",
141
+ "C",
142
+ "C4",
143
+ "COM",
144
+ "D",
145
+ "E",
146
+ "EM",
147
+ "EXE",
148
+ "F",
149
+ "FA",
150
+ "FLY",
151
+ "G",
152
+ "I",
153
+ "ICN",
154
+ "INP",
155
+ "INT",
156
+ "ISC",
157
+ "N",
158
+ "PERF",
159
+ "PIE",
160
+ "PLE",
161
+ "PLC",
162
+ "PLR",
163
+ "PT",
164
+ "PTH",
165
+ "PYI",
166
+ "Q",
167
+ "RET",
168
+ "RSE",
169
+ "RUF",
170
+ "SIM",
171
+ "SLF",
172
+ "SLOT",
173
+ "T10",
174
+ "TC",
175
+ "TID",
176
+ "TRY",
177
+ "UP",
178
+ "W",
179
+ "YTT",
180
+ ]
181
+ ignore = [
182
+ "C408",
183
+ "B905",
184
+ "C901",
185
+ "COM812",
186
+ "D100",
187
+ "D101",
188
+ "D102",
189
+ "D103",
190
+ "D104",
191
+ "D105",
192
+ "D106",
193
+ "D107",
194
+ "D203",
195
+ "D204",
196
+ "D213",
197
+ "D215",
198
+ "D400",
199
+ "D401",
200
+ "D404",
201
+ "D406",
202
+ "D407",
203
+ "D408",
204
+ "D409",
205
+ "D413",
206
+ "EM101",
207
+ "EM102",
208
+ "ISC001",
209
+ "PLC0415",
210
+ "PLR0912",
211
+ "PLR0913",
212
+ "PLR0915",
213
+ "PLR0917",
214
+ "SLF001",
215
+ "TRY003",
216
+ "TC006",
217
+ ]
218
+
219
+ [tool.ruff.lint.flake8-quotes]
220
+ docstring-quotes = "double"
221
+
222
+ [tool.ruff.lint.flake8-type-checking]
223
+ runtime-evaluated-base-classes = [
224
+ "pydantic.BaseModel",
225
+ "sqlalchemy.orm.DeclarativeBase",
226
+ "schemez.Schema",
227
+ "sqlmodel.SQLModel",
228
+ ]
229
+ runtime-evaluated-decorators = [
230
+ "pydantic.validate_call",
231
+ "fastapi.FastAPI.get",
232
+ "fastapi.FastAPI.post",
233
+ "fastmcp.FastMCP.tool",
234
+ "typer.Typer.command",
235
+ ]
236
+
237
+ [tool.ruff.lint.isort]
238
+ lines-after-imports = 2
239
+ force-sort-within-sections = true
240
+ combine-as-imports = true
241
+
242
+ [tool.ruff.lint.mccabe]
243
+ max-complexity = 15
244
+
245
+ [tool.ruff.lint.per-file-ignores]
246
+ "__init__.py" = [
247
+ "E402",
248
+ "I001",
249
+ ]
250
+ "scripts/*" = ["INP001"]
251
+ "*tests/*" = ["D100"]
252
+
253
+ [tool.ruff.format]
254
+ preview = true
255
+
256
+ [tool.ty.environment]
257
+ python-version = "3.13"
258
+ python-platform = "all"
259
+
260
+ [tool.ty.src]
261
+ include = ["src"]
262
+
263
+ [tool.ty.analysis]
264
+ allowed-unresolved-imports = []
265
+
266
+ [tool.ty.rules]
267
+ incompatible-mutable-override = "ignore"
268
+
269
+ [tool.uv]
270
+ default-groups = [
271
+ "dev",
272
+ "lint",
273
+ "docs",
274
+ ]
275
+
276
+ [tool.uv.build-backend]
277
+ wheel-exclude = [
278
+ ".mypy_cache/**",
279
+ "__pycache__/**",
280
+ "*.pyc",
281
+ "*.pyo",
282
+ ".pytest_cache/**",
283
+ ".ruff_cache/**",
284
+ ]
285
+ source-exclude = [
286
+ ".mypy_cache/**",
287
+ "__pycache__/**",
288
+ "*.pyc",
289
+ "*.pyo",
290
+ ".pytest_cache/**",
291
+ ".ruff_cache/**",
292
+ ]
@@ -1,46 +1,64 @@
1
+ #:tombi schema.strict = false
2
+
1
3
  [project]
2
4
  name = "streambricks"
3
- version = "1.0.0"
4
- description = "Streamlit widgets and helpers"
5
+ version = "1.1.0"
6
+ description = "Streamlit widgets and helpers: auto-generated forms for Pydantic models, typed session state and login helpers"
5
7
  readme = "README.md"
6
8
  requires-python = ">=3.13"
7
- license = { file = "LICENSE" }
9
+ license = "MIT"
10
+ license-files = ["LICENSE"]
8
11
  authors = [
9
12
  { name = "Philipp Temminghoff", email = "philipptemminghoff@googlemail.com" },
10
13
  ]
11
- keywords = []
14
+ keywords = [
15
+ "authentication",
16
+ "components",
17
+ "dataclasses",
18
+ "forms",
19
+ "pydantic",
20
+ "session-state",
21
+ "streamlit",
22
+ "ui",
23
+ "widgets",
24
+ ]
12
25
  classifiers = [
13
26
  "Development Status :: 4 - Beta",
27
+ "Framework :: Pydantic :: 2",
14
28
  "Intended Audience :: Developers",
15
29
  "Operating System :: OS Independent",
16
30
  "Programming Language :: Python :: 3",
17
31
  "Programming Language :: Python :: 3 :: Only",
18
- "Programming Language :: Python :: 3.12",
19
32
  "Programming Language :: Python :: 3.13",
20
33
  "Programming Language :: Python :: 3.14",
21
- "Topic :: Documentation",
22
34
  "Topic :: Software Development",
35
+ "Topic :: Software Development :: Libraries :: Python Modules",
36
+ "Topic :: Software Development :: User Interfaces",
23
37
  "Topic :: Utilities",
24
38
  "Typing :: Typed",
25
39
  ]
26
40
  dependencies = [
27
41
  "fieldz>=0.1.0",
42
+ "pillow>=10.0",
43
+ "pydantic>=2.0",
28
44
  # Only add below (Copier)
29
45
  "streamlit>=1.43.2",
30
46
  ]
31
47
 
32
48
  [project.urls]
33
49
  "Code coverage" = "https://app.codecov.io/gh/phil65/streambricks"
34
- Discussions = "https://github.com/phil65/streambricks/discussions"
35
50
  Documentation = "https://phil65.github.io/streambricks/"
51
+ Homepage = "https://phil65.github.io/streambricks/"
36
52
  Issues = "https://github.com/phil65/streambricks/issues"
37
53
  Source = "https://github.com/phil65/streambricks"
38
54
 
39
55
  [project.optional-dependencies]
40
56
  auth = ["authlib"]
57
+ llm = ["tokonomics>=1.0.0"]
41
58
 
42
59
  [dependency-groups]
43
60
  dev = [
61
+ "deptry",
44
62
  "devtools",
45
63
  "pyreadline3",
46
64
  "pytest",
@@ -54,9 +72,8 @@ docs = [
54
72
  # Only add below (Copier)
55
73
  ]
56
74
  lint = [
57
- "mypy; python_version >= '3.14'",
58
- "mypy[faster-cache]; python_version < '3.14'",
59
75
  "ruff",
76
+ "ty",
60
77
  # Only add below (Copier)
61
78
  ]
62
79
 
@@ -73,6 +90,10 @@ exclude_lines = [
73
90
  'if __name__ == "__main__":',
74
91
  ]
75
92
 
93
+ [tool.deptry.per_rule_ignores]
94
+ # authlib is required by streamlit's st.login (auth extra), not imported directly.
95
+ DEP002 = ["authlib"]
96
+
76
97
  [tool.mknodes]
77
98
  allowed-commit-types = [
78
99
  "fix",
@@ -85,14 +106,6 @@ allowed-commit-types = [
85
106
  ]
86
107
  docstring-style = "google"
87
108
 
88
- [tool.mypy]
89
- python_version = "3.13"
90
- disable_error_code = ["misc", "import"]
91
- pretty = true
92
- check_untyped_defs = true
93
- exclude = ["venv/", ".venv/", "tests/"]
94
- plugins = []
95
-
96
109
  [tool.pyright]
97
110
  venvPath = "."
98
111
  venv = ".venv"
@@ -112,14 +125,16 @@ reportUnannotatedClassAttribute = false
112
125
  reportSelfClsParameterName = false
113
126
  reportPrivateImportUsage = false
114
127
 
115
- [tool.pytest.ini_options]
128
+ [tool.pytest]
116
129
  log_cli = true
117
130
  log_date_format = "%Y-%m-%d %H:%M:%S"
118
131
  log_format = "%(asctime)s %(levelname)s %(message)s"
119
- testpaths = "tests/"
132
+ minversion = "9.0"
133
+ testpaths = ["tests/"]
134
+ asyncio_mode = "auto"
120
135
 
121
136
  [tool.ruff]
122
- line-length = 90
137
+ line-length = 100
123
138
  extend-exclude = ["docs"]
124
139
  target-version = "py313"
125
140
 
@@ -212,11 +227,14 @@ ignore = [
212
227
  "D408", # Section underline should be in the line following the section's name ("{name}")
213
228
  "D409", # Section underline should match the length of its name ("{name}")
214
229
  "D413", # Missing blank line after last section ("{name}")
230
+ "EM101", # Exception must not use a string literal, assign to variable first
231
+ "EM102", # Exception must not use an f-string literal, assign to variable first
215
232
  "ISC001",
216
233
  "PLC0415",
217
234
  "PLR0912", # Too many branches
218
235
  "PLR0913", # Too many arguments to function call
219
236
  "PLR0915", # Too many statements
237
+ "PLR0917", # Too many positional arguments
220
238
  # "PLR2004", # Magic values instead of named consts
221
239
  "SLF001", # Private member accessed
222
240
  "TRY003", # Avoid specifying long messages outside the exception class
@@ -248,16 +266,52 @@ lines-after-imports = 2
248
266
  force-sort-within-sections = true
249
267
  combine-as-imports = true
250
268
 
269
+ [tool.ruff.lint.mccabe]
270
+ max-complexity = 15
271
+
251
272
  [tool.ruff.lint.per-file-ignores]
252
273
  "__init__.py" = ["E402", "I001"]
253
274
  "scripts/*" = ["INP001"]
275
+ "*tests/*" = ["D100"]
254
276
 
255
277
  [tool.ruff.format]
256
- # Enable preview style formatting.
257
278
  preview = true
258
279
 
259
280
  [tool.ty.environment]
260
281
  python-version = "3.13"
282
+ python-platform = "all"
283
+
284
+ [tool.ty.src]
285
+ # `ty check` (hooks, CI, editors) type-checks the package code only.
286
+ include = ["src"]
287
+
288
+ [tool.ty.analysis]
289
+ # Optional dependencies that are not always installed, e.g. "numpy", "numpy.**".
290
+ # Unresolved imports are errors otherwise, so broken imports are caught.
291
+ allowed-unresolved-imports = []
292
+
293
+ [tool.ty.rules]
294
+ # Narrowing an overridden class attribute (e.g. pydantic discriminators,
295
+ # `Config` attributes) is an intentional pattern.
296
+ incompatible-mutable-override = "ignore"
261
297
 
262
298
  [tool.uv]
263
299
  default-groups = ["dev", "lint", "docs"]
300
+
301
+ [tool.uv.build-backend]
302
+ wheel-exclude = [
303
+ ".mypy_cache/**",
304
+ "__pycache__/**",
305
+ "*.pyc",
306
+ "*.pyo",
307
+ ".pytest_cache/**",
308
+ ".ruff_cache/**",
309
+ ]
310
+ source-exclude = [
311
+ ".mypy_cache/**",
312
+ "__pycache__/**",
313
+ "*.pyc",
314
+ "*.pyo",
315
+ ".pytest_cache/**",
316
+ ".ruff_cache/**",
317
+ ]
@@ -55,7 +55,7 @@ def requires_login[**P, T](
55
55
  def decorator(fn: Callable[P, T]) -> Callable[P, T]:
56
56
  @functools.wraps(fn)
57
57
  def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
58
- if hasattr(st, "user") and st.user.is_logged_in:
58
+ if hasattr(st, "user") and getattr(st.user, "is_logged_in", False):
59
59
  return fn(*args, **kwargs)
60
60
 
61
61
  # Handle unauthorized access
@@ -190,9 +190,7 @@ def profile_widget(
190
190
  <div class="profile-widget-{key if key else "default"}">
191
191
  <img src="{img_src}" class="avatar-{key if key else "default"}" alt="User Avatar">
192
192
  {
193
- f'<span class="profile-name-{key if key else "default"}">{name}</span>'
194
- if show_name
195
- else ""
193
+ f'<span class="profile-name-{key if key else "default"}">{name}</span>' if show_name else ""
196
194
  }
197
195
  </div>
198
196
  """
@@ -0,0 +1,25 @@
1
+ """Logging configuration for streambricks."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+
7
+
8
+ LogLevel = int | str
9
+
10
+
11
+ def get_logger(name: str, log_level: LogLevel | None = None) -> logging.Logger:
12
+ """Get a logger for the given name.
13
+
14
+ Args:
15
+ name: The name of the logger.
16
+ Will be prefixed with 'streambricks'
17
+ log_level: The logging level to set for the logger
18
+
19
+ Returns:
20
+ A logger instance
21
+ """
22
+ logger = logging.getLogger(f"streambricks.{name}")
23
+ if log_level is not None:
24
+ logger.setLevel(log_level)
25
+ return logger
@@ -1,21 +1,19 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Self, TypeVar
3
+ from typing import Self
4
4
 
5
5
  from pydantic import BaseModel
6
6
  import streamlit as st
7
7
 
8
8
 
9
- T = TypeVar("T", bound=BaseModel)
10
-
11
-
12
9
  class State(BaseModel):
10
+ """Pydantic model stored in `st.session_state`, persisting across reruns."""
11
+
13
12
  @classmethod
14
13
  def get(cls, *, key: str | None = None) -> Self:
15
14
  """Get or initialize typed state for Streamlit.
16
15
 
17
16
  Args:
18
- model_class: Pydantic model class defining the state structure
19
17
  key: Optional key to use in session_state (defaults to model class name)
20
18
 
21
19
  Returns:
@@ -114,7 +114,8 @@ def bind_kwargs_as_widget[**P, T](
114
114
  defaults[name] = default
115
115
 
116
116
  # Create a Pydantic model dynamically
117
- model_name = f"{func.__name__}Config"
117
+ func_name = getattr(func, "__name__", type(func).__name__)
118
+ model_name = f"{func_name}Config"
118
119
  config_model = create_model(model_name, **fields) # type: ignore
119
120
 
120
121
  # Add docstrings as class variables
@@ -122,7 +123,7 @@ def bind_kwargs_as_widget[**P, T](
122
123
  setattr(config_model, f"__doc_{name}__", docstring)
123
124
 
124
125
  # Create a session state key for storing current config
125
- config_key = f"{widget_prefix}_{func.__name__}_config"
126
+ config_key = f"{widget_prefix}_{func_name}_config"
126
127
 
127
128
  @wraps(func)
128
129
  def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
@@ -130,9 +131,7 @@ def bind_kwargs_as_widget[**P, T](
130
131
  if config_key not in st.session_state:
131
132
  # Initialize with defaults
132
133
  config_data = {
133
- name: (defaults.get(name))
134
- for name in kwargs_to_bind
135
- if name in sig.parameters
134
+ name: (defaults.get(name)) for name in kwargs_to_bind if name in sig.parameters
136
135
  }
137
136
  # Override with any provided values in kwargs
138
137
  for name in kwargs_to_bind:
@@ -50,12 +50,9 @@ if TYPE_CHECKING:
50
50
 
51
51
  T = TypeVar("T")
52
52
  WidgetFunc = Callable[..., T]
53
- TForm = TypeVar("TForm", bound=BaseModel)
54
53
 
55
54
 
56
- FIELD_METADATA_RENDERERS: dict[str, WidgetFunc[Any]] = {
57
- "model_identifier": render_model_id_field
58
- }
55
+ FIELD_METADATA_RENDERERS: dict[str, WidgetFunc[Any]] = {"model_identifier": render_model_id_field}
59
56
 
60
57
 
61
58
  PRIMITIVE_RENDERERS = {
@@ -407,9 +404,7 @@ def render_open_set_field(
407
404
  temp_list: list[Any] = []
408
405
  add_new_item(temp_list, item_type)
409
406
  # If the temp_list has an item and it's not a duplicate, add it to our items
410
- if temp_list and str(temp_list[0]) not in {
411
- str(i) for i in st.session_state[items_key]
412
- }:
407
+ if temp_list and str(temp_list[0]) not in {str(i) for i in st.session_state[items_key]}:
413
408
  st.session_state[items_key].append(temp_list[0])
414
409
  elif temp_list: # Item was created but was a duplicate
415
410
  st.warning("Item already exists in the set.")
@@ -579,13 +574,9 @@ def render_model_instance_field( # noqa: PLR0911
579
574
  if possible_type is type(None):
580
575
  return None
581
576
  if is_literal_type(possible_type):
582
- return get_args(possible_type)[
583
- 0
584
- ] # Return first literal value
577
+ return get_args(possible_type)[0] # Return first literal value
585
578
 
586
- st.error(
587
- f"Could not create instance of any type in {model_class.__name__}"
588
- )
579
+ st.error(f"Could not create instance of any type in {model_class.__name__}")
589
580
  return None
590
581
  # Initialize value if none for non-union types
591
582
  elif value is None:
@@ -617,7 +608,7 @@ def render_model_instance_field( # noqa: PLR0911
617
608
  if field_help:
618
609
  nested_field_info["help"] = field_help
619
610
  if hasattr(field.native_field, "json_schema_extra"):
620
- nested_field_info.update(field.native_field.json_schema_extra or {}) # type: ignore
611
+ nested_field_info.update(field.native_field.json_schema_extra or {})
621
612
  renderer = get_field_renderer(nested_field_info)
622
613
  updated_value[field_name] = renderer(
623
614
  key=f"{key}_{field_name}",
@@ -643,8 +634,7 @@ def get_field_renderer(field_info: dict[str, Any]) -> WidgetFunc[Any]: # noqa:
643
634
  json_schema_extra = field_info.get("json_schema_extra", {})
644
635
  if (
645
636
  json_schema_extra
646
- and (field_type := json_schema_extra.get("field_type"))
647
- in FIELD_METADATA_RENDERERS
637
+ and (field_type := json_schema_extra.get("field_type")) in FIELD_METADATA_RENDERERS
648
638
  ):
649
639
  return FIELD_METADATA_RENDERERS[field_type]
650
640
  if annotation is SecretStr or (
@@ -680,7 +670,7 @@ def get_field_renderer(field_info: dict[str, Any]) -> WidgetFunc[Any]: # noqa:
680
670
  if isinstance(annotation, type):
681
671
  try:
682
672
  if issubclass(annotation, base_type): # type: ignore
683
- return renderer # type: ignore
673
+ return renderer
684
674
  except TypeError:
685
675
  # Skip if we get a TypeError (for special typing constructs)
686
676
  continue
@@ -697,7 +687,13 @@ def render_model_readonly[T](
697
687
  instance: T | None = None,
698
688
  exclude: set[str] | None = None,
699
689
  ):
700
- """Render a model in read-only mode using a clean label-based layout."""
690
+ """Render a model instance read-only, one labeled value per field.
691
+
692
+ Args:
693
+ model_class: Class of the model to display.
694
+ instance: Instance to display. Shows an info message if None.
695
+ exclude: Names of fields to leave out.
696
+ """
701
697
  excluded_fields = exclude or set()
702
698
  if instance is None:
703
699
  st.info("No data available")
@@ -808,7 +804,7 @@ def render_model_field(model_class, field_name, value=None, container=st):
808
804
  field = get_field(model_class, field_name)
809
805
  field_info = {"name": field.name, "type": field.type, "default": field.default}
810
806
  if hasattr(field.native_field, "json_schema_extra"):
811
- dct = field.native_field.json_schema_extra or {} # type: ignore
807
+ dct = field.native_field.json_schema_extra or {}
812
808
  field_info.update(dct)
813
809
  field_info["json_schema_extra"] = dct
814
810
  label = field_name.replace("_", " ").title()
@@ -843,7 +839,19 @@ def render_model_form(
843
839
  readonly: bool = False,
844
840
  exclude: set[str] | None = None,
845
841
  ) -> Any:
846
- """Render a complete form for a model class or instance using compact layout."""
842
+ """Render a form for a model class or instance and return the edited instance.
843
+
844
+ Works with Pydantic models, dataclasses and other classes supported by fieldz.
845
+ Fields with a `category` in their metadata are grouped into tabs.
846
+
847
+ Args:
848
+ model_or_instance: Model class (a default instance is created) or instance.
849
+ readonly: Render the values read-only instead of as input widgets.
850
+ exclude: Names of fields to leave out.
851
+
852
+ Returns:
853
+ A new instance with the values entered in the form.
854
+ """
847
855
  excluded_fields = exclude or set()
848
856
  if isinstance(model_or_instance, type):
849
857
  model_class = model_or_instance
@@ -878,18 +886,14 @@ def render_model_form(
878
886
  if field.name in excluded_fields:
879
887
  continue
880
888
  current_value = get_with_default(instance, field.name, field)
881
- result[field.name] = render_model_field(
882
- model_class, field.name, current_value
883
- )
889
+ result[field.name] = render_model_field(model_class, field.name, current_value)
884
890
  else:
885
891
  # Single category, render fields directly
886
892
  for field in fieldz.fields(model_class, parse_annotated=True):
887
893
  if field.name in excluded_fields:
888
894
  continue
889
895
  current_value = get_with_default(instance, field.name, field)
890
- result[field.name] = render_model_field(
891
- model_class, field.name, current_value
892
- )
896
+ result[field.name] = render_model_field(model_class, field.name, current_value)
893
897
 
894
898
  return fieldz.replace(instance, **result)
895
899
 
@@ -971,9 +975,7 @@ if __name__ == "__main__":
971
975
  settings: list[SubModel] = pydantic.Field(default_factory=list)
972
976
  """A list of nested models"""
973
977
 
974
- priorities: list[Literal["Low", "Medium", "High"]] = pydantic.Field(
975
- default_factory=list
976
- )
978
+ priorities: list[Literal["Low", "Medium", "High"]] = pydantic.Field(default_factory=list)
977
979
  """A list of priority levels."""
978
980
 
979
981
  def demo():
@@ -30,9 +30,7 @@ def render_str_field(
30
30
  multiple_lines = field_info.get("multiple_lines", False)
31
31
  safe_value = "" if value is None else value
32
32
  has_meaningful_content = safe_value.strip() != ""
33
- has_line_breaks = has_meaningful_content and (
34
- "\n" in safe_value or "\r" in safe_value
35
- )
33
+ has_line_breaks = has_meaningful_content and ("\n" in safe_value or "\r" in safe_value)
36
34
  is_long_val = len(safe_value) > 100 # noqa: PLR2004
37
35
  use_text_area = max_length > 100 or is_long_val or multiple_lines or has_line_breaks # noqa: PLR2004
38
36
 
@@ -73,10 +73,7 @@ def unpack_annotated(annotation: Any) -> Any:
73
73
  def is_literal_type(annotation: Any) -> bool:
74
74
  """Check if a type annotation is a Literal type."""
75
75
  # Check directly against the origin or special attribute
76
- return (
77
- get_origin(annotation) is Literal
78
- or getattr(annotation, "__origin__", None) is Literal
79
- )
76
+ return get_origin(annotation) is Literal or getattr(annotation, "__origin__", None) is Literal
80
77
 
81
78
 
82
79
  def is_union_type(annotation: Any) -> bool:
@@ -257,7 +254,7 @@ def get_description(field: fieldz.Field) -> str | None:
257
254
  if "description" in field.metadata:
258
255
  return field.metadata["description"]
259
256
  if hasattr(field.native_field, "description"):
260
- return field.native_field.description # type: ignore
257
+ return field.native_field.description
261
258
  return None
262
259
 
263
260
 
@@ -361,9 +358,7 @@ def get_union_type_options(annotation: Any) -> list[tuple[Any, str]]:
361
358
 
362
359
  # Handle Literal types
363
360
  elif is_literal_type(arg):
364
- values = ", ".join(
365
- f'"{v}"' if isinstance(v, str) else str(v) for v in get_args(arg)
366
- )
361
+ values = ", ".join(f'"{v}"' if isinstance(v, str) else str(v) for v in get_args(arg))
367
362
  description = f"Literal[{values}]"
368
363
  type_options.append((arg, description))
369
364
 
@@ -1,79 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: streambricks
3
- Version: 1.0.0
4
- Summary: Streamlit widgets and helpers
5
- Keywords:
6
- Author: Philipp Temminghoff
7
- Author-email: Philipp Temminghoff <philipptemminghoff@googlemail.com>
8
- License: MIT License
9
-
10
- Copyright (c) 2024, Philipp Temminghoff
11
-
12
- Permission is hereby granted, free of charge, to any person obtaining a copy
13
- of this software and associated documentation files (the "Software"), to deal
14
- in the Software without restriction, including without limitation the rights
15
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- copies of the Software, and to permit persons to whom the Software is
17
- furnished to do so, subject to the following conditions:
18
-
19
- The above copyright notice and this permission notice shall be included in all
20
- copies or substantial portions of the Software.
21
-
22
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- SOFTWARE.
29
-
30
- Classifier: Development Status :: 4 - Beta
31
- Classifier: Intended Audience :: Developers
32
- Classifier: Operating System :: OS Independent
33
- Classifier: Programming Language :: Python :: 3
34
- Classifier: Programming Language :: Python :: 3 :: Only
35
- Classifier: Programming Language :: Python :: 3.12
36
- Classifier: Programming Language :: Python :: 3.13
37
- Classifier: Programming Language :: Python :: 3.14
38
- Classifier: Topic :: Documentation
39
- Classifier: Topic :: Software Development
40
- Classifier: Topic :: Utilities
41
- Classifier: Typing :: Typed
42
- Requires-Dist: fieldz>=0.1.0
43
- Requires-Dist: streamlit>=1.43.2
44
- Requires-Dist: authlib ; extra == 'auth'
45
- Requires-Python: >=3.13
46
- Project-URL: Code coverage, https://app.codecov.io/gh/phil65/streambricks
47
- Project-URL: Discussions, https://github.com/phil65/streambricks/discussions
48
- Project-URL: Documentation, https://phil65.github.io/streambricks/
49
- Project-URL: Issues, https://github.com/phil65/streambricks/issues
50
- Project-URL: Source, https://github.com/phil65/streambricks
51
- Provides-Extra: auth
52
- Description-Content-Type: text/markdown
53
-
54
- # StreamBricks
55
-
56
- [![PyPI License](https://img.shields.io/pypi/l/streambricks.svg)](https://pypi.org/project/streambricks/)
57
- [![Package status](https://img.shields.io/pypi/status/streambricks.svg)](https://pypi.org/project/streambricks/)
58
- [![Monthly downloads](https://img.shields.io/pypi/dm/streambricks.svg)](https://pypi.org/project/streambricks/)
59
- [![Distribution format](https://img.shields.io/pypi/format/streambricks.svg)](https://pypi.org/project/streambricks/)
60
- [![Wheel availability](https://img.shields.io/pypi/wheel/streambricks.svg)](https://pypi.org/project/streambricks/)
61
- [![Python version](https://img.shields.io/pypi/pyversions/streambricks.svg)](https://pypi.org/project/streambricks/)
62
- [![Implementation](https://img.shields.io/pypi/implementation/streambricks.svg)](https://pypi.org/project/streambricks/)
63
- [![Releases](https://img.shields.io/github/downloads/phil65/streambricks/total.svg)](https://github.com/phil65/streambricks/releases)
64
- [![Github Contributors](https://img.shields.io/github/contributors/phil65/streambricks)](https://github.com/phil65/streambricks/graphs/contributors)
65
- [![Github Discussions](https://img.shields.io/github/discussions/phil65/streambricks)](https://github.com/phil65/streambricks/discussions)
66
- [![Github Forks](https://img.shields.io/github/forks/phil65/streambricks)](https://github.com/phil65/streambricks/forks)
67
- [![Github Issues](https://img.shields.io/github/issues/phil65/streambricks)](https://github.com/phil65/streambricks/issues)
68
- [![Github Issues](https://img.shields.io/github/issues-pr/phil65/streambricks)](https://github.com/phil65/streambricks/pulls)
69
- [![Github Watchers](https://img.shields.io/github/watchers/phil65/streambricks)](https://github.com/phil65/streambricks/watchers)
70
- [![Github Stars](https://img.shields.io/github/stars/phil65/streambricks)](https://github.com/phil65/streambricks/stars)
71
- [![Github Repository size](https://img.shields.io/github/repo-size/phil65/streambricks)](https://github.com/phil65/streambricks)
72
- [![Github last commit](https://img.shields.io/github/last-commit/phil65/streambricks)](https://github.com/phil65/streambricks/commits)
73
- [![Github release date](https://img.shields.io/github/release-date/phil65/streambricks)](https://github.com/phil65/streambricks/releases)
74
- [![Github language count](https://img.shields.io/github/languages/count/phil65/streambricks)](https://github.com/phil65/streambricks)
75
- [![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/streambricks)](https://github.com/phil65/streambricks)
76
- [![Package status](https://codecov.io/gh/phil65/streambricks/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/streambricks/)
77
- [![PyUp](https://pyup.io/repos/github/phil65/streambricks/shield.svg)](https://pyup.io/repos/github/phil65/streambricks/)
78
-
79
- [Read the documentation!](https://phil65.github.io/streambricks/)
@@ -1,26 +0,0 @@
1
- # StreamBricks
2
-
3
- [![PyPI License](https://img.shields.io/pypi/l/streambricks.svg)](https://pypi.org/project/streambricks/)
4
- [![Package status](https://img.shields.io/pypi/status/streambricks.svg)](https://pypi.org/project/streambricks/)
5
- [![Monthly downloads](https://img.shields.io/pypi/dm/streambricks.svg)](https://pypi.org/project/streambricks/)
6
- [![Distribution format](https://img.shields.io/pypi/format/streambricks.svg)](https://pypi.org/project/streambricks/)
7
- [![Wheel availability](https://img.shields.io/pypi/wheel/streambricks.svg)](https://pypi.org/project/streambricks/)
8
- [![Python version](https://img.shields.io/pypi/pyversions/streambricks.svg)](https://pypi.org/project/streambricks/)
9
- [![Implementation](https://img.shields.io/pypi/implementation/streambricks.svg)](https://pypi.org/project/streambricks/)
10
- [![Releases](https://img.shields.io/github/downloads/phil65/streambricks/total.svg)](https://github.com/phil65/streambricks/releases)
11
- [![Github Contributors](https://img.shields.io/github/contributors/phil65/streambricks)](https://github.com/phil65/streambricks/graphs/contributors)
12
- [![Github Discussions](https://img.shields.io/github/discussions/phil65/streambricks)](https://github.com/phil65/streambricks/discussions)
13
- [![Github Forks](https://img.shields.io/github/forks/phil65/streambricks)](https://github.com/phil65/streambricks/forks)
14
- [![Github Issues](https://img.shields.io/github/issues/phil65/streambricks)](https://github.com/phil65/streambricks/issues)
15
- [![Github Issues](https://img.shields.io/github/issues-pr/phil65/streambricks)](https://github.com/phil65/streambricks/pulls)
16
- [![Github Watchers](https://img.shields.io/github/watchers/phil65/streambricks)](https://github.com/phil65/streambricks/watchers)
17
- [![Github Stars](https://img.shields.io/github/stars/phil65/streambricks)](https://github.com/phil65/streambricks/stars)
18
- [![Github Repository size](https://img.shields.io/github/repo-size/phil65/streambricks)](https://github.com/phil65/streambricks)
19
- [![Github last commit](https://img.shields.io/github/last-commit/phil65/streambricks)](https://github.com/phil65/streambricks/commits)
20
- [![Github release date](https://img.shields.io/github/release-date/phil65/streambricks)](https://github.com/phil65/streambricks/releases)
21
- [![Github language count](https://img.shields.io/github/languages/count/phil65/streambricks)](https://github.com/phil65/streambricks)
22
- [![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/streambricks)](https://github.com/phil65/streambricks)
23
- [![Package status](https://codecov.io/gh/phil65/streambricks/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/streambricks/)
24
- [![PyUp](https://pyup.io/repos/github/phil65/streambricks/shield.svg)](https://pyup.io/repos/github/phil65/streambricks/)
25
-
26
- [Read the documentation!](https://phil65.github.io/streambricks/)
File without changes