Skip to content

sob.properties

This module defines classes for describing properties of a model.

Property

Property(
    types: (
        sob.abc.Types
        | collections.abc.Sequence[
            type | sob.properties.Property
        ]
        | type
        | sob.properties.Property
        | sob._types.Undefined
        | None
    ) = sob._types.UNDEFINED,
    name: str | None = None,
    *,
    required: bool = False,
    versions: (
        str
        | sob.abc.Version
        | collections.abc.Iterable[str | sob.abc.Version]
        | None
    ) = None
)

Bases: sob.abc.Property

This is the base class for defining a property.

Attributes:

  • types (sob.abc.Types | None) –

    One or more types or property definitions. More than one types and/or property definitions results in a polymorphic interpretation wherein a value is un-marshalled in accordance with each type or property in the list (sequentially), until the value is un-marshalled without throwing a TypeError or ValueError. If the list of types and/or properties is exhausted without successfully un-marshalling the value, a TypeError or ValueError error is raised. When types are sub-classes of sob.Object, each type is attempted, and of the resulting instances, the type resulting in the fewest extraneous attributes (attributes not corresponding to any metadata) is used.)

  • name (str | None) –

    The name of the property when loaded from or dumped into a JSON object. Specifying a name facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility function sob.utilities.get_property_name.

  • required (bool) –

    If True, sob.validatewill raise a validation error if this property is missing (isNone`).

  • versions (collections.abc.Sequence[sob.abc.Version] | None) –

    One or more version specifiers to which this property applies.

    Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.

    Versioning can be applied to a model's properties with sob.version_model. For example, one use would be within the __init__ method of an sob.Object sub-class, in order to dynamically alter metadata based on version attributes.

Source code in src/sob/properties.py
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
def __init__(
    self,
    types: abc.Types
    | Sequence[type | Property]
    | type
    | Property
    | Undefined
    | None = UNDEFINED,
    name: str | None = None,
    *,
    required: bool = False,
    versions: str
    | abc.Version
    | Iterable[str | abc.Version]
    | None = None,
) -> None:
    self._types: abc.Types | None = type(self)._types  # noqa: SLF001
    if types is not UNDEFINED:
        self.types = types  # type: ignore
    self.name: str | None = name
    self.required: bool = required
    self._versions: Sequence[abc.Version] | None = None
    if versions is not None:
        self.versions = versions  # type: ignore

StringProperty

StringProperty(
    name: str | None = None,
    *,
    required: bool = False,
    versions: (
        str
        | sob.abc.Version
        | collections.abc.Iterable[str | sob.abc.Version]
        | None
    ) = None
)

Bases: sob.properties.Property, sob.abc.StringProperty

This class represents metadata describing a string property.

Attributes:

  • name (str | None) –

    The name of the property when loaded from or dumped into a JSON object. Specifying a name facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility function sob.utilities.get_property_name.

  • required (bool) –

    If True, sob.validatewill raise a validation error if this property is missing (isNone`).

  • versions (collections.abc.Sequence[sob.abc.Version] | None) –

    One or more version specifiers to which this property applies.

    Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.

    Versioning can be applied to a model's properties with sob.version_model. For example, one use would be within the __init__ method of an sob.Object sub-class, in order to dynamically alter metadata based on version attributes.

Source code in src/sob/properties.py
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
def __init__(
    self,
    name: str | None = None,
    *,
    required: bool = False,
    versions: str
    | abc.Version
    | Iterable[str | abc.Version]
    | None = None,
) -> None:
    super().__init__(
        name=name,
        required=required,
        versions=versions,
    )

DateProperty

DateProperty(
    name: str | None = None,
    *,
    required: bool = False,
    versions: (
        str
        | sob.abc.Version
        | collections.abc.Iterable[str | sob.abc.Version]
        | None
    ) = None,
    date2str: typing.Callable[
        [datetime.date], str
    ] = sob.properties.DateProperty._date2str,
    str2date: typing.Callable[
        [str], datetime.date
    ] = sob.properties.DateProperty._str2date
)

Bases: sob.properties.Property, sob.abc.DateProperty

This class represents metadata describing a date property.

