Skip to content

Types

Wrapper for Notion API data types.

Similar to other records, these object provide access to the primitive data structure used in the Notion API as well as higher-level methods.

BlockRef

Bases: ParentRef

Reference a block.

Source code in src/notional/types.py
105
106
107
108
109
110
111
112
113
114
115
116
117
class BlockRef(ParentRef, type="block_id"):
    """Reference a block."""

    block_id: UUID

    @classmethod
    def __compose__(cls, block_ref):
        """Compose a BlockRef from the given reference object.

        `block_ref` can be either a string, UUID, or block.
        """
        ref = ObjectReference[block_ref]
        return BlockRef(block_id=ref.id)

__compose__(block_ref) classmethod

Compose a BlockRef from the given reference object.

block_ref can be either a string, UUID, or block.

Source code in src/notional/types.py
110
111
112
113
114
115
116
117
@classmethod
def __compose__(cls, block_ref):
    """Compose a BlockRef from the given reference object.

    `block_ref` can be either a string, UUID, or block.
    """
    ref = ObjectReference[block_ref]
    return BlockRef(block_id=ref.id)

BooleanFormula

Bases: FormulaResult

A Notion boolean formula result.

Source code in src/notional/types.py
964
965
966
967
968
969
970
971
972
class BooleanFormula(FormulaResult, type="boolean"):
    """A Notion boolean formula result."""

    boolean: Optional[bool] = None

    @property
    def Result(self):
        """Return the result of this BooleanFormula."""
        return self.boolean

Result property

Return the result of this BooleanFormula.

Checkbox

Bases: NativeTypeMixin, PropertyValue

Simple checkbox type; represented as a boolean.

Source code in src/notional/types.py
511
512
513
514
class Checkbox(NativeTypeMixin, PropertyValue, type="checkbox"):
    """Simple checkbox type; represented as a boolean."""

    checkbox: Optional[bool] = None

CreatedBy

Bases: PropertyValue

A Notion created-by property value.

Source code in src/notional/types.py
1126
1127
1128
1129
1130
1131
1132
1133
class CreatedBy(PropertyValue, type="created_by"):
    """A Notion created-by property value."""

    created_by: User

    def __str__(self):
        """Return the contents of this property as a string."""
        return str(self.created_by)

__str__()

Return the contents of this property as a string.

Source code in src/notional/types.py
1131
1132
1133
def __str__(self):
    """Return the contents of this property as a string."""
    return str(self.created_by)

CreatedTime

Bases: NativeTypeMixin, PropertyValue

A Notion created-time property value.

Source code in src/notional/types.py
1120
1121
1122
1123
class CreatedTime(NativeTypeMixin, PropertyValue, type="created_time"):
    """A Notion created-time property value."""

    created_time: datetime

DatabaseRef

Bases: ParentRef

Reference a database.

Source code in src/notional/types.py
75
76
77
78
79
80
81
82
83
84
85
86
87
class DatabaseRef(ParentRef, type="database_id"):
    """Reference a database."""

    database_id: UUID

    @classmethod
    def __compose__(cls, db_ref):
        """Compose a DatabaseRef from the given reference object.

        `db_ref` can be either a string, UUID, or database.
        """
        ref = ObjectReference[db_ref]
        return DatabaseRef(database_id=ref.id)

__compose__(db_ref) classmethod

Compose a DatabaseRef from the given reference object.

db_ref can be either a string, UUID, or database.

Source code in src/notional/types.py
80
81
82
83
84
85
86
87
@classmethod
def __compose__(cls, db_ref):
    """Compose a DatabaseRef from the given reference object.

    `db_ref` can be either a string, UUID, or database.
    """
    ref = ObjectReference[db_ref]
    return DatabaseRef(database_id=ref.id)

Date

Bases: PropertyValue

Notion complex date type - may include timestamp and/or be a date range.

Source code in src/notional/types.py
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
class Date(PropertyValue, type="date"):
    """Notion complex date type - may include timestamp and/or be a date range."""

    date: Optional[DateRange] = None

    def __contains__(self, other):
        """Determine if the given date is in the range (inclusive) of this Date.

        Raises ValueError if the Date object is not a range - e.g. has no end date.
        """

        if not self.IsRange:
            raise ValueError("This date is not a range")

        return self.Start <= other <= self.End

    def __str__(self):
        """Return a string representation of this property."""
        return "" if self.date is None else str(self.date)

    @classmethod
    def __compose__(cls, start, end=None):
        """Create a new Date from the native values."""
        return cls(date=DateRange(start=start, end=end))

    @property
    def IsRange(self):
        """Determine if this object represents a date range (versus a single date)."""

        if self.date is None:
            return False

        return self.date.end is not None

    @property
    def Start(self):
        """Return the start date of this property."""
        return None if self.date is None else self.date.start

    @property
    def End(self):
        """Return the end date of this property."""
        return None if self.date is None else self.date.end

End property

Return the end date of this property.

IsRange property

Determine if this object represents a date range (versus a single date).

Start property

Return the start date of this property.

__compose__(start, end=None) classmethod

Create a new Date from the native values.

Source code in src/notional/types.py
537
538
539
540
@classmethod
def __compose__(cls, start, end=None):
    """Create a new Date from the native values."""
    return cls(date=DateRange(start=start, end=end))

__contains__(other)

Determine if the given date is in the range (inclusive) of this Date.

Raises ValueError if the Date object is not a range - e.g. has no end date.

Source code in src/notional/types.py
522
523
524
525
526
527
528
529
530
531
def __contains__(self, other):
    """Determine if the given date is in the range (inclusive) of this Date.

    Raises ValueError if the Date object is not a range - e.g. has no end date.
    """

    if not self.IsRange:
        raise ValueError("This date is not a range")

    return self.Start <= other <= self.End

__str__()

Return a string representation of this property.

Source code in src/notional/types.py
533
534
535
def __str__(self):
    """Return a string representation of this property."""
    return "" if self.date is None else str(self.date)

DateFormula

Bases: FormulaResult

A Notion date formula result.

Source code in src/notional/types.py
953
954
955
956
957
958
959
960
961
class DateFormula(FormulaResult, type="date"):
    """A Notion date formula result."""

    date: Optional[DateRange] = None

    @property
    def Result(self):
        """Return the result of this DateFormula."""
        return self.date

Result property

Return the result of this DateFormula.

DateRange

Bases: GenericObject

A Notion date range, with an optional end date.

Source code in src/notional/types.py
195
196
197
198
199
200
201
202
203
204
205
206
207
class DateRange(GenericObject):
    """A Notion date range, with an optional end date."""

    start: Union[date, datetime]
    end: Optional[Union[date, datetime]] = None

    def __str__(self):
        """Return a string representation of this object."""

        if self.end is None:
            return f"{self.start}"

        return f"{self.start} :: {self.end}"

__str__()

Return a string representation of this object.

Source code in src/notional/types.py
201
202
203
204
205
206
207
def __str__(self):
    """Return a string representation of this object."""

    if self.end is None:
        return f"{self.start}"

    return f"{self.start} :: {self.end}"

Email

Bases: NativeTypeMixin, PropertyValue

Notion email type.

Source code in src/notional/types.py
821
822
823
824
class Email(NativeTypeMixin, PropertyValue, type="email"):
    """Notion email type."""

    email: Optional[str] = None

