Python API¶
Sphinx-Needs provides an open API for other Sphinx-extensions to provide specific need-types, create needs or make usage of the filter possibilities.
The API allows the injection of extra configuration, but does not support manipulation of it (e.g remove need types), to keep the final configuration transparent for the Sphinx project authors.
Configuration¶
API to get or add specific sphinx needs configuration parameters.
All functions here are available under sphinx_needs.api.
- add_dynamic_function(app: Sphinx, function: DynamicFunction, name: str | None = None) None¶
Registers a new dynamic function for sphinx-needs.
If
nameis not given, the name to call the function is automatically taken from the provided function. The used name must be unique.Usage:
from sphinx_needs.api import add_dynamic_function def my_function(app, need, needs, *args, **kwargs): # Do magic here return "some data" add_dynamic_function(app, my_function)
Read Dynamic functions for details about how to use dynamic functions.
- Parameters:
app – Sphinx application object
function – Function to register
name – Name of the dynamic function as string
- Returns:
None
- add_extra_option(app: Sphinx, name: str, *, description: str = 'Added by add_extra_option API', schema: ExtraOptionStringSchemaType | ExtraOptionBooleanSchemaType | ExtraOptionIntegerSchemaType | ExtraOptionNumberSchemaType | ExtraOptionMultiValueSchemaType | None = None, nullable: bool | None = None) None¶
Adds an extra option to the configuration. This option can then later be used inside needs or
add_need.Same impact as using needs_extra_options manually.
Usage:
from sphinx_needs.api import add_extra_option add_extra_option(app, 'my_extra_option')
- Parameters:
app – Sphinx application object
name – Name of the extra option
description – Description of the extra option
schema – Schema definition for the extra option
nullable – Whether the field allows unset values.
- Returns:
None
- add_need_type(app: Sphinx, directive: str, title: str, prefix: str, color: str = '#ffffff', style: str = 'node') None¶
Adds a new need_type to the configuration.
The given directive must no exist, otherwise NeedsApiConfigException gets raised.
Same impact as using needs_types manually.
Usage:
from sphinx_needs.api import add_need_type add_need_type(app, 'awesome', 'Awesome', 'AW_', '#000000', 'cloud')
- Parameters:
app – Sphinx application object
directive – Name of the directive, e.g. ‘story’
title – Long, human-readable title, e.g. ‘User-Story’
prefix – Prefix, if IDs get automatically generated. E.g.:
'US_'color – Hex-color code used in needflow representation. Default:
'#ffffff'style – Plantuml-style for needflow representation. Default: ‘node’
- Returns:
None
- add_warning(app: Sphinx, name: str, function: Callable[[NeedItem, SphinxLoggerAdapter], bool] | None = None, filter_string: str | None = None) None¶
Registers a warning.
A warning can be based on the result of a given filter_string or an own defined function.
- Parameters:
app – Sphinx app object
name – Name as string for the warning
function – function to execute to check the warning
filter_string – filter_string to use for the warning
- Returns:
None
Need¶
- class DefaultContextData¶
- add_external_need(app: Sphinx, need_type: str, title: str | None = None, id: str | None = None, need_source: NeedItemSourceProtocol | None = None, external_url: str | None = None, external_css: str = 'external_link', content: str = '', status: str | None = None, tags: str | list[str] | None = None, constraints: str | None = None, **kwargs: Any) list[Node]¶
Adds an external need from an external source. This need does not have any representation in the current documentation project. However, it can be linked and filtered. It’s reference will open a link to another, external sphinx documentation project.
It returns an empty list (without any nodes), so no nodes will be added to the document.
- Parameters:
app – Sphinx application object.
need_type – Name of the need type to create.
title – String as title.
id – ID as string. If not given, a id will get generated.
external_url – URL as string, which shall be used as link to the original need source
content – Content as single string.
status – Status as string.
tags – A list of tags, or a comma separated string.
constraints – constraints as single, comma separated string.
external_css – CSS class name as string, which is set for the <a> tag.
- Raises:
InvalidNeedException – If the need could not be added due to a validation issue.
- add_need(app: Sphinx, state: None | RSTState = None, docname: None | str = None, lineno: None | int = None, need_type: str = '', title: str = '', *, need_source: NeedItemSourceProtocol | None = None, id: str | None = None, content: str | StringList = '', lineno_content: None | int = None, doctype: None | str = None, status: str | None = None, tags: None | str | list[str] = None, constraints: None | str | list[str] = None, parts: dict[str, NeedsPartType] | None = None, arch: dict[str, str] | None = None, signature: None | str = None, sections: list[str] | None = None, jinja_content: bool | None = None, hide: None | bool | str = None, collapse: None | bool | str = None, style: None | str = None, layout: None | str = None, template: None | str = None, pre_template: str | None = None, post_template: str | None = None, is_import: bool = False, is_external: bool = False, external_url: str | None = None, external_css: str = 'external_link', full_title: str | None = None, allow_type_coercion: bool = True, **kwargs: Any) list[Node]¶
Creates a new need and returns its node.
add_needallows to create needs programmatically and use its returned node to be integrated in any docutils based structure.kwargscan contain options defined inneeds_extra_optionsandneeds_extra_links. If an entry is found inkwargs, which is not specified in the configuration or registered e.g. viaadd_extra_option, an exception is raised.If
is_externalis set toTrue, no node will be created. Instead, the need is referencing an external url. Used mostly for needs_external_needs to integrate and reference needs from external documentation.- Raises:
InvalidNeedException – If the need could not be added due to a validation issue.
If the need is within the current project, i.e. not an external need, the following parameters are used to help provide source mapped warnings and errors:
- Parameters:
docname – documentation identifier, for the referencing document.
lineno – line number of the top of the directive (1-indexed).
lineno_content – line number of the content start of the directive (1-indexed).
Otherwise, the following parameters are used:
- Parameters:
is_external – Is true, no node is created and need is referencing external url
external_url – URL as string, which is used as target if
is_externalisTrueexternal_css – CSS class name as string, which is set for the <a> tag.
Additional parameters:
- Parameters:
app – Sphinx application object.
state – Current state object.
need_type – Name of the need type to create.
title – String as title.
full_title – This is given, if an auto-generated title was trimmed. It is used to auto-generate the ID, if required.
id – ID as string. If not given, an id will get generated.
content – Content of the need, either as a
stror aStringList(a string with mapping to the source text).status – Status as string.
tags – A list of tags, or a comma separated string.
constraints – Constraints as single, comma separated, string.
constraints_passed – Contains bool describing if all constraints have passed
hide – If True then the need is not rendered.
Nonemeans that the value can be overriden by global defaults, else it is set to False.collapse – If True, then hide the meta-data information of the need.
Nonemeans that the value can be overriden by global defaults, else it is set to False.style – String value of class attribute of node.
layout – String value of layout definition to use
template – Template name to use for the content of this need
pre_template – Template name to use for content added before need
post_template – Template name to use for the content added after need
allow_type_coercion – If true, values will be coerced to the expected type where possible.
- Returns:
list of nodes
- del_need(app: Sphinx, need_id: str) None¶
Deletes an existing need.
- Parameters:
app – Sphinx application object.
need_id – Sphinx need id.
- generate_need(needs_config: NeedsSphinxConfig, needs_schema: FieldsSchema, need_type: str, title: str, *, need_source: NeedItemSourceProtocol | None = None, docname: None | str = None, lineno: None | int = None, id: str | None = None, doctype: str = '.rst', content: str = '', lineno_content: None | int = None, status: str | None = None, tags: None | str | list[str] = None, constraints: None | str | list[str] = None, parts: dict[str, NeedsPartType] | None = None, arch: dict[str, str] | None = None, signature: None | str = None, sections: Sequence[str] | None = None, jinja_content: bool | None = None, hide: None | bool | str = None, collapse: None | bool | str = None, style: None | str = None, layout: None | str = None, template_root: Path | None = None, template: None | str = None, pre_template: str | None = None, post_template: str | None = None, is_import: bool = False, is_external: bool = False, external_url: str | None = None, external_css: str = 'external_link', full_title: str | None = None, allow_type_coercion: bool = True, **kwargs: Any) NeedItem¶
Creates a validated need data entry, without adding it to the project.
Important
This function does not parse or analyse the content, and so will not auto-populate the
partsorarchfields of the need from the content.It will also not validate that the ID is not already in use within the project.
- Raises:
InvalidNeedException – If the data fails any validation issue.
kwargscan contain options defined inneeds_extra_optionsandneeds_extra_links. If an entry is found inkwargs, which is not specified in the configuration or registered e.g. viaadd_extra_option, an exception is raised.If the need is within the current project, i.e. not an external need, the following parameters are used to help provide source mapped warnings and errors:
- Parameters:
docname – documentation identifier, for the referencing document.
lineno – line number of the top of the directive (1-indexed).
lineno_content – line number of the content start of the directive (1-indexed).
Otherwise, the following parameters are used:
- Parameters:
is_external – Is true, no node is created and need is referencing external url
external_url – URL as string, which is used as target if
is_externalisTrueexternal_css – CSS class name as string, which is set for the <a> tag.
Additional parameters:
- Parameters:
app – Sphinx application object.
state – Current state object.
need_type – Name of the need type to create.
title – String as title.
full_title – This is given, if an auto-generated title was trimmed. It is used to auto-generate the ID, if required.
id – ID as string. If not given, an id will get generated.
content – Content of the need
status – Status as string.
tags – A list of tags, or a comma separated string.
constraints – Constraint names as comma separated string or list of strings
constraints_passed – Contains bool describing if all constraints have passed
hide – If True then the need is not rendered.
Nonemeans that the value can be overriden by global defaults, else it is set to False.collapse – If True, then hide the meta-data information of the need.
Nonemeans that the value can be overriden by global defaults, else it is set to False.style – String value of class attribute of node.
layout – String value of layout definition to use
template_root – Root path for template files, only required if the template_path config is relative.
template – Template name to use for the content of this need
pre_template – Template name to use for content added before need
post_template – Template name to use for the content added after need
allow_type_coercion – If true, values will be coerced to the expected type where possible.
- get_needs_view(app: Sphinx) NeedsView¶
Return a read-only view of all resolved needs.
Important
this should only be called within the write phase, after the needs have been fully collected. If not already done, this will ensure all needs are resolved (e.g. back links have been computed etc), and then lock the data to prevent further modification.
Exceptions¶
- exception FunctionParsingException(message: str, name: str | None)¶
Called if parsing of given function string has not worked
- exception InvalidNeedException(type_: Literal['invalid_kwargs', 'invalid_type', 'invalid_extra_option', 'invalid_link_option', 'missing_id', 'invalid_id', 'duplicate_id', 'invalid_title', 'invalid_status', 'invalid_tags', 'invalid_layout', 'invalid_style', 'invalid_value', 'invalid_constraints', 'invalid_jinja_content', 'invalid_template', 'global_option', 'failed_init'], message: str)¶
Raised when a need could not be created/added, due to a validation issue.
- exception NeedsApiConfigException¶
A configuration changes collides with the already provided configuration by the user.
Example: An extension wants to add an already existing needs_type.
- exception NeedsApiConfigWarning¶
- exception NeedsConfigException¶
- exception NeedsConstraintFailed¶
- exception NeedsInvalidException¶
- exception NeedsInvalidFilter¶
Data¶
- class NeedConstraintResults(constraints: Mapping[str, tuple[tuple[str, bool, str | None], ...]])¶
A class representing the results of constraints on a need item.
- class NeedItem(*, source: NeedItemSourceProtocol | None, content: NeedsContent, core: NeedsInfoType, extras: dict[str, AllowedTypes | None], links: dict[str, list[str]], backlinks: dict[str, list[str]] | None = None, parts: Sequence[NeedPartData] = (), modifications: Sequence[NeedModification] = (), constraint_results: None | NeedConstraintResults = None, dynamic_fields: dict[str, FieldFunctionArray | LinksFunctionArray] | None = None, _validate: bool = True)¶
A class representing a single need item.
- add_modification(modification: NeedModification) None¶
Add a modification to the need item.
- Parameters:
modification – The modification to add.
- property constraint_results: None | NeedConstraintResults¶
Return the constraint results of the need item.
- property content: NeedsContent¶
Return the content of the need item.
- get_backlinks(link_type: str) list[str]¶
Get backlink references by link_type key.
- Raises:
KeyError – If the link_type is not a backlink type.
- get_extra(key: str) AllowedTypes | None¶
Get an extra by key.
- Raises:
KeyError – If the key is not an extra.
- get_links(link_type: str) list[str]¶
Get link references by link_type key.
- Raises:
KeyError – If the link_type is not a link type.
- get_part(part_id: str) NeedPartData | None¶
Get a part by its ID.
- get_part_item(part_id: str) NeedPartItem | None¶
Get a part, merged with its parent need, by its ID.
- property has_dynamic_fields: bool¶
Return True if the need item has dynamic fields, False otherwise.
- iter_backlinks_items() Iterable[tuple[str, list[str]]]¶
Yield all backlinks as (link_type, references) pairs.
- iter_links_items() Iterable[tuple[str, list[str]]]¶
Yield all links as (link_type, references) pairs.
- iter_part_items() Iterable[NeedPartItem]¶
Yield all parts, merged with the parent part, from a need.
- property modifications: tuple[NeedModification, ...]¶
Return the modifications of the need item.
- property parts: Iterable[NeedPartData]¶
Return the parts of the need item.
- set_constraint_results(constraint_results: None | NeedConstraintResults, *, _recompute: bool = True) None¶
Set the constraint results for the need item.
- Parameters:
constraint_results – The constraint results to set.
- set_content(content: NeedsContent) None¶
Replace the content of the need item.
- Parameters:
new_content – The new content to set.
- set_parts(parts: Sequence[NeedPartData], *, _recompute: bool = True) None¶
Set the parts of the need item.
- Parameters:
parts – The parts to set.
- property source: NeedItemSourceProtocol¶
Return the source of the need item.
- class NeedItemSourceProtocol(*args, **kwargs)¶
Protocol for need item source types.
- property dict_repr: NeedsSourceInfoType¶
Return a dictionary representation of the source.
- class NeedModification(*, docname: str | None = None, lineno: int | None = None)¶
A class representing a modification to a need item, by a needextend directive.
- class NeedPartData(*, id: str, content: str, backlinks: dict[str, list[str]] = <factory>)¶
A class representing a part of a need, which is generally derived from
:np:role within the parent need.
- class NeedPartItem(need: NeedItem, part_id: str)¶
A class representing a part of a need, which is a sub-need, merged with the parent need.
Any data coming from the part will override the data from the parent need.
Note this is a read-only view into a need part. It does not allow modification of the underlying data.
- copy() NeedPartItem¶
Return a copy of the NeedPartItem.
- copy_for_needtable() NeedPartItem¶
Return a copy of the NeedPartItem with specific fields for needtable.
- get_backlinks(link_type: str) list[str]¶
Get backlink references by link_type key.
- Raises:
KeyError – If the link_type is not a backlink type.
- get_links(link_type: str) list[str]¶
Get link references by link_type key.
- Raises:
KeyError – If the link_type is not a link type.
- iter_backlinks_items() Iterable[tuple[str, list[str]]]¶
Yield all backlinks as (link_type, references) pairs.
- class NeedsContent(*, doctype: str, content: str, pre_content: str | None = None, post_content: str | None = None, jinja_content: bool = False, template: str | None = None, pre_template: str | None = None, post_template: str | None = None)¶
A class representing the content of a need item.
Module to control access to sphinx-needs data, which is stored in the Sphinx environment.
- class NeedsInfoComputedType¶
Data for a single need, that can be computed from existing data.
These fields are used for convenience in filters.
- constraints_error: None | str¶
An error message set if any constraint failed, and error_message field is set in config.
- constraints_passed: None | bool¶
True if all constraints passed, False if any failed, None if not yet checked.
- constraints_results: None | Mapping[str, Mapping[str, bool]]¶
Mapping of constraint name, to check name, to result, None if not yet checked.
- parts: Mapping[str, NeedsPartType]¶
Mapping of parts, a.k.a. sub-needs, IDs to data that overrides the need’s data
- class NeedsInfoType¶
Data for a single need.
- class NeedsPartType¶
Data for a single need part.
- class NeedsSourceInfoType¶
Data for the source of a single need.
Views¶
These views are returned by certain functions, and injected into filters, but should not be instantiated directly.
- class NeedsAndPartsListView(*, _indexes: _LazyIndexes, _selected_ids: dict[tuple[str, str | None], None] | None)¶
A read-only view of needs and parts, after resolution (e.g. back links have been computed etc)
The parts are created by creating a copy of the need for each item in
parts, and then overwriting a subset of fields with the values from the part.- __iter__() Iterator[NeedItem | NeedPartItem]¶
Iterate over the needs and parts in the view.
- filter_has_tag(values: list[str]) NeedsAndPartsListView¶
Create new view with only needs/parts that have at least one of these values in the
tagsfield list.
- filter_ids(values: Iterable[str]) NeedsAndPartsListView¶
Create new view with needs/parts filtered by the
idfield.
- filter_is_external(value: bool) NeedsAndPartsListView¶
Create new view with only needs/parts where
is_externalfield is true/false.
- filter_statuses(values: list[str]) NeedsAndPartsListView¶
Create new view with only needs/parts that have certain
statusfield values.
- filter_types(values: list[str], or_type_names: bool = False) NeedsAndPartsListView¶
Create new view with only needs/parts that have certain
typefield values.- Parameters:
values – List of types to filter by.
or_type_names – If True, filter by both
typeandtype_namefield
- class NeedsView(*, _indexes: _LazyIndexes, _selected_ids: dict[str, None] | None)¶
A read-only view of needs, mapping need ids to need data, with “fast” filtering methods.
The needs are read-only and fully resolved (e.g. dynamic values and back links have been computed etc)
- filter_has_tag(values: list[str]) NeedsView¶
Create new view with only needs that have at least one of these values in the
tagsfield list.
- filter_is_external(value: bool) NeedsView¶
Create new view with only needs where
is_externalfield is true/false.
- filter_statuses(values: list[str]) NeedsView¶
Create new view with only needs that have certain
statusfield values.
- filter_types(values: list[str], or_type_names: bool = False) NeedsView¶
Create new view with only needs that have certain
typefield values.- Parameters:
values – List of types to filter by.
or_type_names – If True, filter by both
typeandtype_namefield
- to_list_with_parts() NeedsAndPartsListView¶
Create a new view with needs and parts.
Schema¶
- AllowedTypes: TypeAlias = str | bool | int | float | list[str] | list[bool] | list[int] | list[float]¶
Type alias for all allowed types in need fields.
This includes scalar types (str, bool, int, float) and their corresponding list types.
- class FieldFunctionArray(value: 'tuple[DynamicFunctionParsed | VariantFunctionParsed | str, ...] | tuple[DynamicFunctionParsed | VariantFunctionParsed | bool, ...] | tuple[DynamicFunctionParsed | VariantFunctionParsed | int, ...] | tuple[DynamicFunctionParsed | VariantFunctionParsed | float, ...]')¶
- class FieldLiteralValue(value: 'AllowedTypes')¶
- class FieldSchema(*, name: str, description: str = '', schema: ExtraOptionStringSchemaType | ExtraOptionBooleanSchemaType | ExtraOptionIntegerSchemaType | ExtraOptionNumberSchemaType | ExtraOptionMultiValueSchemaType, nullable: bool = False, directive_option: bool = False, allow_dynamic_functions: bool = False, allow_variant_functions: bool = False, allow_defaults: bool = False, allow_extend: bool = False, predicate_defaults: tuple[tuple[str, FieldLiteralValue | FieldFunctionArray], ...] = (), default: None | FieldLiteralValue | FieldFunctionArray = None)¶
Schema for a single field.
- Raises:
ValueError – if any of the parameters are invalid
- convert_directive_option(value: str) FieldLiteralValue | FieldFunctionArray¶
Convert a string to the correct type for this field.
- Raises:
TypeError – if value is not a string
ValueError – if value cannot be converted to the correct type
FunctionParsingException – if a dynamic function is malformed
VariantParsingException – if a variant function is malformed
- convert_or_type_check(value: Any, *, allow_coercion: bool) None | FieldLiteralValue | FieldFunctionArray¶
Convert a value to the correct type for this field, or check if it is of the correct type.
- Parameters:
value – The value to convert or check.
allow_coercion – Whether to allow coercion of string values to the correct type. This will also allow dynamic and variant functions if the field allows them.
- Returns:
True if the value is of the correct type, False otherwise.
- Raises:
ValueError – if value cannot be converted to the correct type
FunctionParsingException – if a dynamic function is malformed
VariantParsingException – if a variant function is malformed
- default: None | FieldLiteralValue | FieldFunctionArray¶
The default value for this field.
Used if the field has not been specifically set, and no predicate matches.
- predicate_defaults: tuple[tuple[str, FieldLiteralValue | FieldFunctionArray], ...]¶
List of (need filter, value) pairs for default predicate values.
Used if the field has not been specifically set.
The value from the first matching filter will be used, if any.
- class FieldsSchema¶
A schema for the fields of a single need.
- add_core_field(field: FieldSchema) None¶
Add a core field to the schema.
- Raises:
ValueError – if a field with the same name already exists
- add_extra_field(field: FieldSchema) None¶
Add an extra field to the schema.
- Raises:
ValueError – if a field with the same name already exists
- add_link_field(field: LinkSchema) None¶
Add a link field to the schema.
- Raises:
ValueError – if a field with the same name already exists
- get_any_field(name: str) FieldSchema | LinkSchema | None¶
Get a field by name.
- get_core_field(name: str) FieldSchema | None¶
Get a core field by name.
- get_extra_field(name: str) FieldSchema | None¶
Get an extra field by name.
- get_link_field(name: str) LinkSchema | None¶
Get a link field by name.
- iter_all_fields() Iterable[FieldSchema | LinkSchema]¶
Iterate over all fields in the schema.
- iter_core_fields() Iterable[FieldSchema]¶
Iterate over all core fields in the schema.
- iter_extra_fields() Iterable[FieldSchema]¶
Iterate over all extra fields in the schema.
- iter_link_fields() Iterable[LinkSchema]¶
Iterate over all link fields in the schema.
- class LinkSchema(*, name: str, description: str = '', directive_option: bool = False, allow_extend: bool = False, allow_dynamic_functions: bool = False, allow_variant_functions: bool = False, allow_defaults: bool = False, predicate_defaults: tuple[tuple[str, LinksLiteralValue | LinksFunctionArray], ...] = (), default: None | LinksLiteralValue | LinksFunctionArray = None)¶
Schema for a single link field.
- convert_directive_option(value: str) LinksLiteralValue | LinksFunctionArray¶
Convert a string to the correct type for this field.
- Raises:
TypeError – if value is not a string
ValueError – if value cannot be converted to the correct type
FunctionParsingException – if a dynamic function is malformed
VariantParsingException – if a variant function is malformed
- convert_or_type_check(value: Any, *, allow_coercion: bool) LinksLiteralValue | LinksFunctionArray¶
Convert a value to the correct type for this field, or check if it is of the correct type.
- Parameters:
value – The value to convert or check.
allow_coercion – Whether to allow coercion of string values to the correct type. This will also allow dynamic and variant functions if the field allows them.
- Returns:
True if the value is of the correct type, False otherwise.
- Raises:
ValueError – if value cannot be converted to the correct type
FunctionParsingException – if a dynamic function is malformed
VariantParsingException – if a variant function is malformed
- default: None | LinksLiteralValue | LinksFunctionArray¶
The default value for this field.
Used if the field has not been specifically set, and no predicate matches.
- predicate_defaults: tuple[tuple[str, LinksLiteralValue | LinksFunctionArray], ...]¶
List of (need filter, value) pairs for default predicate values.
Used if the field has not been specifically set.
The value from the first matching filter will be used, if any.
- class LinksFunctionArray(value: 'tuple[str | DynamicFunctionParsed | VariantFunctionParsed, ...]')¶
- class LinksLiteralValue(value: 'list[str]')¶
Types and violations for schema validation.
There are 3 places the types are used: 1. In the extra option and extra links definition. 2. For the JSON schema coming from schema_definitions and schema_definitions_from_json configs. 3. For runtime type checking of the loaded JSON schema config.
All below types have the field ‘type’ set as required field. For case 1. this is important, as it is the primar type information source and users have to provide it. For 2. and 3. it is not required. If it is not given, it is injected before the type check occurs. If it is given, the types have to match what is provided in 1.
- class ExtraOptionBooleanSchemaType¶
Boolean extra option schema.
A predefined set of truthy/falsy strings are accepted: - truthy = {“true”, “yes”, “y”, “on”, “1”} - falsy = {“false”, “no”, “n”, “off”, “0”}
For fixed values, the const field can be used. enum is not supported as const is functionally equivalent and less verbose.
- class ExtraOptionIntegerSchemaType¶
Integer extra option schema.
- class ExtraOptionMultiValueSchemaType¶
Multi value extra option such as a list of strings, integers, numbers, or booleans.
Current SN use case are tags.
- contains: NotRequired[ExtraOptionStringSchemaType | ExtraOptionBooleanSchemaType | ExtraOptionIntegerSchemaType | ExtraOptionNumberSchemaType]¶
Schema constraints for some items.
- class ExtraOptionNumberSchemaType¶
Float extra option schema.
Python reads in JSON numbers as floats. The jsonschema library handles precision issues with floats using a tolerance-based approach.