Attributes:

  • name (str | None) –

    The name of the property when loaded from or dumped into a JSON object. Specifying a name facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility function sob.utilities.get_property_name.

  • required (bool) –

    If True, sob.validatewill raise a validation error if this property is missing (isNone`).

  • versions (collections.abc.Sequence[sob.abc.Version] | None) –

    One or more version specifiers to which this property applies.

    Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.

    Versioning can be applied to a model's properties with sob.version_model. For example, one use would be within the __init__ method of an sob.Object sub-class, in order to dynamically alter metadata based on version attributes.

Parameters:

  • name (str | None, default: None ) –
  • required (bool, default: False ) –
  • versions (str | sob.abc.Version | collections.abc.Iterable[str | sob.abc.Version] | None, default: None ) –
  • date2str (typing.Callable[[datetime.date], str], default: sob.properties.DateProperty._date2str ) –

    A function, taking one argument (a python date json_object), and returning a date string in the desired format. The default is datetime.date.isoformat —returning an ISO-8601 compliant date string.

  • str2date (typing.Callable[[str], datetime.date], default: sob.properties.DateProperty._str2date ) –

    A function, taking one argument (a date string), and returning a python date object. By default, this is iso8601.iso8601.parse_date.

Source code in src/sob/properties.py
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
def __init__(
    self,
    name: str | None = None,
    *,
    required: bool = False,
    versions: str
    | abc.Version
    | Iterable[str | abc.Version]
    | None = None,
    date2str: Callable[[date], str] = _date2str,
    str2date: Callable[[str], date] = _str2date,
) -> None:
    """
    Parameters:
        name:
        required:
        versions:
        date2str: A function, taking one argument (a python `date`
            json_object), and returning a date string in the
            desired format. The default is `datetime.date.isoformat`
            —returning an ISO-8601 compliant date string.

        str2date: A function, taking one argument (a date string), and
            returning a python `date` object. By default, this is
            `iso8601.iso8601.parse_date`.
    """
    super().__init__(
        name=name,
        required=required,
        versions=versions,
    )
    self._date2str = date2str
    self._str2date = str2date

DateTimeProperty

DateTimeProperty(
    name: str | None = None,
    *,
    required: bool = False,
    versions: (
        str
        | sob.abc.Version
        | collections.abc.Iterable[str | sob.abc.Version]
        | None
    ) = None,
    datetime2str: typing.Callable[
        [datetime.datetime], str
    ] = sob.properties.DateTimeProperty._datetime2str,
    str2datetime: typing.Callable[
        [str], datetime.datetime
    ] = sob.properties.DateTimeProperty._str2datetime
)

Bases: sob.properties.Property, sob.abc.DateTimeProperty

This class represents metadata describing a date property.

Attributes:

  • name (str | None) –

    The name of the property when loaded from or dumped into a JSON object. Specifying a name facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility function sob.utilities.get_property_name.

  • required (bool) –

    If True, sob.validatewill raise a validation error if this property is missing (isNone`).

  • versions (collections.abc.Sequence[sob.abc.Version] | None) –

    One or more version specifiers to which this property applies.

    Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.

    Versioning can be applied to a model's properties with sob.version_model. For example, one use would be within the __init__ method of an sob.Object sub-class, in order to dynamically alter metadata based on version attributes.

Parameters:

  • name (str | None, default: None ) –
  • required (bool, default: False ) –
  • versions (str | sob.abc.Version | collections.abc.Iterable[str | sob.abc.Version] | None, default: None ) –
  • datetime2str (typing.Callable[[datetime.datetime], str], default: sob.properties.DateTimeProperty._datetime2str ) –

    A function, taking one argument (a python datetime json_object), and returning a date/time string in the desired format. The default is datetime.datetime.isoformat, returning an ISO-8601 compliant date/time string.

  • str2datetime (typing.Callable[[str], datetime.datetime], default: sob.properties.DateTimeProperty._str2datetime ) –

    A function, taking one argument (a datetime string), and returning a python datetime.datetime object. By default, this is iso8601.iso8601.parse_date.