EmojiObject

Bases: TypedObject

A Notion emoji object.

Source code in src/notional/types.py
126
127
128
129
130
131
132
133
134
135
136
137
138
class EmojiObject(TypedObject, type="emoji"):
    """A Notion emoji object."""

    emoji: str

    def __str__(self):
        """Return this EmojiObject as a simple string."""
        return self.emoji

    @classmethod
    def __compose__(cls, emoji):
        """Compose an EmojiObject from the given emoji string."""
        return EmojiObject(emoji=emoji)

__compose__(emoji) classmethod

Compose an EmojiObject from the given emoji string.

Source code in src/notional/types.py
135
136
137
138
@classmethod
def __compose__(cls, emoji):
    """Compose an EmojiObject from the given emoji string."""
    return EmojiObject(emoji=emoji)

__str__()

Return this EmojiObject as a simple string.

Source code in src/notional/types.py
131
132
133
def __str__(self):
    """Return this EmojiObject as a simple string."""
    return self.emoji

EquationObject

Bases: RichTextObject

Notion equation element.

Source code in src/notional/types.py
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
class EquationObject(RichTextObject, type="equation"):
    """Notion equation element."""

    class _NestedData(GenericObject):
        expression: str

    equation: _NestedData

    def __str__(self):
        """Return a string representation of this object."""

        if self.equation is None:
            return None

        return self.equation.expression

__str__()

Return a string representation of this object.

Source code in src/notional/types.py
322
323
324
325
326
327
328
def __str__(self):
    """Return a string representation of this object."""

    if self.equation is None:
        return None

    return self.equation.expression

ExternalFile

Bases: FileObject

An external file object.

Source code in src/notional/types.py
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
class ExternalFile(FileObject, type="external"):
    """An external file object."""

    class _NestedData(GenericObject):
        url: str

    external: _NestedData

    def __str__(self):
        """Return a string representation of this object."""
        name = super().__str__()

        if self.external and self.external.url:
            return f"![{name}]({self.external.url})"

        return name

    @classmethod
    def __compose__(cls, url, name=None):
        """Create a new `ExternalFile` from the given URL."""
        return cls(name=name, external=cls._NestedData(url=url))

__compose__(url, name=None) classmethod

Create a new ExternalFile from the given URL.

Source code in src/notional/types.py
189
190
191
192
@classmethod
def __compose__(cls, url, name=None):
    """Create a new `ExternalFile` from the given URL."""
    return cls(name=name, external=cls._NestedData(url=url))

__str__()

Return a string representation of this object.

Source code in src/notional/types.py
180
181
182
183
184
185
186
187
def __str__(self):
    """Return a string representation of this object."""
    name = super().__str__()

    if self.external and self.external.url:
        return f"![{name}]({self.external.url})"

    return name

FileObject

Bases: TypedObject

A Notion file object.

Depending on the context, a FileObject may require a name (such as in the Files property). This makes the object hierarchy difficult, so here we simply allow name to be optional. It is the responsibility of the caller to set name if required by the API.

Source code in src/notional/types.py
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
class FileObject(TypedObject):
    """A Notion file object.

    Depending on the context, a FileObject may require a name (such as in the `Files`
    property).  This makes the object hierarchy difficult, so here we simply allow
    `name` to be optional.  It is the responsibility of the caller to set `name` if
    required by the API.
    """

    name: Optional[str] = None

    def __str__(self):
        """Return a string representation of this object."""
        return self.name or "__unknown__"

    @property
    def URL(self):
        """Return the URL to this FileObject."""
        return self("url")

URL property

Return the URL to this FileObject.

__str__()

Return a string representation of this object.

Source code in src/notional/types.py
152
153
154
def __str__(self):
    """Return a string representation of this object."""
    return self.name or "__unknown__"

Files

Bases: PropertyValue

Notion files type.

Source code in src/notional/types.py
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
class Files(PropertyValue, type="files"):
    """Notion files type."""

    files: List[FileObject] = []

    def __contains__(self, other):
        """Determine if the given FileObject or name is in the property."""

        if self.files is None:
            return False

        for ref in self.files:
            if ref == other:
                return True

            if ref.name == other:
                return True

        return False

    def __str__(self):
        """Return a string representation of this property."""
        return "; ".join([str(file) for file in self.files])

    def __iter__(self):
        """Iterate over the FileObject's in this property."""

        if self.files is None:
            return None

        return iter(self.files)

    def __len__(self):
        """Return the number of Files in this property."""

        return len(self.files)

    def __getitem__(self, name):
        """Return the FileObject with the given name."""

        if self.files is None:
            return None

        for ref in self.files:
            if ref.name == name:
                return ref

        raise AttributeError("No such file")

    def __iadd__(self, obj):
        """Append the given `FileObject` in place."""

        if obj in self:
            raise ValueError(f"Item exists: {obj}")

        self.append(obj)
        return self

    def __isub__(self, obj):
        """Remove the given `FileObject` in place."""

        if obj not in self:
            raise ValueError(f"No such item: {obj}")

        self.remove(obj)
        return self

    def append(self, obj):
        """Append the given file reference to this property.

        :param ref: the `FileObject` to be added
        """
        self.files.append(obj)

    def remove(self, obj):
        """Remove the given file reference from this property.

        :param ref: the `FileObject` to be removed
        """
        self.files.remove(obj)

__contains__(other)

Determine if the given FileObject or name is in the property.

Source code in src/notional/types.py
838
839
840
841
842
843
844
845
846
847
848
849
850
851
def __contains__(self, other):
    """Determine if the given FileObject or name is in the property."""

    if self.files is None:
        return False

    for ref in self.files:
        if ref == other:
            return True

        if ref.name == other:
            return True

    return False

__getitem__(name)

Return the FileObject with the given name.

Source code in src/notional/types.py
870
871
872
873
874
875
876
877
878
879
880
def __getitem__(self, name):
    """Return the FileObject with the given name."""

    if self.files is None:
        return None

    for ref in self.files:
        if ref.name == name:
            return ref

    raise AttributeError("No such file")

__iadd__(obj)

Append the given FileObject in place.

Source code in src/notional/types.py
882
883
884
885
886
887
888
889
def __iadd__(self, obj):
    """Append the given `FileObject` in place."""

    if obj in self:
        raise ValueError(f"Item exists: {obj}")

    self.append(obj)
    return self

__isub__(obj)

Remove the given FileObject in place.

Source code in src/notional/types.py
891
892
893
894
895
896
897
898
def __isub__(self, obj):
    """Remove the given `FileObject` in place."""

    if obj not in self:
        raise ValueError(f"No such item: {obj}")

    self.remove(obj)
    return self

__iter__()

Iterate over the FileObject's in this property.

Source code in src/notional/types.py
857
858
859
860
861
862
863
def __iter__(self):
    """Iterate over the FileObject's in this property."""

    if self.files is None:
        return None

    return iter(self.files)

__len__()

Return the number of Files in this property.

Source code in src/notional/types.py
865
866
867
868
def __len__(self):
    """Return the number of Files in this property."""

    return len(self.files)

__str__()

Return a string representation of this property.

