symbrim.core.requirement.RequirementBase

class symbrim.core.requirement.RequirementBase(attribute_name: str, submodel_types: type | tuple[type, ...], description: str | None = None, hard: bool = True, full_name: str | None = None, type_name: str | None = None)

Bases: ABC

Simple class containing the requirement properties.

Attributes

attribute_name

Name of the attribute that is used to store the object in the parent.

description

Description of the object.

full_name

Full name of the object.

hard

Boolean whether the requirement is a hard requirement.

type_hint

Type hint for the submodel.

type_name

Names of the supported types of the submodel.

types

Supported types of the submodel.

Methods

__init__

Initialize a new instance of the requirement.

is_satisfied_by

Check whether the object satisfies the requirement.

__init__(attribute_name: str, submodel_types: type | tuple[type, ...], description: str | None = None, hard: bool = True, full_name: str | None = None, type_name: str | None = None) None

Initialize a new instance of the requirement.

Parameters:
  • attribute_name (str) – Name of the attribute that is used to store the object in the parent.

  • submodel_types (type | tuple[type, ...]) – Supported types of the object.

  • description (str, optional) – Description of the object, by default None.

  • hard (bool, optional) – Whether the requirement is hard, i.e. the requirement should be satisfied for the model to be defined, by default True.

  • full_name (str, optional) – Full name of the object, by default capitalized version of the attribute name, where the underscores are replaced by spaces.

  • type_name (str, optional) – Names of the supported types of the object. The names of the type classes are used by default.

__repr__() str

Return repr(self).

__str__() str

Return str(self).

__weakref__

list of weak references to the object (if defined)

property attribute_name: str

Name of the attribute that is used to store the object in the parent.

property description: str

Description of the object.

property full_name: str

Full name of the object.

property hard: bool

Boolean whether the requirement is a hard requirement.

abstract is_satisfied_by(obj: object | type) bool

Check whether the object satisfies the requirement.

Parameters:

obj (object) – Object to check.

Returns:

Whether the object satisfies the requirement.

Return type:

bool

property type_hint: type

Type hint for the submodel.

property type_name: str

Names of the supported types of the submodel.

property types: tuple[type, ...]

Supported types of the submodel.