datalad_next.constraints.WithDescription
- class datalad_next.constraints.WithDescription(constraint: Constraint, *, input_synopsis: str | None = None, input_description: str | None = None, error_message: str | None = None, input_synopsis_for_ds: str | None = None, input_description_for_ds: str | None = None, error_message_for_ds: str | None = None)[source]
Bases:
Constraint
Constraint that wraps another constraint and replaces its description
Whenever a constraint's self-description does not fit an application context, it can be wrapped with this class. The given synopsis and description of valid inputs replaces those of the wrapped constraint.
- property constraint: Constraint
Returns the wrapped constraint instance
- for_dataset(dataset: DatasetParameter) Constraint [source]
Wrap the wrapped constraint again after tailoring it for the dataset
- property input_description
Returns full description of valid input for a constraint
Like
input_synopsis
this information is user-facing. In contrast, to the synopsis there is length/line limit. Nevertheless, the information should be presented in a compact fashion that avoids needless verbosity. If possible, a single paragraph is a good format. If multiple paragraphs are necessary, they should be separated by a single, empty line.Rendering code may indent, or rewrap the text, so no line-by-line formatting will be preserved.
If possible, the synopsis should be written in a UI/API-agnostic fashion. However, if this is impossible or leads to imprecisions or confusion, it should focus on use within Python code and with Python data types. Tailored documentation can be provided via the
WithDescription
wrapper.
- property input_synopsis
Returns brief, single line summary of valid input for a constraint
This information is user-facing, and to be used in any place where space is limited (tooltips, usage summaries, etc).
If possible, the synopsis should be written in a UI/API-agnostic fashion. However, if this is impossible or leads to imprecisions or confusion, it should focus on use within Python code and with Python data types. Tailored documentation can be provided via the
WithDescription
wrapper.