Source code in src/notional/types.py
853
854
855
def __str__(self):
    """Return a string representation of this property."""
    return "; ".join([str(file) for file in self.files])

append(obj)

Append the given file reference to this property.

:param ref: the FileObject to be added

Source code in src/notional/types.py
900
901
902
903
904
905
def append(self, obj):
    """Append the given file reference to this property.

    :param ref: the `FileObject` to be added
    """
    self.files.append(obj)

remove(obj)

Remove the given file reference from this property.

:param ref: the FileObject to be removed

Source code in src/notional/types.py
907
908
909
910
911
912
def remove(self, obj):
    """Remove the given file reference from this property.

    :param ref: the `FileObject` to be removed
    """
    self.files.remove(obj)

Formula

Bases: PropertyValue

A Notion formula property value.

Source code in src/notional/types.py
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
class Formula(PropertyValue, type="formula"):
    """A Notion formula property value."""

    formula: Optional[FormulaResult] = None

    def __str__(self):
        """Return the result of this formula as a string."""
        return str(self.Result or "")

    @property
    def Result(self):
        """Return the result of this Formula in its native type."""

        if self.formula is None:
            return None

        return self.formula.Result

Result property

Return the result of this Formula in its native type.

__str__()

Return the result of this formula as a string.

Source code in src/notional/types.py
980
981
982
def __str__(self):
    """Return the result of this formula as a string."""
    return str(self.Result or "")

FormulaResult

Bases: TypedObject

A Notion formula result.

This object contains the result of the expression in the database properties.

Source code in src/notional/types.py
915
916
917
918
919
920
921
922
923
924
925
926
927
928
class FormulaResult(TypedObject):
    """A Notion formula result.

    This object contains the result of the expression in the database properties.
    """

    def __str__(self):
        """Return the formula result as a string."""
        return self.Result or ""

    @property
    def Result(self):
        """Return the result of this FormulaResult."""
        raise NotImplementedError("Result unavailable")

Result property

Return the result of this FormulaResult.

__str__()

Return the formula result as a string.

Source code in src/notional/types.py
921
922
923
def __str__(self):
    """Return the formula result as a string."""
    return self.Result or ""

HostedFile

Bases: FileObject

A Notion file object.

Source code in src/notional/types.py
162
163
164
165
166
167
168
169
class HostedFile(FileObject, type="file"):
    """A Notion file object."""

    class _NestedData(GenericObject):
        url: str
        expiry_time: Optional[datetime] = None

    file: _NestedData

LastEditedBy

Bases: PropertyValue

A Notion last-edited-by property value.

Source code in src/notional/types.py
1142
1143
1144
1145
1146
1147
1148
1149
class LastEditedBy(PropertyValue, type="last_edited_by"):
    """A Notion last-edited-by property value."""

    last_edited_by: User

    def __str__(self):
        """Return the contents of this property as a string."""
        return str(self.last_edited_by)

__str__()

Return the contents of this property as a string.

Source code in src/notional/types.py
1147
1148
1149
def __str__(self):
    """Return the contents of this property as a string."""
    return str(self.last_edited_by)

LastEditedTime

Bases: NativeTypeMixin, PropertyValue

A Notion last-edited-time property value.

Source code in src/notional/types.py
1136
1137
1138
1139
class LastEditedTime(NativeTypeMixin, PropertyValue, type="last_edited_time"):
    """A Notion last-edited-time property value."""

    last_edited_time: datetime

MentionData

Bases: TypedObject

Base class for typed Mention data objects.

Source code in src/notional/types.py
210
211
class MentionData(TypedObject):
    """Base class for typed `Mention` data objects."""

MentionDatabase

Bases: MentionData

Nested database information for Mention properties.

Source code in src/notional/types.py
244
245
246
247
248
249
250
251
252
253
254
255
class MentionDatabase(MentionData, type="database"):
    """Nested database information for `Mention` properties."""

    database: ObjectReference

    @classmethod
    def __compose__(cls, page):
        """Build a `Mention` object for the specified database reference."""

        ref = ObjectReference[page]

        return MentionObject(plain_text=str(ref), mention=MentionDatabase(database=ref))

__compose__(page) classmethod

Build a Mention object for the specified database reference.

Source code in src/notional/types.py
249
250
251
252
253
254
255
@classmethod
def __compose__(cls, page):
    """Build a `Mention` object for the specified database reference."""

    ref = ObjectReference[page]

    return MentionObject(plain_text=str(ref), mention=MentionDatabase(database=ref))

MentionDate

Bases: MentionData

Nested date data for Mention properties.

Source code in src/notional/types.py
258
259
260
261
262
263
264
265
266
267
268
269
270
271
class MentionDate(MentionData, type="date"):
    """Nested date data for `Mention` properties."""

    date: DateRange

    @classmethod
    def __compose__(cls, start, end=None):
        """Build a `Mention` object for the specified URL."""

        date_obj = DateRange(start=start, end=end)

        return MentionObject(
            plain_text=str(date_obj), mention=MentionDate(date=date_obj)
        )

__compose__(start, end=None) classmethod

Build a Mention object for the specified URL.

Source code in src/notional/types.py
263
264
265
266
267
268
269
270
271
@classmethod
def __compose__(cls, start, end=None):
    """Build a `Mention` object for the specified URL."""

    date_obj = DateRange(start=start, end=end)

    return MentionObject(
        plain_text=str(date_obj), mention=MentionDate(date=date_obj)
    )

MentionLinkPreview

Bases: MentionData

Nested url data for Mention properties.

These objects cannot be created via the API.

Source code in src/notional/types.py
274
275
276
277
278
279
280
281
282
283
class MentionLinkPreview(MentionData, type="link_preview"):
    """Nested url data for `Mention` properties.

    These objects cannot be created via the API.
    """

    class _NestedData(GenericObject):
        url: str

    link_preview: _NestedData

MentionObject

Bases: RichTextObject

Notion mention element.

Source code in src/notional/types.py
308
309
310
311
class MentionObject(RichTextObject, type="mention"):
    """Notion mention element."""

    mention: MentionData

MentionPage

Bases: MentionData

Nested page data for Mention properties.

Source code in src/notional/types.py
230
231
232
233
234
235
236
237
238
239
240
241
class MentionPage(MentionData, type="page"):
    """Nested page data for `Mention` properties."""

    page: ObjectReference

    @classmethod
    def __compose__(cls, page_ref):
        """Build a `Mention` object for the specified page reference."""

        ref = ObjectReference[page_ref]

        return MentionObject(plain_text=str(ref), mention=MentionPage(page=ref))

__compose__(page_ref) classmethod

Build a Mention object for the specified page reference.

Source code in src/notional/types.py
235
236
237
238
239
240
241
@classmethod
def __compose__(cls, page_ref):
    """Build a `Mention` object for the specified page reference."""

    ref = ObjectReference[page_ref]

    return MentionObject(plain_text=str(ref), mention=MentionPage(page=ref))

MentionTemplate

Bases: MentionData

Nested template data for Mention properties.

Source code in src/notional/types.py
302
303
304
305
class MentionTemplate(MentionData, type="template_mention"):
    """Nested template data for `Mention` properties."""

    template_mention: MentionTemplateData

MentionTemplateData

Bases: TypedObject

Nested template data for Mention properties.

