brim.core.requirement.ConnectionRequirement#

class brim.core.requirement.ConnectionRequirement(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: RequirementBase

Class representing a requirement for a connection.

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 connection 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__()#

Return repr(self).

__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.

is_satisfied_by(connection: object | type) bool#

Check whether the connection satisfies the requirement.

Parameters:

connection (Connection) – Connection to check.

Returns:

Whether the connection 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.