Skip to content

Commit d047aa9

Browse files
committed
doc
1 parent aec4c1e commit d047aa9

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

packages/models-library/src/models_library/basic_types.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
assert issubclass(BuildTargetEnum, Enum) # nosec
2020

2121
__all__: tuple[str, ...] = (
22-
"LogLevel",
2322
"BootModeEnum",
2423
"BuildTargetEnum",
24+
"LogLevel",
2525
)
2626

2727

@@ -76,6 +76,11 @@
7676

7777

7878
class ConstrainedStr(str):
79+
"""Emulates pydantic's v1 constrained types
80+
81+
DEPRECATED: Use instead Annotated[str, StringConstraints(...)]
82+
"""
83+
7984
pattern: str | Pattern[str] | None = None
8085
min_length: int | None = None
8186
max_length: int | None = None
@@ -102,6 +107,11 @@ def __get_pydantic_core_schema__(cls, _source_type, _handler):
102107

103108

104109
class IDStr(ConstrainedStr):
110+
"""Non-empty bounded string used as identifier
111+
112+
DEPRECATED: Use instead Annotated[str, StringConstraints(strip_whitespace=True, min_length=1, max_length=100)]
113+
"""
114+
105115
strip_whitespace = True
106116
min_length = 1
107117
max_length = 100
@@ -126,18 +136,29 @@ def concatenate(*args: "IDStr", link_char: str = " ") -> "IDStr":
126136

127137

128138
class ShortTruncatedStr(ConstrainedStr):
129-
# NOTE: Use to input e.g. titles or display names
130-
# A truncated string:
131-
# - Strips whitespaces and truncate strings that exceed the specified characters limit (curtail_length).
132-
# - Ensures that the **input** data length to the API is controlled and prevents exceeding large inputs silently, i.e. without raising errors.
133-
# SEE https://github.com/ITISFoundation/osparc-simcore/pull/5989#discussion_r1650506583
139+
"""A truncated string used to input e.g. titles or display names
140+
141+
- Strips whitespaces and truncate strings that exceed the specified characters limit (curtail_length).
142+
- Ensures that the **input** data length to the API is controlled and prevents exceeding large inputs silently,
143+
i.e. without raising errors.
144+
145+
SEE https://github.com/ITISFoundation/osparc-simcore/pull/5989#discussion_r1650506583
146+
147+
DEPRECATED: Use instead Annotated[str, StringConstraints(strip_whitespace=True), trim_string_before(max_length=600)]
148+
"""
149+
134150
strip_whitespace = True
135151
curtail_length = 600
136152

137153

138154
class LongTruncatedStr(ConstrainedStr):
139-
# NOTE: Use to input e.g. descriptions or summaries
140-
# Analogous to ShortTruncatedStr
155+
"""Use to input e.g. descriptions or summaries
156+
157+
Analogous to ShortTruncatedStr
158+
159+
DEPRECATED: Use instead Annotated[str, StringConstraints(strip_whitespace=True), trim_string_before(max_length=65536)]
160+
"""
161+
141162
strip_whitespace = True
142163
curtail_length = 65536 # same as github descripton
143164

0 commit comments

Comments
 (0)