Source code in src/notional/types.py
286
287
class MentionTemplateData(TypedObject):
    """Nested template data for `Mention` properties."""

MentionTemplateDate

Bases: MentionTemplateData

Nested date template data for Mention properties.

Source code in src/notional/types.py
290
291
292
293
class MentionTemplateDate(MentionTemplateData, type="template_mention_date"):
    """Nested date template data for `Mention` properties."""

    template_mention_date: str

MentionTemplateUser

Bases: MentionTemplateData

Nested user template data for Mention properties.

Source code in src/notional/types.py
296
297
298
299
class MentionTemplateUser(MentionTemplateData, type="template_mention_user"):
    """Nested user template data for `Mention` properties."""

    template_mention_user: str

MentionUser

Bases: MentionData

Nested user data for Mention properties.

Source code in src/notional/types.py
214
215
216
217
218
219
220
221
222
223
224
225
226
227
class MentionUser(MentionData, type="user"):
    """Nested user data for `Mention` properties."""

    user: User

    @classmethod
    def __compose__(cls, user: User):
        """Build a `Mention` object for the specified user.

        The `id` field must be set for the given User.  Other fields may cause errors
        if they do not match the specific type returned from the API.
        """

        return MentionObject(plain_text=str(user), mention=MentionUser(user=user))

__compose__(user) classmethod

Build a Mention object for the specified user.

The id field must be set for the given User. Other fields may cause errors if they do not match the specific type returned from the API.

Source code in src/notional/types.py
219
220
221
222
223
224
225
226
227
@classmethod
def __compose__(cls, user: User):
    """Build a `Mention` object for the specified user.

    The `id` field must be set for the given User.  Other fields may cause errors
    if they do not match the specific type returned from the API.
    """

    return MentionObject(plain_text=str(user), mention=MentionUser(user=user))

MultiSelect

Bases: PropertyValue

Notion multi-select type.

Source code in src/notional/types.py
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
class MultiSelect(PropertyValue, type="multi_select"):
    """Notion multi-select type."""

    multi_select: List[SelectValue] = []

    def __str__(self):
        """Return a string representation of this property."""
        return ", ".join(self.Values)

    def __len__(self):
        """Count the number of selected values."""
        return len(self.multi_select)

    def __getitem__(self, index):
        """Return the SelectValue object at the given index."""

        if self.multi_select is None:
            raise IndexError("empty property")

        if index > len(self.multi_select):
            raise IndexError("index out of range")

        return self.multi_select[index]

    def __iadd__(self, other):
        """Add the given option to this MultiSelect."""

        if other in self:
            raise ValueError(f"Duplicate item: {other}")

        self.append(other)

        return self

    def __isub__(self, other):
        """Remove the given value from this MultiSelect."""

        if other not in self:
            raise ValueError(f"No such item: {other}")

        self.remove(other)

        return self

    def __contains__(self, name):
        """Determine if the given name is in this MultiSelect.

        To avoid confusion, only names are considered for comparison, not ID's.
        """

        for opt in self.multi_select:
            if opt.name == name:
                return True

        return False

    def __iter__(self):
        """Iterate over the SelectValue's in this property."""

        if self.multi_select is None:
            return None

        return iter(self.multi_select)

    @classmethod
    def __compose__(cls, *values):
        """Initialize a new MultiSelect from the given value(s)."""
        select = [SelectValue[value] for value in values if value is not None]

        return cls(multi_select=select)

    def append(self, *values):
        """Add selected values to this MultiSelect."""

        for value in values:
            if value is None:
                raise ValueError("'None' is an invalid value")

            if value not in self:
                self.multi_select.append(SelectValue[value])

    def remove(self, *values):
        """Remove selected values from this MultiSelect."""

        self.multi_select = [opt for opt in self.multi_select if opt.name not in values]

    @property
    def Values(self):
        """Return the names of each value in this MultiSelect as a list."""

        if self.multi_select is None:
            return None

        return [str(val) for val in self.multi_select if val.name is not None]

Values property

Return the names of each value in this MultiSelect as a list.

__compose__(*values) classmethod

Initialize a new MultiSelect from the given value(s).

Source code in src/notional/types.py
734
735
736
737
738
739
@classmethod
def __compose__(cls, *values):
    """Initialize a new MultiSelect from the given value(s)."""
    select = [SelectValue[value] for value in values if value is not None]

    return cls(multi_select=select)

__contains__(name)

Determine if the given name is in this MultiSelect.

To avoid confusion, only names are considered for comparison, not ID's.

Source code in src/notional/types.py
714
715
716
717
718
719
720
721
722
723
724
def __contains__(self, name):
    """Determine if the given name is in this MultiSelect.

    To avoid confusion, only names are considered for comparison, not ID's.
    """

    for opt in self.multi_select:
        if opt.name == name:
            return True

    return False

__getitem__(index)

Return the SelectValue object at the given index.

Source code in src/notional/types.py
683
684
685
686
687
688
689
690
691
692
def __getitem__(self, index):
    """Return the SelectValue object at the given index."""

    if self.multi_select is None:
        raise IndexError("empty property")

    if index > len(self.multi_select):
        raise IndexError("index out of range")

    return self.multi_select[index]

__iadd__(other)

Add the given option to this MultiSelect.

Source code in src/notional/types.py
694
695
696
697
698
699
700
701
702
def __iadd__(self, other):
    """Add the given option to this MultiSelect."""

    if other in self:
        raise ValueError(f"Duplicate item: {other}")

    self.append(other)

    return self

__isub__(other)

Remove the given value from this MultiSelect.

Source code in src/notional/types.py
704
705
706
707
708
709
710
711
712
def __isub__(self, other):
    """Remove the given value from this MultiSelect."""

    if other not in self:
        raise ValueError(f"No such item: {other}")

    self.remove(other)

    return self

__iter__()

Iterate over the SelectValue's in this property.

Source code in src/notional/types.py
726
727
728
729
730
731
732
def __iter__(self):
    """Iterate over the SelectValue's in this property."""

    if self.multi_select is None:
        return None

    return iter(self.multi_select)

__len__()

Count the number of selected values.

Source code in src/notional/types.py
679
680
681
def __len__(self):
    """Count the number of selected values."""
    return len(self.multi_select)

__str__()

Return a string representation of this property.

Source code in src/notional/types.py
675
676
677
def __str__(self):
    """Return a string representation of this property."""
    return ", ".join(self.Values)

append(*values)

Add selected values to this MultiSelect.

Source code in src/notional/types.py
741
742
743
744
745
746
747
748
749
def append(self, *values):
    """Add selected values to this MultiSelect."""

    for value in values:
        if value is None:
            raise ValueError("'None' is an invalid value")

        if value not in self:
            self.multi_select.append(SelectValue[value])

remove(*values)

Remove selected values from this MultiSelect.

Source code in src/notional/types.py
751
752
753
754
def remove(self, *values):
    """Remove selected values from this MultiSelect."""

    self.multi_select = [opt for opt in self.multi_select if opt.name not in values]

NativeTypeMixin

Mixin class for properties that can be represented as native Python types.