Source code in src/sob/properties.py
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
def __init__(
    self,
    name: str | None = None,
    *,
    required: bool = False,
    versions: str
    | abc.Version
    | Iterable[str | abc.Version]
    | None = None,
    datetime2str: Callable[[datetime], str] = _datetime2str,
    str2datetime: Callable[[str], datetime] = _str2datetime,
) -> None:
    """
    Parameters:
        name:
        required:
        versions:
        datetime2str: A function, taking one argument (a python `datetime`
            json_object), and returning a date/time string in the desired
            format. The default is `datetime.datetime.isoformat`,
            returning an ISO-8601 compliant date/time string.
        str2datetime: A function, taking one argument (a datetime string),
            and returning a python `datetime.datetime` object. By default,
            this is `iso8601.iso8601.parse_date`.
    """
    self._datetime2str = datetime2str
    self._str2datetime = str2datetime
    super().__init__(
        name=name,
        required=required,
        versions=versions,
    )

BytesProperty

BytesProperty(
    name: str | None = None,
    *,
    required: bool = False,
    versions: (
        str
        | sob.abc.Version
        | collections.abc.Iterable[str | sob.abc.Version]
        | None
    ) = None
)

Bases: sob.properties.Property, sob.abc.BytesProperty

This class represents metadata describing a property with binary values.

Attributes:

  • name (str | None) –

    The name of the property when loaded from or dumped into a JSON object. Specifying a name facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility function sob.utilities.get_property_name.

  • required (bool) –

    If True, sob.validatewill raise a validation error if this property is missing (isNone`).

  • versions (collections.abc.Sequence[sob.abc.Version] | None) –

    One or more version specifiers to which this property applies.

    Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.

    Versioning can be applied to a model's properties with sob.version_model. For example, one use would be within the __init__ method of an sob.Object sub-class, in order to dynamically alter metadata based on version attributes.

Source code in src/sob/properties.py
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
def __init__(
    self,
    name: str | None = None,
    *,
    required: bool = False,
    versions: str
    | abc.Version
    | Iterable[str | abc.Version]
    | None = None,
) -> None:
    super().__init__(
        name=name,
        required=required,
        versions=versions,
    )

EnumeratedProperty

EnumeratedProperty(
    types: (
        sob.abc.Types
        | collections.abc.Sequence[
            type | sob.properties.Property
        ]
        | type
        | sob.properties.Property
        | sob._types.Undefined
        | None
    ) = sob._types.UNDEFINED,
    values: (
        collections.abc.Iterable[sob.abc.MarshallableTypes]
        | None
    ) = None,
    name: str | None = None,
    *,
    required: bool = False,
    versions: (
        str
        | sob.abc.Version
        | collections.abc.Iterable[str | sob.abc.Version]
        | None
    ) = None
)

Bases: sob.properties.Property, sob.abc.EnumeratedProperty

This class represents metadata describing a property having a finite, pre-determined, set of possible values.

Attributes:

  • name (str | None) –

    The name of the property when loaded from or dumped into a JSON object. Specifying a name facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility function sob.utilities.get_property_name.

  • required (bool) –

    If True, sob.validatewill raise a validation error if this property is missing (isNone`).

  • versions (collections.abc.Sequence[sob.abc.Version] | None) –

    One or more version specifiers to which this property applies.

    Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.

    Versioning can be applied to a model's properties with sob.version_model. For example, one use would be within the __init__ method of an sob.Object sub-class, in order to dynamically alter metadata based on version attributes.

  • values (set[sob.abc.MarshallableTypes] | None) –

    All possible values for this property.

Source code in src/sob/properties.py
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
def __init__(
    self,
    types: abc.Types
    | Sequence[type | Property]
    | type
    | Property
    | Undefined
    | None = UNDEFINED,
    values: Iterable[MarshallableTypes] | None = None,
    name: str | None = None,
    *,
    required: bool = False,
    versions: str
    | abc.Version
    | Iterable[str | abc.Version]
    | None = None,
) -> None:
    self._values: set[MarshallableTypes] | None = None
    super().__init__(
        types=types, name=name, required=required, versions=versions
    )
    self.values = values  # type: ignore

NumberProperty

NumberProperty(
    name: str | None = None,
    *,
    required: bool = False,
    versions: (
        str
        | sob.abc.Version
        | collections.abc.Iterable[str | sob.abc.Version]
        | None
    ) = None
)

Bases: sob.properties.Property, sob.abc.NumberProperty