Source code in src/notional/types.py
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
class NativeTypeMixin:
    """Mixin class for properties that can be represented as native Python types."""

    def __str__(self):
        """Return a string representation of this object."""

        value = self.Value

        if value is None:
            return ""

        return str(value)

    def __eq__(self, other):
        """Determine if this property is equal to the given object."""

        # if `other` is a NativeTypeMixin, this comparrison will call __eq__ on that
        # object using this objects `Value` as the value for `other` (allowing callers
        # to compare using either native types or NativeTypeMixin's)

        return other == self.Value

    def __ne__(self, other):
        """Determine if this property is not equal to the given object."""
        return not self.__eq__(other)

    @classmethod
    def __compose__(cls, value):
        """Build the property value from the native Python value."""

        # use type-name field to instantiate the class when possible
        if hasattr(cls, "type"):
            return cls(**{cls.type: value})

        raise NotImplementedError()

    @property
    def Value(self):
        """Get the current value of this property as a native Python type."""

        cls = self.__class__

        # check to see if the object has a field with the type-name
        # (this is assigned by TypedObject during subclass creation)
        if hasattr(cls, "type") and hasattr(self, cls.type):
            return getattr(self, cls.type)

        raise NotImplementedError()

Value property

Get the current value of this property as a native Python type.

__compose__(value) classmethod

Build the property value from the native Python value.

Source code in src/notional/types.py
357
358
359
360
361
362
363
364
365
@classmethod
def __compose__(cls, value):
    """Build the property value from the native Python value."""

    # use type-name field to instantiate the class when possible
    if hasattr(cls, "type"):
        return cls(**{cls.type: value})

    raise NotImplementedError()

__eq__(other)

Determine if this property is equal to the given object.

Source code in src/notional/types.py
344
345
346
347
348
349
350
351
def __eq__(self, other):
    """Determine if this property is equal to the given object."""

    # if `other` is a NativeTypeMixin, this comparrison will call __eq__ on that
    # object using this objects `Value` as the value for `other` (allowing callers
    # to compare using either native types or NativeTypeMixin's)

    return other == self.Value

__ne__(other)

Determine if this property is not equal to the given object.

Source code in src/notional/types.py
353
354
355
def __ne__(self, other):
    """Determine if this property is not equal to the given object."""
    return not self.__eq__(other)

__str__()

Return a string representation of this object.

Source code in src/notional/types.py
334
335
336
337
338
339
340
341
342
def __str__(self):
    """Return a string representation of this object."""

    value = self.Value

    if value is None:
        return ""

    return str(value)

Number

Bases: NativeTypeMixin, PropertyValue

Simple number type.

Source code in src/notional/types.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
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
class Number(NativeTypeMixin, PropertyValue, type="number"):
    """Simple number type."""

    number: Optional[Union[float, int]] = None

    def __float__(self):
        """Return the Number as a `float`."""

        if self.number is None:
            raise ValueError("Cannot convert 'None' to float")

        return float(self.number)

    def __int__(self):
        """Return the Number as an `int`."""

        if self.number is None:
            raise ValueError("Cannot convert 'None' to int")

        return int(self.number)

    def __iadd__(self, other):
        """Add the given value to this Number."""

        if isinstance(other, Number):
            self.number += other.Value
        else:
            self.number += other

        return self

    def __isub__(self, other):
        """Subtract the given value from this Number."""

        if isinstance(other, Number):
            self.number -= other.Value
        else:
            self.number -= other

        return self

    def __add__(self, other):
        """Add the value of `other` and returns the result as a Number."""
        return Number[other + self.Value]

    def __sub__(self, other):
        """Subtract the value of `other` and returns the result as a Number."""
        return Number[self.Value - float(other)]

    def __mul__(self, other):
        """Multiply the value of `other` and returns the result as a Number."""
        return Number[other * self.Value]

    def __le__(self, other):
        """Return `True` if this `Number` is less-than-or-equal-to `other`."""
        return self < other or self == other

    def __lt__(self, other):
        """Return `True` if this `Number` is less-than `other`."""
        return other > self.Value

    def __ge__(self, other):
        """Return `True` if this `Number` is greater-than-or-equal-to `other`."""
        return self > other or self == other

    def __gt__(self, other):
        """Return `True` if this `Number` is greater-than `other`."""
        return other < self.Value

    @property
    def Value(self):
        """Get the current value of this property as a native Python number."""
        return self.number

Value property

Get the current value of this property as a native Python number.

__add__(other)

Add the value of other and returns the result as a Number.

Source code in src/notional/types.py
477
478
479
def __add__(self, other):
    """Add the value of `other` and returns the result as a Number."""
    return Number[other + self.Value]

__float__()

Return the Number as a float.

Source code in src/notional/types.py
441
442
443
444
445
446
447
def __float__(self):
    """Return the Number as a `float`."""

    if self.number is None:
        raise ValueError("Cannot convert 'None' to float")

    return float(self.number)

__ge__(other)

Return True if this Number is greater-than-or-equal-to other.

Source code in src/notional/types.py
497
498
499
def __ge__(self, other):
    """Return `True` if this `Number` is greater-than-or-equal-to `other`."""
    return self > other or self == other

__gt__(other)

Return True if this Number is greater-than other.

Source code in src/notional/types.py
501
502
503
def __gt__(self, other):
    """Return `True` if this `Number` is greater-than `other`."""
    return other < self.Value

__iadd__(other)

Add the given value to this Number.

Source code in src/notional/types.py
457
458
459
460
461
462
463
464
465
def __iadd__(self, other):
    """Add the given value to this Number."""

    if isinstance(other, Number):
        self.number += other.Value
    else:
        self.number += other

    return self

__int__()

Return the Number as an int.

Source code in src/notional/types.py
449
450
451
452
453
454
455
def __int__(self):
    """Return the Number as an `int`."""

    if self.number is None:
        raise ValueError("Cannot convert 'None' to int")

    return int(self.number)

__isub__(other)

Subtract the given value from this Number.

Source code in src/notional/types.py
467
468
469
470
471
472
473
474
475
def __isub__(self, other):
    """Subtract the given value from this Number."""

    if isinstance(other, Number):
        self.number -= other.Value
    else:
        self.number -= other

    return self

__le__(other)

Return True if this Number is less-than-or-equal-to other.

Source code in src/notional/types.py
489
490
491
def __le__(self, other):
    """Return `True` if this `Number` is less-than-or-equal-to `other`."""
    return self < other or self == other

__lt__(other)

Return True if this Number is less-than other.

Source code in src/notional/types.py
493
494
495
def __lt__(self, other):
    """Return `True` if this `Number` is less-than `other`."""
    return other > self.Value

__mul__(other)

Multiply the value of other and returns the result as a Number.

Source code in src/notional/types.py
485
486
487
def __mul__(self, other):
    """Multiply the value of `other` and returns the result as a Number."""
    return Number[other * self.Value]

__sub__(other)

Subtract the value of other and returns the result as a Number.

Source code in src/notional/types.py
481
482
483
def __sub__(self, other):
    """Subtract the value of `other` and returns the result as a Number."""
    return Number[self.Value - float(other)]

NumberFormula

Bases: FormulaResult

A Notion number formula result.

Source code in src/notional/types.py
942
943
944
945
946
947
948
949
950
class NumberFormula(FormulaResult, type="number"):
    """A Notion number formula result."""

    number: Optional[Union[float, int]] = None

    @property
    def Result(self):
        """Return the result of this NumberFormula."""
        return self.number

Result property

Return the result of this NumberFormula.

ObjectReference

Bases: GenericObject

A general-purpose object reference in the Notion API.

Source code in src/notional/types.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class ObjectReference(GenericObject):
    """A general-purpose object reference in the Notion API."""

    id: UUID

    @classmethod
    def __compose__(cls, ref):
        """Compose an ObjectReference from the given reference.

        `ref` may be a `UUID`, `str`, `ParentRef` or `GenericObject` with an `id`.

        Strings may be either UUID's or URL's to Notion content.
        """

        if isinstance(ref, cls):
            return ref.copy(deep=True)

        if isinstance(ref, ParentRef):
            # ParentRef's are typed-objects with a nested UUID
            return ObjectReference(id=ref())

        if isinstance(ref, GenericObject) and hasattr(ref, "id"):
            # re-compose the ObjectReference from the internal ID
            return ObjectReference[ref.id]

        if isinstance(ref, UUID):
            return ObjectReference(id=ref)

        if isinstance(ref, str):
            ref = util.extract_id_from_string(ref)

            if ref is not None:
                return ObjectReference(id=UUID(ref))

        raise ValueError("Unrecognized 'ref' attribute")

    @property
    def URL(self):
        """Return the Notion URL for this object reference.

        Note: this is a convenience property only.  It does not guarantee that the
        URL exists or that it is accessible by the integration.
        """
        return helpers.get_url(self.id)

URL property

Return the Notion URL for this object reference.

Note: this is a convenience property only. It does not guarantee that the URL exists or that it is accessible by the integration.

__compose__(ref) classmethod

Compose an ObjectReference from the given reference.

ref may be a UUID, str, ParentRef or GenericObject with an id.

Strings may be either UUID's or URL's to Notion content.

Source code in src/notional/types.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@classmethod
def __compose__(cls, ref):
    """Compose an ObjectReference from the given reference.

    `ref` may be a `UUID`, `str`, `ParentRef` or `GenericObject` with an `id`.

    Strings may be either UUID's or URL's to Notion content.
    """

    if isinstance(ref, cls):
        return ref.copy(deep=True)

    if isinstance(ref, ParentRef):
        # ParentRef's are typed-objects with a nested UUID
        return ObjectReference(id=ref())

    if isinstance(ref, GenericObject) and hasattr(ref, "id"):
        # re-compose the ObjectReference from the internal ID
        return ObjectReference[ref.id]

    if isinstance(ref, UUID):
        return ObjectReference(id=ref)

    if isinstance(ref, str):
        ref = util.extract_id_from_string(ref)

        if ref is not None:
            return ObjectReference(id=UUID(ref))

    raise ValueError("Unrecognized 'ref' attribute")

PageRef

Bases: ParentRef

Reference a page.

Source code in src/notional/types.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
class PageRef(ParentRef, type="page_id"):
    """Reference a page."""

    page_id: UUID

    @classmethod
    def __compose__(cls, page_ref):
        """Compose a PageRef from the given reference object.

        `page_ref` can be either a string, UUID, or page.
        """
        ref = ObjectReference[page_ref]
        return PageRef(page_id=ref.id)

__compose__(page_ref) classmethod

Compose a PageRef from the given reference object.

page_ref can be either a string, UUID, or page.

Source code in src/notional/types.py
 95
 96
 97
 98
 99
100
101
102
@classmethod
def __compose__(cls, page_ref):
    """Compose a PageRef from the given reference object.

    `page_ref` can be either a string, UUID, or page.
    """
    ref = ObjectReference[page_ref]
    return PageRef(page_id=ref.id)

ParentRef

Bases: TypedObject

Reference another block as a parent.

Source code in src/notional/types.py
68
69
class ParentRef(TypedObject):
    """Reference another block as a parent."""

People

Bases: PropertyValue

Notion people type.

Source code in src/notional/types.py
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
class People(PropertyValue, type="people"):
    """Notion people type."""

    people: List[User] = []

    def __iter__(self):
        """Iterate over the User's in this property."""

        if self.people is None:
            return None

        return iter(self.people)

    def __contains__(self, other):
        """Determine if the given User or name is in this People.

        To avoid confusion, only names are considered for comparison (not ID's).
        """

        for user in self.people:
            if user == other:
                return True

            if user.name == other:
                return True

        return False

    def __len__(self):
        """Return the number of People in this property."""

        return len(self.people)

    def __getitem__(self, index):
        """Return the People object at the given index."""

        if self.people is None:
            raise IndexError("empty property")

        if index > len(self.people):
            raise IndexError("index out of range")

        return self.people[index]

    def __str__(self):
        """Return a string representation of this property."""
        return ", ".join([str(user) for user in self.people])

__contains__(other)

Determine if the given User or name is in this People.