This class represents metadata describing a property having numeric (decimal, float or integer) values.

Attributes:

  • name (str | None) –

    The name of the property when loaded from or dumped into a JSON object. Specifying a name facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility function sob.utilities.get_property_name.

  • required (bool) –

    If True, sob.validatewill raise a validation error if this property is missing (isNone`).

  • versions (collections.abc.Sequence[sob.abc.Version] | None) –

    One or more version specifiers to which this property applies.

    Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.

    Versioning can be applied to a model's properties with sob.version_model. For example, one use would be within the __init__ method of an sob.Object sub-class, in order to dynamically alter metadata based on version attributes.

Source code in src/sob/properties.py
648
649
650
651
652
653
654
655
656
657
658
def __init__(
    self,
    name: str | None = None,
    *,
    required: bool = False,
    versions: str
    | abc.Version
    | Iterable[str | abc.Version]
    | None = None,
) -> None:
    super().__init__(name=name, required=required, versions=versions)

IntegerProperty

IntegerProperty(
    name: str | None = None,
    *,
    required: bool = False,
    versions: (
        str
        | sob.abc.Version
        | collections.abc.Iterable[str | sob.abc.Version]
        | None
    ) = None
)

Bases: sob.properties.Property, sob.abc.IntegerProperty

This class represents metadata describing a property having integer values.

Attributes:

  • name (str | None) –

    The name of the property when loaded from or dumped into a JSON object. Specifying a name facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility function sob.utilities.get_property_name.

  • required (bool) –

    If True, sob.validatewill raise a validation error if this property is missing (isNone`).

  • versions (collections.abc.Sequence[sob.abc.Version] | None) –

    One or more version specifiers to which this property applies.

    Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.

    Versioning can be applied to a model's properties with sob.version_model. For example, one use would be within the __init__ method of an sob.Object sub-class, in order to dynamically alter metadata based on version attributes.

Source code in src/sob/properties.py
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
def __init__(
    self,
    name: str | None = None,
    *,
    required: bool = False,
    versions: str
    | abc.Version
    | Iterable[str | abc.Version]
    | None = None,
) -> None:
    super().__init__(
        name=name,
        required=required,
        versions=versions,
    )

BooleanProperty

BooleanProperty(
    name: str | None = None,
    *,
    required: bool = False,
    versions: (
        str
        | sob.abc.Version
        | collections.abc.Iterable[str | sob.abc.Version]
        | None
    ) = None
)

Bases: sob.properties.Property, sob.abc.BooleanProperty

This class represents metadata describing a property having boolean values.

Attributes:

  • name (str | None) –

    The name of the property when loaded from or dumped into a JSON object. Specifying a name facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility function sob.utilities.get_property_name.

  • required (bool) –

    If True, sob.validatewill raise a validation error if this property is missing (isNone`).

  • versions (collections.abc.Sequence[sob.abc.Version] | None) –

    One or more version specifiers to which this property applies.

    Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.

    Versioning can be applied to a model's properties with sob.version_model. For example, one use would be within the __init__ method of an sob.Object sub-class, in order to dynamically alter metadata based on version attributes.

Source code in src/sob/properties.py
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
def __init__(
    self,
    name: str | None = None,
    *,
    required: bool = False,
    versions: str
    | abc.Version
    | Iterable[str | abc.Version]
    | None = None,
) -> None:
    super().__init__(
        name=name,
        required=required,
        versions=versions,
    )

ArrayProperty

ArrayProperty(
    item_types: (
        type
        | collections.abc.Sequence[
            type | sob.properties.Property
        ]
        | sob._types.Undefined
        | sob.abc.Types
        | None
    ) = sob._types.UNDEFINED,
    name: str | None = None,
    *,
    required: bool = False,
    versions: (
        str
        | sob.abc.Version
        | collections.abc.Iterable[str | sob.abc.Version]
        | None
    ) = None
)

Bases: sob.properties.Property, sob.abc.ArrayProperty

This class represents metadata describing a property accepting array (list/tuple) values.

Attributes:

  • name (str | None) –

    The name of the property when loaded from or dumped into a JSON object. Specifying a name facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility function sob.utilities.get_property_name.

  • required (bool) –

    If True, sob.validatewill raise a validation error if this property is missing (isNone`).

  • versions (collections.abc.Sequence[sob.abc.Version] | None) –

    One or more version specifiers to which this property applies.

    Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.

    Versioning can be applied to a model's properties with sob.version_model. For example, one use would be within the __init__ method of an sob.Object sub-class, in order to dynamically alter metadata based on version attributes.

  • item_types (sob.abc.Types | None) –

    The type(s) of values/objects contained in the array. Similar to sob.Property().types, but applied to items in the array, not the array itself.

Source code in src/sob/properties.py
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
def __init__(
    self,
    item_types: type
    | Sequence[type | Property]
    | Undefined
    | abc.Types
    | None = UNDEFINED,
    name: str | None = None,
    *,
    required: bool = False,
    versions: str
    | abc.Version
    | Iterable[str | abc.Version]
    | None = None,
) -> None:
    self._item_types: Types | None = type(self)._item_types  # noqa: SLF001
    if item_types is not UNDEFINED:
        self.item_types = item_types  # type: ignore
    super().__init__(
        name=name,
        required=required,
        versions=versions,
    )

DictionaryProperty

DictionaryProperty(
    value_types: (
        type
        | collections.abc.Sequence[
            type | sob.properties.Property
        ]
        | sob._types.Undefined
        | sob.abc.Types
        | None
    ) = sob._types.UNDEFINED,
    name: str | None = None,
    *,
    required: bool = False,
    versions: (
        str
        | sob.abc.Version
        | collections.abc.Iterable[str | sob.abc.Version]
        | None
    ) = None
)

Bases: sob.properties.Property, sob.abc.DictionaryProperty

This class represents metadata describing a property accepting dictionary values (deserialized JSON objects without a pre-determined set of properties).

Attributes:

  • name (str | None) –

    The name of the property when loaded from or dumped into a JSON object. Specifying a name facilitates mapping of PEP8 compliant property names to JSON attribute names which might be incompatible with well-formatted python code due to various reasons such as being camelCased, or being python keywords. To infer an appropriate property name programmatically, use the utility function sob.utilities.get_property_name.

  • required (bool) –

    If True, sob.validatewill raise a validation error if this property is missing (isNone`).

  • versions (collections.abc.Sequence[sob.abc.Version] | None) –

    One or more version specifiers to which this property applies.

    Version numbers prefixed by "<" indicate any version less than the one specified, so "<3.0" indicates that this property is available in versions prior to 3.0. The inverse is true for version numbers prefixed by ">". ">=" and "<=" have similar meanings, but are inclusive.

    Versioning can be applied to a model's properties with sob.version_model. For example, one use would be within the __init__ method of an sob.Object sub-class, in order to dynamically alter metadata based on version attributes.

  • value_types (sob.abc.Types | None) –

    The type(s) of values/objects comprising the mapped values. Similar to sob.Property().types, but applied to values in the mapping/dictionary, not to the dictionary itself.

Source code in src/sob/properties.py
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
def __init__(
    self,
    value_types: type
    | Sequence[type | Property]
    | Undefined
    | abc.Types
    | None = UNDEFINED,
    name: str | None = None,
    *,
    required: bool = False,
    versions: str
    | abc.Version
    | Iterable[str | abc.Version]
    | None = None,
) -> None:
    self._value_types: abc.Types | None = type(  # noqa: SLF001
        self
    )._value_types
    if value_types is not UNDEFINED:
        self.value_types = value_types  # type: ignore
    super().__init__(
        name=name,
        required=required,
        versions=versions,
    )

has_mutable_types

has_mutable_types(
    property_: sob.abc.Property | type[sob.abc.Property],
) -> bool

This function returns True if modification of the .types member of a property class or instance is permitted.

Parameters:

  • property
Source code in src/sob/properties.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def has_mutable_types(property_: abc.Property | type[abc.Property]) -> bool:
    """
    This function returns `True` if modification of the `.types` member of a
    property class or instance is permitted.

    Parameters:
        property:
    """
    property_type: type
    if isinstance(property_, abc.Property):
        property_type = type(property_)
    else:
        if not issubclass(property_, abc.Property):
            raise TypeError(property_)
        property_type = property_
    return property_type._types is None  # noqa: SLF001