To avoid confusion, only names are considered for comparison (not ID's).

Source code in src/notional/types.py
779
780
781
782
783
784
785
786
787
788
789
790
791
792
def __contains__(self, other):
    """Determine if the given User or name is in this People.

    To avoid confusion, only names are considered for comparison (not ID's).
    """

    for user in self.people:
        if user == other:
            return True

        if user.name == other:
            return True

    return False

__getitem__(index)

Return the People object at the given index.

Source code in src/notional/types.py
799
800
801
802
803
804
805
806
807
808
def __getitem__(self, index):
    """Return the People object at the given index."""

    if self.people is None:
        raise IndexError("empty property")

    if index > len(self.people):
        raise IndexError("index out of range")

    return self.people[index]

__iter__()

Iterate over the User's in this property.

Source code in src/notional/types.py
771
772
773
774
775
776
777
def __iter__(self):
    """Iterate over the User's in this property."""

    if self.people is None:
        return None

    return iter(self.people)

__len__()

Return the number of People in this property.

Source code in src/notional/types.py
794
795
796
797
def __len__(self):
    """Return the number of People in this property."""

    return len(self.people)

__str__()

Return a string representation of this property.

Source code in src/notional/types.py
810
811
812
def __str__(self):
    """Return a string representation of this property."""
    return ", ".join([str(user) for user in self.people])

PhoneNumber

Bases: NativeTypeMixin, PropertyValue

Notion phone type.

Source code in src/notional/types.py
827
828
829
830
class PhoneNumber(NativeTypeMixin, PropertyValue, type="phone_number"):
    """Notion phone type."""

    phone_number: Optional[str] = None

PropertyItem

Bases: PropertyValue, NotionObject

A PropertyItem returned by the Notion API.

Basic property items have a similar schema to corresponding property values. As a result, these items share the PropertyValue type definitions.

This class provides a placeholder for parsing property items, however objects parse by this class will likely be PropertyValue's instead.

Source code in src/notional/types.py
1153
1154
1155
1156
1157
1158
1159
1160
1161
class PropertyItem(PropertyValue, NotionObject, object="property_item"):
    """A `PropertyItem` returned by the Notion API.

    Basic property items have a similar schema to corresponding property values.  As a
    result, these items share the `PropertyValue` type definitions.

    This class provides a placeholder for parsing property items, however objects
    parse by this class will likely be `PropertyValue`'s instead.
    """

PropertyValue

Bases: TypedObject

Base class for Notion property values.

Source code in src/notional/types.py
381
382
383
384
class PropertyValue(TypedObject):
    """Base class for Notion property values."""

    id: Optional[str] = None

Relation

Bases: PropertyValue

A Notion relation property value.

Source code in src/notional/types.py
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
class Relation(PropertyValue, type="relation"):
    """A Notion relation property value."""

    relation: List[ObjectReference] = []
    has_more: bool = False

    @classmethod
    def __compose__(cls, *pages):
        """Return a `Relation` property with the specified pages."""
        return cls(relation=[ObjectReference[page] for page in pages])

    def __contains__(self, page):
        """Determine if the given page is in this Relation."""
        return ObjectReference[page] in self.relation

    def __iter__(self):
        """Iterate over the ObjectReference's in this property."""

        if self.relation is None:
            return None

        return iter(self.relation)

    def __len__(self):
        """Return the number of ObjectReference's in this property."""

        return len(self.relation)

    def __getitem__(self, index):
        """Return the ObjectReference object at the given index."""

        if self.relation is None:
            raise IndexError("empty property")

        if index > len(self.relation):
            raise IndexError("index out of range")

        return self.relation[index]

    def __iadd__(self, page):
        """Add the given page to this Relation in place."""

        ref = ObjectReference[page]

        if ref in self.relation:
            raise ValueError(f"Duplicate item: {ref.id}")

        self.relation.append(ref)

        return self

    def __isub__(self, page):
        """Remove the given page from this Relation in place."""

        ref = ObjectReference[page]

        if ref in self.relation:
            raise ValueError(f"No such item: {ref.id}")

        self.relation.remove(ref)

        return self

__compose__(*pages) classmethod

Return a Relation property with the specified pages.

Source code in src/notional/types.py
1000
1001
1002
1003
@classmethod
def __compose__(cls, *pages):
    """Return a `Relation` property with the specified pages."""
    return cls(relation=[ObjectReference[page] for page in pages])

__contains__(page)

Determine if the given page is in this Relation.

Source code in src/notional/types.py
1005
1006
1007
def __contains__(self, page):
    """Determine if the given page is in this Relation."""
    return ObjectReference[page] in self.relation

__getitem__(index)

Return the ObjectReference object at the given index.

Source code in src/notional/types.py
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
def __getitem__(self, index):
    """Return the ObjectReference object at the given index."""

    if self.relation is None:
        raise IndexError("empty property")

    if index > len(self.relation):
        raise IndexError("index out of range")

    return self.relation[index]

__iadd__(page)

Add the given page to this Relation in place.

Source code in src/notional/types.py
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
def __iadd__(self, page):
    """Add the given page to this Relation in place."""

    ref = ObjectReference[page]

    if ref in self.relation:
        raise ValueError(f"Duplicate item: {ref.id}")

    self.relation.append(ref)

    return self

__isub__(page)

Remove the given page from this Relation in place.

Source code in src/notional/types.py
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
def __isub__(self, page):
    """Remove the given page from this Relation in place."""

    ref = ObjectReference[page]

    if ref in self.relation:
        raise ValueError(f"No such item: {ref.id}")

    self.relation.remove(ref)

    return self

__iter__()

Iterate over the ObjectReference's in this property.

Source code in src/notional/types.py
1009
1010
1011
1012
1013
1014
1015
def __iter__(self):
    """Iterate over the ObjectReference's in this property."""

    if self.relation is None:
        return None

    return iter(self.relation)

__len__()

Return the number of ObjectReference's in this property.

Source code in src/notional/types.py
1017
1018
1019
1020
def __len__(self):
    """Return the number of ObjectReference's in this property."""

    return len(self.relation)

RichText

Bases: NativeTypeMixin, PropertyValue

Notion rich text type.

Source code in src/notional/types.py
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
class RichText(NativeTypeMixin, PropertyValue, type="rich_text"):
    """Notion rich text type."""

    rich_text: List[RichTextObject] = []

    def __len__(self):
        """Return the number of object in the RichText object."""
        return len(self.rich_text)

    @classmethod
    def __compose__(cls, *text):
        """Create a new `RichText` property from the given strings."""
        return cls(rich_text=rich_text(*text))

    @property
    def Value(self):
        """Return the plain text from this RichText."""

        if self.rich_text is None:
            return None

        return plain_text(*self.rich_text)

Value property

Return the plain text from this RichText.

__compose__(*text) classmethod

Create a new RichText property from the given strings.

Source code in src/notional/types.py
421
422
423
424
@classmethod
def __compose__(cls, *text):
    """Create a new `RichText` property from the given strings."""
    return cls(rich_text=rich_text(*text))

__len__()

Return the number of object in the RichText object.

Source code in src/notional/types.py
417
418
419
def __len__(self):
    """Return the number of object in the RichText object."""
    return len(self.rich_text)

Rollup

Bases: PropertyValue

A Notion rollup property value.

Source code in src/notional/types.py
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
class Rollup(PropertyValue, type="rollup"):
    """A Notion rollup property value."""

    rollup: Optional[RollupObject] = None

    def __str__(self):
        """Return a string representation of this Rollup property."""

        if self.rollup is None:
            return ""

        value = self.rollup.Value
        if value is None:
            return ""

        return str(value)

__str__()

Return a string representation of this Rollup property.

Source code in src/notional/types.py
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
def __str__(self):
    """Return a string representation of this Rollup property."""

    if self.rollup is None:
        return ""

    value = self.rollup.Value
    if value is None:
        return ""

    return str(value)

RollupArray

Bases: RollupObject

A Notion rollup array property value.

Source code in src/notional/types.py
1091
1092
1093
1094
1095
1096
1097
1098
1099
class RollupArray(RollupObject, type="array"):
    """A Notion rollup array property value."""

    array: List[PropertyValue]

    @property
    def Value(self):
        """Return the native representation of this Rollup object."""
        return self.array

Value property

Return the native representation of this Rollup object.

RollupDate

Bases: RollupObject

A Notion rollup date property value.

Source code in src/notional/types.py
1080
1081
1082
1083
1084
1085
1086
1087
1088
class RollupDate(RollupObject, type="date"):
    """A Notion rollup date property value."""

    date: Optional[DateRange] = None

    @property
    def Value(self):
        """Return the native representation of this Rollup object."""
        return self.date

Value property

Return the native representation of this Rollup object.

RollupNumber

Bases: RollupObject

A Notion rollup number property value.

Source code in src/notional/types.py
1069
1070
1071
1072
1073
1074
1075
1076
1077
class RollupNumber(RollupObject, type="number"):
    """A Notion rollup number property value."""

    number: Optional[Union[float, int]] = None

    @property
    def Value(self):
        """Return the native representation of this Rollup object."""
        return self.number

Value property

Return the native representation of this Rollup object.

RollupObject

Bases: TypedObject, ABC

A Notion rollup property value.

Source code in src/notional/types.py
1058
1059
1060
1061
1062
1063
1064
1065
1066
class RollupObject(TypedObject, ABC):
    """A Notion rollup property value."""

    function: Optional[Function] = None

    @property
    @abstractmethod
    def Value(self):
        """Return the native representation of this Rollup object."""

Value abstractmethod property

Return the native representation of this Rollup object.

SelectOne

Bases: NativeTypeMixin, PropertyValue

Notion select type.

Source code in src/notional/types.py
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
class SelectOne(NativeTypeMixin, PropertyValue, type="select"):
    """Notion select type."""

    select: Optional[SelectValue] = None

    def __str__(self):
        """Return a string representation of this property."""
        return self.Value or ""

    def __eq__(self, other):
        """Determine if this property is equal to the given object.

        To avoid confusion, this method compares Select options by name.
        """

        if other is None:
            return self.select is None

        return other == self.select.name

    @classmethod
    def __compose__(cls, value, color=None):
        """Create a `SelectOne` property from the given value.

        :param value: a string to use for this property
        :param color: an optional Color for the value
        """
        return cls(select=SelectValue[value, color])

    @property
    def Value(self):
        """Return the value of this property as a string."""

        if self.select is None:
            return None

        return str(self.select)

Value property

Return the value of this property as a string.

__compose__(value, color=None) classmethod

Create a SelectOne property from the given value.

:param value: a string to use for this property :param color: an optional Color for the value

Source code in src/notional/types.py
651
652
653
654
655
656
657
658
@classmethod
def __compose__(cls, value, color=None):
    """Create a `SelectOne` property from the given value.

    :param value: a string to use for this property
    :param color: an optional Color for the value
    """
    return cls(select=SelectValue[value, color])

__eq__(other)

Determine if this property is equal to the given object.

To avoid confusion, this method compares Select options by name.

Source code in src/notional/types.py
640
641
642
643
644
645
646
647
648
649
def __eq__(self, other):
    """Determine if this property is equal to the given object.

    To avoid confusion, this method compares Select options by name.
    """

    if other is None:
        return self.select is None

    return other == self.select.name

__str__()

Return a string representation of this property.

Source code in src/notional/types.py
636
637
638
def __str__(self):
    """Return a string representation of this property."""
    return self.Value or ""

SelectValue

Bases: GenericObject

Values for select & multi-select properties.

Source code in src/notional/types.py
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
class SelectValue(GenericObject):
    """Values for select & multi-select properties."""

    name: str
    id: Optional[Union[UUID, str]] = None
    color: Optional[Color] = None

    def __str__(self):
        """Return a string representation of this property."""
        return self.name

    @classmethod
    def __compose__(cls, value, color=None):
        """Create a `SelectValue` property from the given value.

        :param value: a string to use for this property
        :param color: an optional Color for the value
        """
        return cls(name=value, color=color)

__compose__(value, color=None) classmethod

Create a SelectValue property from the given value.

:param value: a string to use for this property :param color: an optional Color for the value

Source code in src/notional/types.py
621
622
623
624
625
626
627
628
@classmethod
def __compose__(cls, value, color=None):
    """Create a `SelectValue` property from the given value.

    :param value: a string to use for this property
    :param color: an optional Color for the value
    """
    return cls(name=value, color=color)

__str__()

Return a string representation of this property.

Source code in src/notional/types.py
617
618
619
def __str__(self):
    """Return a string representation of this property."""
    return self.name

Status

Bases: NativeTypeMixin, PropertyValue

Notion status property.

Source code in src/notional/types.py
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
class Status(NativeTypeMixin, PropertyValue, type="status"):
    """Notion status property."""

    class _NestedData(GenericObject):
        name: str = None
        id: Optional[Union[UUID, str]] = None
        color: Optional[Color] = None

    status: Optional[_NestedData] = None

    def __str__(self):
        """Return a string representation of this property."""
        return self.Value or ""

    def __eq__(self, other):
        """Determine if this property is equal to the given object.

        To avoid confusion, this method compares Status options by name.
        """

        if other is None:
            return self.status is None

        if isinstance(other, Status):
            return self.status.name == other.status.name

        return self.status.name == other

    @classmethod
    def __compose__(cls, name, color=None):
        """Create a `Status` property from the given name.

        :param name: a string to use for this property
        :param color: an optional Color for the status
        """

        if name is None:
            raise ValueError("'name' cannot be None")

        return cls(status=Status._NestedData(name=name, color=color))

    @property
    def Value(self):
        """Return the value of this property as a string."""

        return self.status.name

Value property

Return the value of this property as a string.

__compose__(name, color=None) classmethod

Create a Status property from the given name.

:param name: a string to use for this property :param color: an optional Color for the status

Source code in src/notional/types.py
590
591
592
593
594
595
596
597
598
599
600
601
@classmethod
def __compose__(cls, name, color=None):
    """Create a `Status` property from the given name.

    :param name: a string to use for this property
    :param color: an optional Color for the status
    """

    if name is None:
        raise ValueError("'name' cannot be None")

    return cls(status=Status._NestedData(name=name, color=color))

__eq__(other)

Determine if this property is equal to the given object.

To avoid confusion, this method compares Status options by name.

Source code in src/notional/types.py
576
577
578
579
580
581
582
583
584
585
586
587
588
def __eq__(self, other):
    """Determine if this property is equal to the given object.

    To avoid confusion, this method compares Status options by name.
    """

    if other is None:
        return self.status is None

    if isinstance(other, Status):
        return self.status.name == other.status.name

    return self.status.name == other

__str__()

Return a string representation of this property.

Source code in src/notional/types.py
572
573
574
def __str__(self):
    """Return a string representation of this property."""
    return self.Value or ""

StringFormula

Bases: FormulaResult

A Notion string formula result.

Source code in src/notional/types.py
931
932
933
934
935
936
937
938
939
class StringFormula(FormulaResult, type="string"):
    """A Notion string formula result."""

    string: Optional[str] = None

    @property
    def Result(self):
        """Return the result of this StringFormula."""
        return self.string

Result property

Return the result of this StringFormula.

Title

Bases: NativeTypeMixin, PropertyValue

Notion title type.

Source code in src/notional/types.py
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
class Title(NativeTypeMixin, PropertyValue, type="title"):
    """Notion title type."""

    title: List[RichTextObject] = []

    def __len__(self):
        """Return the number of object in the Title object."""

        return len(self.title)

    @classmethod
    def __compose__(cls, *text):
        """Create a new `Title` property from the given text elements."""
        return cls(title=rich_text(*text))

    @property
    def Value(self):
        """Return the plain text from this Title."""

        if self.title is None:
            return None

        return plain_text(*self.title)

Value property

Return the plain text from this Title.

__compose__(*text) classmethod

Create a new Title property from the given text elements.

Source code in src/notional/types.py
397
398
399
400
@classmethod
def __compose__(cls, *text):
    """Create a new `Title` property from the given text elements."""
    return cls(title=rich_text(*text))

__len__()

Return the number of object in the Title object.

Source code in src/notional/types.py
392
393
394
395
def __len__(self):
    """Return the number of object in the Title object."""

    return len(self.title)

URL

Bases: NativeTypeMixin, PropertyValue

Notion URL type.

Source code in src/notional/types.py
815
816
817
818
class URL(NativeTypeMixin, PropertyValue, type="url"):
    """Notion URL type."""

    url: Optional[str] = None

WorkspaceRef

Bases: ParentRef

Reference the workspace.

Source code in src/notional/types.py
120
121
122
123
class WorkspaceRef(ParentRef, type="workspace"):
    """Reference the workspace."""

    workspace: bool = True