mautrix.client.api.types.event package¶
Submodules¶
mautrix.client.api.types.event.account_data module¶
-
class
mautrix.client.api.types.event.account_data.
AccountDataEvent
(type: mautrix.client.api.types.event.base.EventType, content: Union[mautrix.client.api.types.event.account_data.RoomTagAccountDataEventContent, mautrix.client.api.types.util.obj.Obj])[source]¶ Bases:
mautrix.client.api.types.event.base.BaseEvent
,mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
-
classmethod
deserialize
(data: NewType.<locals>.new_type) → mautrix.client.api.types.event.account_data.AccountDataEvent[source]¶ Convert the given data parsed from JSON into an object of this type.
Return type: AccountDataEvent
-
static
deserialize_content
(data: NewType.<locals>.new_type) → Union[mautrix.client.api.types.event.account_data.RoomTagAccountDataEventContent, mautrix.client.api.types.util.obj.Obj][source]¶ Return type: Union
[RoomTagAccountDataEventContent
,Obj
]
-
classmethod
-
class
mautrix.client.api.types.event.account_data.
RoomTagAccountDataEventContent
(tags: Dict[str, mautrix.client.api.types.event.account_data.RoomTagInfo] = None)[source]¶ Bases:
mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
-
class
mautrix.client.api.types.event.account_data.
RoomTagInfo
(order: int = None)[source]¶ Bases:
mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
-
order
= None¶
-
-
mautrix.client.api.types.event.account_data.
dataclass
(maybe_cls=None, these=None, repr_ns=None, repr=True, cmp=True, hash=None, init=True, slots=False, frozen=False, weakref_slot=True, str=False, *, auto_attribs=True, kw_only=False, cache_hash=False, auto_exc=False)¶ A class decorator that adds dunder-methods according to the specified attributes using
attr.ib()
or the these argument.Parameters: - these (
dict
ofstr
toattr.ib()
) –A dictionary of name to
attr.ib()
mappings. This is useful to avoid the definition of your attributes within the class body because you can’t (e.g. if you want to add__repr__
methods to Django models) or don’t want to.If these is not
None
,attrs
will not search the class body for attributes and will not remove any attributes from it.If these is an ordered dict (
dict
on Python 3.6+,collections.OrderedDict
otherwise), the order is deduced from the order of the attributes inside these. Otherwise the order of the definition of the attributes is used. - repr_ns (str) – When using nested classes, there’s no way in Python 2
to automatically detect that. Therefore it’s possible to set the
namespace explicitly for a more meaningful
repr
output. - repr (bool) – Create a
__repr__
method with a human readable representation ofattrs
attributes.. - str (bool) – Create a
__str__
method that is identical to__repr__
. This is usually not necessary except forException
s. - cmp (bool) – Create
__eq__
,__ne__
,__lt__
,__le__
,__gt__
, and__ge__
methods that compare the class as if it were a tuple of itsattrs
attributes. But the attributes are only compared, if the types of both classes are identical! - hash (
bool
orNone
) –If
None
(default), the__hash__
method is generated according how cmp and frozen are set.- If both are True,
attrs
will generate a__hash__
for you. - If cmp is True and frozen is False,
__hash__
will be set to None, marking it unhashable (which it is). - If cmp is False,
__hash__
will be left untouched meaning the__hash__
method of the base class will be used (if base class isobject
, this means it will fall back to id-based hashing.).
Although not recommended, you can decide for yourself and force
attrs
to create one (e.g. if the class is immutable even though you didn’t freeze it programmatically) by passingTrue
or not. Both of these cases are rather special and should be used carefully.See the Python documentation and the GitHub issue that led to the default behavior for more details.
- If both are True,
- init (bool) – Create a
__init__
method that initializes theattrs
attributes. Leading underscores are stripped for the argument name. If a__attrs_post_init__
method exists on the class, it will be called after the class is fully initialized. - slots (bool) – Create a slots-style class that’s more memory-efficient. See slots for further ramifications.
- frozen (bool) –
Make instances immutable after initialization. If someone attempts to modify a frozen instance,
attr.exceptions.FrozenInstanceError
is raised.Please note:
- This is achieved by installing a custom
__setattr__
method on your class so you can’t implement an own one. - True immutability is impossible in Python.
- This does have a minor a runtime performance impact when initializing new instances. In other words:
__init__
is slightly slower withfrozen=True
. - If a class is frozen, you cannot modify
self
in__attrs_post_init__
or a self-written__init__
. You can circumvent that limitation by usingobject.__setattr__(self, "attribute_name", value)
.
- This is achieved by installing a custom
- weakref_slot (bool) – Make instances weak-referenceable. This has no
effect unless
slots
is also enabled. - auto_attribs (bool) –
If True, collect PEP 526-annotated attributes (Python 3.6 and later only) from the class body.
In this case, you must annotate every field. If
attrs
encounters a field that is set to anattr.ib()
but lacks a type annotation, anattr.exceptions.UnannotatedAttributeError
is raised. Usefield_name: typing.Any = attr.ib(...)
if you don’t want to set a type.If you assign a value to those attributes (e.g.
x: int = 42
), that value becomes the default value like if it were passed usingattr.ib(default=42)
. Passing an instance ofFactory
also works as expected.Attributes annotated as
typing.ClassVar
are ignored. - kw_only (bool) – Make all attributes keyword-only (Python 3+)
in the generated
__init__
(ifinit
isFalse
, this parameter is ignored). - cache_hash (bool) – Ensure that the object’s hash code is computed
only once and stored on the object. If this is set to
True
, hashing must be either explicitly or implicitly enabled for this class. If the hash code is cached, avoid any reassignments of fields involved in hash code computation or mutations of the objects those fields point to after object creation. If such changes occur, the behavior of the object’s hash code is undefined. - auto_exc (bool) –
If the class subclasses
BaseException
(which implicitly includes any subclass of any exception), the following happens to behave like a well-behaved Python exceptions class:- the values for cmp and hash are ignored and the instances compare
and hash by the instance’s ids (N.B.
attrs
will not remove existing implementations of__hash__
or the equality methods. It just won’t add own ones.), - all attributes that are either passed into
__init__
or have a default value are additionally available as a tuple in theargs
attribute, - the value of str is ignored leaving
__str__
to base classes.
- the values for cmp and hash are ignored and the instances compare
and hash by the instance’s ids (N.B.
New in version 16.0.0: slots
New in version 16.1.0: frozen
New in version 16.3.0: str
New in version 16.3.0: Support for
__attrs_post_init__
.Changed in version 17.1.0: hash supports
None
as value which is also the default now.New in version 17.3.0: auto_attribs
Changed in version 18.1.0: If these is passed, no attributes are deleted from the class body.
Changed in version 18.1.0: If these is ordered, the order is retained.
New in version 18.2.0: weakref_slot
Deprecated since version 18.2.0:
__lt__
,__le__
,__gt__
, and__ge__
now raise aDeprecationWarning
if the classes compared are subclasses of each other.__eq
and__ne__
never tried to compared subclasses to each other.New in version 18.2.0: kw_only
New in version 18.2.0: cache_hash
New in version 19.1.0: auto_exc
- these (
mautrix.client.api.types.event.base module¶
-
class
mautrix.client.api.types.event.base.
BaseEvent
(content: mautrix.client.api.types.util.obj.Obj, type: mautrix.client.api.types.event.base.EventType)[source]¶ Bases:
object
Base event class. The only things an event must have are content and event type.
-
class
mautrix.client.api.types.event.base.
BaseRoomEvent
(content: mautrix.client.api.types.util.obj.Obj, type: mautrix.client.api.types.event.base.EventType, room_id: NewType.<locals>.new_type, event_id: NewType.<locals>.new_type, sender: NewType.<locals>.new_type, timestamp: int)[source]¶ Bases:
mautrix.client.api.types.event.base.BaseEvent
Base room event class. Room events must have a room ID, event ID, sender and timestamp in addition to the content and type in the base event.
-
class
mautrix.client.api.types.event.base.
BaseUnsigned
(age: int = None)[source]¶ Bases:
object
Base unsigned information.
-
age
= None¶
-
-
class
mautrix.client.api.types.event.base.
EventType
(t: str, t_class: <unknown>.EventType.Class = unknown)[source]¶ Bases:
mautrix.client.api.types.util.serializable.Serializable
An event type.
-
ALL
= EventType("__ALL__", EventType.Class.UNKNOWN)¶
-
class
Class
(_)¶ Bases:
<unknown>.SerializableEnum
An enumeration.
-
ACCOUNT_DATA
= 'account_data'¶
-
EPHEMERAL
= 'ephemeral'¶
-
MESSAGE
= 'message'¶
-
STATE
= 'state'¶
-
UNKNOWN
= 'unknown'¶
-
-
DIRECT
= EventType("m.direct", EventType.Class.ACCOUNT_DATA)¶
-
IGNORED_USER_LIST
= EventType("m.ignored_user_list", EventType.Class.ACCOUNT_DATA)¶
-
PRESENCE
= EventType("m.presence", EventType.Class.EPHEMERAL)¶
-
PUSH_RULES
= EventType("m.push_rules", EventType.Class.ACCOUNT_DATA)¶
-
REACTION
= EventType("m.reaction", EventType.Class.MESSAGE)¶
-
RECEIPT
= EventType("m.receipt", EventType.Class.EPHEMERAL)¶
-
ROOM_ALIASES
= EventType("m.room.aliases", EventType.Class.STATE)¶
-
ROOM_AVATAR
= EventType("m.room.avatar", EventType.Class.STATE)¶
-
ROOM_CANONICAL_ALIAS
= EventType("m.room.canonical_alias", EventType.Class.STATE)¶
-
ROOM_CREATE
= EventType("m.room.create", EventType.Class.STATE)¶
-
ROOM_ENCRYPTED
= EventType("m.room.encrypted", EventType.Class.MESSAGE)¶
-
ROOM_JOIN_RULES
= EventType("m.room.join_rules", EventType.Class.STATE)¶
-
ROOM_MEMBER
= EventType("m.room.member", EventType.Class.STATE)¶
-
ROOM_MESSAGE
= EventType("m.room.message", EventType.Class.MESSAGE)¶
-
ROOM_NAME
= EventType("m.room.name", EventType.Class.STATE)¶
-
ROOM_PINNED_EVENTS
= EventType("m.room.pinned_events", EventType.Class.STATE)¶
-
ROOM_POWER_LEVELS
= EventType("m.room.power_levels", EventType.Class.STATE)¶
-
ROOM_REDACTION
= EventType("m.room.redaction", EventType.Class.MESSAGE)¶
-
ROOM_TOMBSTONE
= EventType("m.room.tombstone", EventType.Class.STATE)¶
-
ROOM_TOPIC
= EventType("m.room.topic", EventType.Class.STATE)¶
-
STICKER
= EventType("m.sticker", EventType.Class.MESSAGE)¶
-
TAG
= EventType("m.tag", EventType.Class.ACCOUNT_DATA)¶
-
TYPING
= EventType("m.typing", EventType.Class.EPHEMERAL)¶
-
by_event_type
= {'__ALL__': EventType("__ALL__", EventType.Class.UNKNOWN), 'm.direct': EventType("m.direct", EventType.Class.ACCOUNT_DATA), 'm.ignored_user_list': EventType("m.ignored_user_list", EventType.Class.ACCOUNT_DATA), 'm.presence': EventType("m.presence", EventType.Class.EPHEMERAL), 'm.push_rules': EventType("m.push_rules", EventType.Class.ACCOUNT_DATA), 'm.reaction': EventType("m.reaction", EventType.Class.MESSAGE), 'm.receipt': EventType("m.receipt", EventType.Class.EPHEMERAL), 'm.room.aliases': EventType("m.room.aliases", EventType.Class.STATE), 'm.room.avatar': EventType("m.room.avatar", EventType.Class.STATE), 'm.room.canonical_alias': EventType("m.room.canonical_alias", EventType.Class.STATE), 'm.room.create': EventType("m.room.create", EventType.Class.STATE), 'm.room.encrypted': EventType("m.room.encrypted", EventType.Class.MESSAGE), 'm.room.join_rules': EventType("m.room.join_rules", EventType.Class.STATE), 'm.room.member': EventType("m.room.member", EventType.Class.STATE), 'm.room.message': EventType("m.room.message", EventType.Class.MESSAGE), 'm.room.name': EventType("m.room.name", EventType.Class.STATE), 'm.room.pinned_events': EventType("m.room.pinned_events", EventType.Class.STATE), 'm.room.power_levels': EventType("m.room.power_levels", EventType.Class.STATE), 'm.room.redaction': EventType("m.room.redaction", EventType.Class.MESSAGE), 'm.room.tombstone': EventType("m.room.tombstone", EventType.Class.STATE), 'm.room.topic': EventType("m.room.topic", EventType.Class.STATE), 'm.sticker': EventType("m.sticker", EventType.Class.MESSAGE), 'm.tag': EventType("m.tag", EventType.Class.ACCOUNT_DATA), 'm.typing': EventType("m.typing", EventType.Class.EPHEMERAL)}¶
-
classmethod
deserialize
(raw: NewType.<locals>.new_type) → Any[source]¶ Convert the given data parsed from JSON into an object of this type.
Return type: Any
-
classmethod
find
(t: str) → mautrix.client.api.types.event.base.EventType[source]¶ Return type: EventType
-
is_account_data
¶ Whether or not the event is an account data event.
Return type: bool
-
is_ephemeral
¶ Whether or not the event is ephemeral.
Return type: bool
-
is_message
¶ Whether or not the event is a message event.
Return type: bool
-
is_state
¶ Whether or not the event is a state event.
Return type: bool
-
-
mautrix.client.api.types.event.base.
dataclass
(maybe_cls=None, these=None, repr_ns=None, repr=True, cmp=True, hash=None, init=True, slots=False, frozen=False, weakref_slot=True, str=False, *, auto_attribs=True, kw_only=False, cache_hash=False, auto_exc=False)¶ A class decorator that adds dunder-methods according to the specified attributes using
attr.ib()
or the these argument.Parameters: - these (
dict
ofstr
toattr.ib()
) –A dictionary of name to
attr.ib()
mappings. This is useful to avoid the definition of your attributes within the class body because you can’t (e.g. if you want to add__repr__
methods to Django models) or don’t want to.If these is not
None
,attrs
will not search the class body for attributes and will not remove any attributes from it.If these is an ordered dict (
dict
on Python 3.6+,collections.OrderedDict
otherwise), the order is deduced from the order of the attributes inside these. Otherwise the order of the definition of the attributes is used. - repr_ns (str) – When using nested classes, there’s no way in Python 2
to automatically detect that. Therefore it’s possible to set the
namespace explicitly for a more meaningful
repr
output. - repr (bool) – Create a
__repr__
method with a human readable representation ofattrs
attributes.. - str (bool) – Create a
__str__
method that is identical to__repr__
. This is usually not necessary except forException
s. - cmp (bool) – Create
__eq__
,__ne__
,__lt__
,__le__
,__gt__
, and__ge__
methods that compare the class as if it were a tuple of itsattrs
attributes. But the attributes are only compared, if the types of both classes are identical! - hash (
bool
orNone
) –If
None
(default), the__hash__
method is generated according how cmp and frozen are set.- If both are True,
attrs
will generate a__hash__
for you. - If cmp is True and frozen is False,
__hash__
will be set to None, marking it unhashable (which it is). - If cmp is False,
__hash__
will be left untouched meaning the__hash__
method of the base class will be used (if base class isobject
, this means it will fall back to id-based hashing.).
Although not recommended, you can decide for yourself and force
attrs
to create one (e.g. if the class is immutable even though you didn’t freeze it programmatically) by passingTrue
or not. Both of these cases are rather special and should be used carefully.See the Python documentation and the GitHub issue that led to the default behavior for more details.
- If both are True,
- init (bool) – Create a
__init__
method that initializes theattrs
attributes. Leading underscores are stripped for the argument name. If a__attrs_post_init__
method exists on the class, it will be called after the class is fully initialized. - slots (bool) – Create a slots-style class that’s more memory-efficient. See slots for further ramifications.
- frozen (bool) –
Make instances immutable after initialization. If someone attempts to modify a frozen instance,
attr.exceptions.FrozenInstanceError
is raised.Please note:
- This is achieved by installing a custom
__setattr__
method on your class so you can’t implement an own one. - True immutability is impossible in Python.
- This does have a minor a runtime performance impact when initializing new instances. In other words:
__init__
is slightly slower withfrozen=True
. - If a class is frozen, you cannot modify
self
in__attrs_post_init__
or a self-written__init__
. You can circumvent that limitation by usingobject.__setattr__(self, "attribute_name", value)
.
- This is achieved by installing a custom
- weakref_slot (bool) – Make instances weak-referenceable. This has no
effect unless
slots
is also enabled. - auto_attribs (bool) –
If True, collect PEP 526-annotated attributes (Python 3.6 and later only) from the class body.
In this case, you must annotate every field. If
attrs
encounters a field that is set to anattr.ib()
but lacks a type annotation, anattr.exceptions.UnannotatedAttributeError
is raised. Usefield_name: typing.Any = attr.ib(...)
if you don’t want to set a type.If you assign a value to those attributes (e.g.
x: int = 42
), that value becomes the default value like if it were passed usingattr.ib(default=42)
. Passing an instance ofFactory
also works as expected.Attributes annotated as
typing.ClassVar
are ignored. - kw_only (bool) – Make all attributes keyword-only (Python 3+)
in the generated
__init__
(ifinit
isFalse
, this parameter is ignored). - cache_hash (bool) – Ensure that the object’s hash code is computed
only once and stored on the object. If this is set to
True
, hashing must be either explicitly or implicitly enabled for this class. If the hash code is cached, avoid any reassignments of fields involved in hash code computation or mutations of the objects those fields point to after object creation. If such changes occur, the behavior of the object’s hash code is undefined. - auto_exc (bool) –
If the class subclasses
BaseException
(which implicitly includes any subclass of any exception), the following happens to behave like a well-behaved Python exceptions class:- the values for cmp and hash are ignored and the instances compare
and hash by the instance’s ids (N.B.
attrs
will not remove existing implementations of__hash__
or the equality methods. It just won’t add own ones.), - all attributes that are either passed into
__init__
or have a default value are additionally available as a tuple in theargs
attribute, - the value of str is ignored leaving
__str__
to base classes.
- the values for cmp and hash are ignored and the instances compare
and hash by the instance’s ids (N.B.
New in version 16.0.0: slots
New in version 16.1.0: frozen
New in version 16.3.0: str
New in version 16.3.0: Support for
__attrs_post_init__
.Changed in version 17.1.0: hash supports
None
as value which is also the default now.New in version 17.3.0: auto_attribs
Changed in version 18.1.0: If these is passed, no attributes are deleted from the class body.
Changed in version 18.1.0: If these is ordered, the order is retained.
New in version 18.2.0: weakref_slot
Deprecated since version 18.2.0:
__lt__
,__le__
,__gt__
, and__ge__
now raise aDeprecationWarning
if the classes compared are subclasses of each other.__eq
and__ne__
never tried to compared subclasses to each other.New in version 18.2.0: kw_only
New in version 18.2.0: cache_hash
New in version 19.1.0: auto_exc
- these (
mautrix.client.api.types.event.generic module¶
-
class
mautrix.client.api.types.event.generic.
GenericEvent
(content: mautrix.client.api.types.util.obj.Obj, type: mautrix.client.api.types.event.base.EventType, room_id: Optional[NewType.<locals>.new_type] = None, event_id: Optional[NewType.<locals>.new_type] = None, sender: Optional[NewType.<locals>.new_type] = None, timestamp: Optional[int] = None, state_key: Optional[str] = None, unsigned: mautrix.client.api.types.util.obj.Obj = None, readacts: Optional[NewType.<locals>.new_type] = None)[source]¶ Bases:
mautrix.client.api.types.event.base.BaseEvent
,mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
An event class that contains all possible top-level event keys and uses generic Obj’s for object keys (content and unsigned)
-
event_id
= None¶
-
readacts
= None¶
-
room_id
= None¶
-
sender
= None¶
-
state_key
= None¶
-
timestamp
= None¶
-
unsigned
= None¶
-
-
mautrix.client.api.types.event.generic.
dataclass
(maybe_cls=None, these=None, repr_ns=None, repr=True, cmp=True, hash=None, init=True, slots=False, frozen=False, weakref_slot=True, str=False, *, auto_attribs=True, kw_only=False, cache_hash=False, auto_exc=False)¶ A class decorator that adds dunder-methods according to the specified attributes using
attr.ib()
or the these argument.Parameters: - these (
dict
ofstr
toattr.ib()
) –A dictionary of name to
attr.ib()
mappings. This is useful to avoid the definition of your attributes within the class body because you can’t (e.g. if you want to add__repr__
methods to Django models) or don’t want to.If these is not
None
,attrs
will not search the class body for attributes and will not remove any attributes from it.If these is an ordered dict (
dict
on Python 3.6+,collections.OrderedDict
otherwise), the order is deduced from the order of the attributes inside these. Otherwise the order of the definition of the attributes is used. - repr_ns (str) – When using nested classes, there’s no way in Python 2
to automatically detect that. Therefore it’s possible to set the
namespace explicitly for a more meaningful
repr
output. - repr (bool) – Create a
__repr__
method with a human readable representation ofattrs
attributes.. - str (bool) – Create a
__str__
method that is identical to__repr__
. This is usually not necessary except forException
s. - cmp (bool) – Create
__eq__
,__ne__
,__lt__
,__le__
,__gt__
, and__ge__
methods that compare the class as if it were a tuple of itsattrs
attributes. But the attributes are only compared, if the types of both classes are identical! - hash (
bool
orNone
) –If
None
(default), the__hash__
method is generated according how cmp and frozen are set.- If both are True,
attrs
will generate a__hash__
for you. - If cmp is True and frozen is False,
__hash__
will be set to None, marking it unhashable (which it is). - If cmp is False,
__hash__
will be left untouched meaning the__hash__
method of the base class will be used (if base class isobject
, this means it will fall back to id-based hashing.).
Although not recommended, you can decide for yourself and force
attrs
to create one (e.g. if the class is immutable even though you didn’t freeze it programmatically) by passingTrue
or not. Both of these cases are rather special and should be used carefully.See the Python documentation and the GitHub issue that led to the default behavior for more details.
- If both are True,
- init (bool) – Create a
__init__
method that initializes theattrs
attributes. Leading underscores are stripped for the argument name. If a__attrs_post_init__
method exists on the class, it will be called after the class is fully initialized. - slots (bool) – Create a slots-style class that’s more memory-efficient. See slots for further ramifications.
- frozen (bool) –
Make instances immutable after initialization. If someone attempts to modify a frozen instance,
attr.exceptions.FrozenInstanceError
is raised.Please note:
- This is achieved by installing a custom
__setattr__
method on your class so you can’t implement an own one. - True immutability is impossible in Python.
- This does have a minor a runtime performance impact when initializing new instances. In other words:
__init__
is slightly slower withfrozen=True
. - If a class is frozen, you cannot modify
self
in__attrs_post_init__
or a self-written__init__
. You can circumvent that limitation by usingobject.__setattr__(self, "attribute_name", value)
.
- This is achieved by installing a custom
- weakref_slot (bool) – Make instances weak-referenceable. This has no
effect unless
slots
is also enabled. - auto_attribs (bool) –
If True, collect PEP 526-annotated attributes (Python 3.6 and later only) from the class body.
In this case, you must annotate every field. If
attrs
encounters a field that is set to anattr.ib()
but lacks a type annotation, anattr.exceptions.UnannotatedAttributeError
is raised. Usefield_name: typing.Any = attr.ib(...)
if you don’t want to set a type.If you assign a value to those attributes (e.g.
x: int = 42
), that value becomes the default value like if it were passed usingattr.ib(default=42)
. Passing an instance ofFactory
also works as expected.Attributes annotated as
typing.ClassVar
are ignored. - kw_only (bool) – Make all attributes keyword-only (Python 3+)
in the generated
__init__
(ifinit
isFalse
, this parameter is ignored). - cache_hash (bool) – Ensure that the object’s hash code is computed
only once and stored on the object. If this is set to
True
, hashing must be either explicitly or implicitly enabled for this class. If the hash code is cached, avoid any reassignments of fields involved in hash code computation or mutations of the objects those fields point to after object creation. If such changes occur, the behavior of the object’s hash code is undefined. - auto_exc (bool) –
If the class subclasses
BaseException
(which implicitly includes any subclass of any exception), the following happens to behave like a well-behaved Python exceptions class:- the values for cmp and hash are ignored and the instances compare
and hash by the instance’s ids (N.B.
attrs
will not remove existing implementations of__hash__
or the equality methods. It just won’t add own ones.), - all attributes that are either passed into
__init__
or have a default value are additionally available as a tuple in theargs
attribute, - the value of str is ignored leaving
__str__
to base classes.
- the values for cmp and hash are ignored and the instances compare
and hash by the instance’s ids (N.B.
New in version 16.0.0: slots
New in version 16.1.0: frozen
New in version 16.3.0: str
New in version 16.3.0: Support for
__attrs_post_init__
.Changed in version 17.1.0: hash supports
None
as value which is also the default now.New in version 17.3.0: auto_attribs
Changed in version 18.1.0: If these is passed, no attributes are deleted from the class body.
Changed in version 18.1.0: If these is ordered, the order is retained.
New in version 18.2.0: weakref_slot
Deprecated since version 18.2.0:
__lt__
,__le__
,__gt__
, and__ge__
now raise aDeprecationWarning
if the classes compared are subclasses of each other.__eq
and__ne__
never tried to compared subclasses to each other.New in version 18.2.0: kw_only
New in version 18.2.0: cache_hash
New in version 19.1.0: auto_exc
- these (
-
mautrix.client.api.types.event.generic.
deserialize_event
(data: NewType.<locals>.new_type) → NewType.<locals>.new_type[source]¶ Return type: Event
[Union
[MessageEvent
,ReactionEvent
,RedactionEvent
,StateEvent
,ReceiptEvent
,PresenceEvent
,TypingEvent
,GenericEvent
]]
mautrix.client.api.types.event.message module¶
-
class
mautrix.client.api.types.event.message.
AudioInfo
(mimetype: str = None, size: int = None, duration: int = None)[source]¶ Bases:
mautrix.client.api.types.event.message.BaseFileInfo
,mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
Information about an audio message.
-
duration
= None¶
-
-
class
mautrix.client.api.types.event.message.
BaseFileInfo
(mimetype: str = None, size: int = None)[source]¶ Bases:
mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
-
mimetype
= None¶
-
size
= None¶
-
-
class
mautrix.client.api.types.event.message.
BaseMessageEventContent
(msgtype: <unknown>.MessageType = None, body: str = '')[source]¶ Bases:
mautrix.client.api.types.event.message.BaseMessageEventContentFuncs
Base event content for all m.room.message-type events.
-
msgtype
= None¶
-
-
class
mautrix.client.api.types.event.message.
BaseMessageEventContentFuncs
[source]¶ Bases:
object
Base class for the contents of all message-type events (currently m.room.message and m.sticker). Contains relation helpers.
-
set_edit
(edits: mautrix.client.api.types.event.message.MessageEvent) → None[source]¶ Return type: None
-
-
class
mautrix.client.api.types.event.message.
FileInfo
(mimetype: str = None, size: int = None, thumbnail_info: mautrix.client.api.types.event.message.ThumbnailInfo = None, thumbnail_url: NewType.<locals>.new_type = None)[source]¶ Bases:
mautrix.client.api.types.event.message.BaseFileInfo
,mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
Information about a document message.
-
thumbnail_info
= None¶
-
thumbnail_url
= None¶
-
-
class
mautrix.client.api.types.event.message.
ImageInfo
(mimetype: str = None, size: int = None, thumbnail_info: mautrix.client.api.types.event.message.ThumbnailInfo = None, thumbnail_url: NewType.<locals>.new_type = None, height: int = None, width: int = None)[source]¶ Bases:
mautrix.client.api.types.event.message.FileInfo
,mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
Information about an image message.
-
class
mautrix.client.api.types.event.message.
InReplyTo
(event_id: Optional[NewType.<locals>.new_type] = None, proxy_target: Optional[RelatesTo] = None)[source]¶ Bases:
object
-
event_id
¶ Return type: EventID
[str
]
-
-
class
mautrix.client.api.types.event.message.
LocationInfo
(thumbnail_url: NewType.<locals>.new_type = None, thumbnail_info: mautrix.client.api.types.event.message.ThumbnailInfo = None)[source]¶ Bases:
mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
Information about a location message.
-
thumbnail_info
= None¶
-
thumbnail_url
= None¶
-
-
class
mautrix.client.api.types.event.message.
LocationMessageEventContent
(msgtype: <unknown>.MessageType = None, body: str = '', geo_uri: str = None, info: mautrix.client.api.types.event.message.LocationInfo = None, relates_to: Optional[mautrix.client.api.types.event.message.RelatesTo] = None)[source]¶ Bases:
mautrix.client.api.types.event.message.BaseMessageEventContent
,mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
-
geo_uri
= None¶
-
info
= None¶
-
-
class
mautrix.client.api.types.event.message.
MediaMessageEventContent
(msgtype: <unknown>.MessageType = None, body: str = '', url: NewType.<locals>.new_type = None, info: Union[mautrix.client.api.types.event.message.AudioInfo, mautrix.client.api.types.event.message.FileInfo, mautrix.client.api.types.util.obj.Obj, None] = None, relates_to: Optional[mautrix.client.api.types.event.message.RelatesTo] = None)[source]¶ Bases:
mautrix.client.api.types.event.message.BaseMessageEventContent
,mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
The content of a media message event (m.image, m.audio, m.video, m.file)
-
static
deserialize_info
(data: NewType.<locals>.new_type) → Union[mautrix.client.api.types.event.message.AudioInfo, mautrix.client.api.types.event.message.FileInfo, mautrix.client.api.types.util.obj.Obj][source]¶ Return type: Union
[AudioInfo
,FileInfo
,Obj
]
-
info
= None¶
-
url
= None¶
-
static
-
class
mautrix.client.api.types.event.message.
MessageEvent
(type: mautrix.client.api.types.event.base.EventType, room_id: NewType.<locals>.new_type, event_id: NewType.<locals>.new_type, sender: NewType.<locals>.new_type, timestamp: int, content: Union[mautrix.client.api.types.event.message.TextMessageEventContent, mautrix.client.api.types.event.message.MediaMessageEventContent, mautrix.client.api.types.event.message.LocationMessageEventContent, mautrix.client.api.types.util.obj.Obj], unsigned: Optional[mautrix.client.api.types.event.message.MessageUnsigned] = None)[source]¶ Bases:
mautrix.client.api.types.event.base.BaseRoomEvent
,mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
An m.room.message event
-
static
deserialize_content
(data: NewType.<locals>.new_type) → Union[mautrix.client.api.types.event.message.TextMessageEventContent, mautrix.client.api.types.event.message.MediaMessageEventContent, mautrix.client.api.types.event.message.LocationMessageEventContent, mautrix.client.api.types.util.obj.Obj][source]¶ Return type: Union
[TextMessageEventContent
,MediaMessageEventContent
,LocationMessageEventContent
,Obj
]
-
make_reply_fallback_html
() → str[source]¶ Generate the HTML fallback for messages replying to this event.
Return type: str
-
make_reply_fallback_text
() → str[source]¶ Generate the plaintext fallback for messages replying to this event.
Return type: str
-
static
serialize_content
(content: Union[mautrix.client.api.types.event.message.TextMessageEventContent, mautrix.client.api.types.event.message.MediaMessageEventContent, mautrix.client.api.types.event.message.LocationMessageEventContent, mautrix.client.api.types.util.obj.Obj]) → NewType.<locals>.new_type[source]¶ Return type: JSON
[Union
[str
,int
,float
,None
,Dict
[str
,_Forwardref
],List
[_Forwardref
]]]
-
unsigned
= None¶
-
static
-
class
mautrix.client.api.types.event.message.
MessageUnsigned
(age: int = None, transaction_id: str = None)[source]¶ Bases:
mautrix.client.api.types.event.base.BaseUnsigned
,mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
Unsigned information sent with message events.
-
transaction_id
= None¶
-
-
class
mautrix.client.api.types.event.message.
RelatesTo
(rel_type: <unknown>.RelationType = None, event_id: Optional[NewType.<locals>.new_type] = None, key: Optional[str] = None)[source]¶ Bases:
mautrix.client.api.types.util.serializable.Serializable
Message relations. Used for reactions, edits and replies.
-
classmethod
deserialize
(data: NewType.<locals>.new_type) → Optional[mautrix.client.api.types.event.message.RelatesTo][source]¶ Convert the given data parsed from JSON into an object of this type.
Return type: Optional
[RelatesTo
]
-
event_id
= None¶
-
key
= None¶
-
rel_type
= None¶
-
classmethod
-
class
mautrix.client.api.types.event.message.
TextMessageEventContent
(msgtype: <unknown>.MessageType = None, body: str = '', format: <unknown>.Format = None, formatted_body: str = None, relates_to: Optional[mautrix.client.api.types.event.message.RelatesTo] = None)[source]¶ Bases:
mautrix.client.api.types.event.message.BaseMessageEventContent
,mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
The content of a text message event (m.text, m.notice, m.emote)
-
format
= None¶
-
formatted_body
= None¶
-
-
class
mautrix.client.api.types.event.message.
ThumbnailInfo
(mimetype: str = None, size: int = None, height: int = None, width: int = None)[source]¶ Bases:
mautrix.client.api.types.event.message.BaseFileInfo
,mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
Information about the thumbnail for a document, video, image or location.
-
class
mautrix.client.api.types.event.message.
VideoInfo
(mimetype: str = None, size: int = None, thumbnail_info: mautrix.client.api.types.event.message.ThumbnailInfo = None, thumbnail_url: NewType.<locals>.new_type = None, height: int = None, width: int = None, duration: int = None)[source]¶ Bases:
mautrix.client.api.types.event.message.ImageInfo
,mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
Information about a video message.
-
duration
= None¶
-
-
mautrix.client.api.types.event.message.
dataclass
(maybe_cls=None, these=None, repr_ns=None, repr=True, cmp=True, hash=None, init=True, slots=False, frozen=False, weakref_slot=True, str=False, *, auto_attribs=True, kw_only=False, cache_hash=False, auto_exc=False)¶ A class decorator that adds dunder-methods according to the specified attributes using
attr.ib()
or the these argument.Parameters: - these (
dict
ofstr
toattr.ib()
) –A dictionary of name to
attr.ib()
mappings. This is useful to avoid the definition of your attributes within the class body because you can’t (e.g. if you want to add__repr__
methods to Django models) or don’t want to.If these is not
None
,attrs
will not search the class body for attributes and will not remove any attributes from it.If these is an ordered dict (
dict
on Python 3.6+,collections.OrderedDict
otherwise), the order is deduced from the order of the attributes inside these. Otherwise the order of the definition of the attributes is used. - repr_ns (str) – When using nested classes, there’s no way in Python 2
to automatically detect that. Therefore it’s possible to set the
namespace explicitly for a more meaningful
repr
output. - repr (bool) – Create a
__repr__
method with a human readable representation ofattrs
attributes.. - str (bool) – Create a
__str__
method that is identical to__repr__
. This is usually not necessary except forException
s. - cmp (bool) – Create
__eq__
,__ne__
,__lt__
,__le__
,__gt__
, and__ge__
methods that compare the class as if it were a tuple of itsattrs
attributes. But the attributes are only compared, if the types of both classes are identical! - hash (
bool
orNone
) –If
None
(default), the__hash__
method is generated according how cmp and frozen are set.- If both are True,
attrs
will generate a__hash__
for you. - If cmp is True and frozen is False,
__hash__
will be set to None, marking it unhashable (which it is). - If cmp is False,
__hash__
will be left untouched meaning the__hash__
method of the base class will be used (if base class isobject
, this means it will fall back to id-based hashing.).
Although not recommended, you can decide for yourself and force
attrs
to create one (e.g. if the class is immutable even though you didn’t freeze it programmatically) by passingTrue
or not. Both of these cases are rather special and should be used carefully.See the Python documentation and the GitHub issue that led to the default behavior for more details.
- If both are True,
- init (bool) – Create a
__init__
method that initializes theattrs
attributes. Leading underscores are stripped for the argument name. If a__attrs_post_init__
method exists on the class, it will be called after the class is fully initialized. - slots (bool) – Create a slots-style class that’s more memory-efficient. See slots for further ramifications.
- frozen (bool) –
Make instances immutable after initialization. If someone attempts to modify a frozen instance,
attr.exceptions.FrozenInstanceError
is raised.Please note:
- This is achieved by installing a custom
__setattr__
method on your class so you can’t implement an own one. - True immutability is impossible in Python.
- This does have a minor a runtime performance impact when initializing new instances. In other words:
__init__
is slightly slower withfrozen=True
. - If a class is frozen, you cannot modify
self
in__attrs_post_init__
or a self-written__init__
. You can circumvent that limitation by usingobject.__setattr__(self, "attribute_name", value)
.
- This is achieved by installing a custom
- weakref_slot (bool) – Make instances weak-referenceable. This has no
effect unless
slots
is also enabled. - auto_attribs (bool) –
If True, collect PEP 526-annotated attributes (Python 3.6 and later only) from the class body.
In this case, you must annotate every field. If
attrs
encounters a field that is set to anattr.ib()
but lacks a type annotation, anattr.exceptions.UnannotatedAttributeError
is raised. Usefield_name: typing.Any = attr.ib(...)
if you don’t want to set a type.If you assign a value to those attributes (e.g.
x: int = 42
), that value becomes the default value like if it were passed usingattr.ib(default=42)
. Passing an instance ofFactory
also works as expected.Attributes annotated as
typing.ClassVar
are ignored. - kw_only (bool) – Make all attributes keyword-only (Python 3+)
in the generated
__init__
(ifinit
isFalse
, this parameter is ignored). - cache_hash (bool) – Ensure that the object’s hash code is computed
only once and stored on the object. If this is set to
True
, hashing must be either explicitly or implicitly enabled for this class. If the hash code is cached, avoid any reassignments of fields involved in hash code computation or mutations of the objects those fields point to after object creation. If such changes occur, the behavior of the object’s hash code is undefined. - auto_exc (bool) –
If the class subclasses
BaseException
(which implicitly includes any subclass of any exception), the following happens to behave like a well-behaved Python exceptions class:- the values for cmp and hash are ignored and the instances compare
and hash by the instance’s ids (N.B.
attrs
will not remove existing implementations of__hash__
or the equality methods. It just won’t add own ones.), - all attributes that are either passed into
__init__
or have a default value are additionally available as a tuple in theargs
attribute, - the value of str is ignored leaving
__str__
to base classes.
- the values for cmp and hash are ignored and the instances compare
and hash by the instance’s ids (N.B.
New in version 16.0.0: slots
New in version 16.1.0: frozen
New in version 16.3.0: str
New in version 16.3.0: Support for
__attrs_post_init__
.Changed in version 17.1.0: hash supports
None
as value which is also the default now.New in version 17.3.0: auto_attribs
Changed in version 18.1.0: If these is passed, no attributes are deleted from the class body.
Changed in version 18.1.0: If these is ordered, the order is retained.
New in version 18.2.0: weakref_slot
Deprecated since version 18.2.0:
__lt__
,__le__
,__gt__
, and__ge__
now raise aDeprecationWarning
if the classes compared are subclasses of each other.__eq
and__ne__
never tried to compared subclasses to each other.New in version 18.2.0: kw_only
New in version 18.2.0: cache_hash
New in version 19.1.0: auto_exc
- these (
mautrix.client.api.types.event.redaction module¶
-
class
mautrix.client.api.types.event.redaction.
RedactionEvent
(type: mautrix.client.api.types.event.base.EventType, room_id: NewType.<locals>.new_type, event_id: NewType.<locals>.new_type, sender: NewType.<locals>.new_type, timestamp: int, content: mautrix.client.api.types.event.redaction.RedactionEventContent, redacts: NewType.<locals>.new_type, unsigned: Optional[mautrix.client.api.types.event.base.BaseUnsigned] = None)[source]¶ Bases:
mautrix.client.api.types.event.base.BaseRoomEvent
,mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
A m.room.redaction event
-
unsigned
¶ Return type: BaseUnsigned
-
-
class
mautrix.client.api.types.event.redaction.
RedactionEventContent
(reason: str = None)[source]¶ Bases:
mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
The content of an m.room.redaction event
-
reason
= None¶
-
-
mautrix.client.api.types.event.redaction.
dataclass
(maybe_cls=None, these=None, repr_ns=None, repr=True, cmp=True, hash=None, init=True, slots=False, frozen=False, weakref_slot=True, str=False, *, auto_attribs=True, kw_only=False, cache_hash=False, auto_exc=False)¶ A class decorator that adds dunder-methods according to the specified attributes using
attr.ib()
or the these argument.Parameters: - these (
dict
ofstr
toattr.ib()
) –A dictionary of name to
attr.ib()
mappings. This is useful to avoid the definition of your attributes within the class body because you can’t (e.g. if you want to add__repr__
methods to Django models) or don’t want to.If these is not
None
,attrs
will not search the class body for attributes and will not remove any attributes from it.If these is an ordered dict (
dict
on Python 3.6+,collections.OrderedDict
otherwise), the order is deduced from the order of the attributes inside these. Otherwise the order of the definition of the attributes is used. - repr_ns (str) – When using nested classes, there’s no way in Python 2
to automatically detect that. Therefore it’s possible to set the
namespace explicitly for a more meaningful
repr
output. - repr (bool) – Create a
__repr__
method with a human readable representation ofattrs
attributes.. - str (bool) – Create a
__str__
method that is identical to__repr__
. This is usually not necessary except forException
s. - cmp (bool) – Create
__eq__
,__ne__
,__lt__
,__le__
,__gt__
, and__ge__
methods that compare the class as if it were a tuple of itsattrs
attributes. But the attributes are only compared, if the types of both classes are identical! - hash (
bool
orNone
) –If
None
(default), the__hash__
method is generated according how cmp and frozen are set.- If both are True,
attrs
will generate a__hash__
for you. - If cmp is True and frozen is False,
__hash__
will be set to None, marking it unhashable (which it is). - If cmp is False,
__hash__
will be left untouched meaning the__hash__
method of the base class will be used (if base class isobject
, this means it will fall back to id-based hashing.).
Although not recommended, you can decide for yourself and force
attrs
to create one (e.g. if the class is immutable even though you didn’t freeze it programmatically) by passingTrue
or not. Both of these cases are rather special and should be used carefully.See the Python documentation and the GitHub issue that led to the default behavior for more details.
- If both are True,
- init (bool) – Create a
__init__
method that initializes theattrs
attributes. Leading underscores are stripped for the argument name. If a__attrs_post_init__
method exists on the class, it will be called after the class is fully initialized. - slots (bool) – Create a slots-style class that’s more memory-efficient. See slots for further ramifications.
- frozen (bool) –
Make instances immutable after initialization. If someone attempts to modify a frozen instance,
attr.exceptions.FrozenInstanceError
is raised.Please note:
- This is achieved by installing a custom
__setattr__
method on your class so you can’t implement an own one. - True immutability is impossible in Python.
- This does have a minor a runtime performance impact when initializing new instances. In other words:
__init__
is slightly slower withfrozen=True
. - If a class is frozen, you cannot modify
self
in__attrs_post_init__
or a self-written__init__
. You can circumvent that limitation by usingobject.__setattr__(self, "attribute_name", value)
.
- This is achieved by installing a custom
- weakref_slot (bool) – Make instances weak-referenceable. This has no
effect unless
slots
is also enabled. - auto_attribs (bool) –
If True, collect PEP 526-annotated attributes (Python 3.6 and later only) from the class body.
In this case, you must annotate every field. If
attrs
encounters a field that is set to anattr.ib()
but lacks a type annotation, anattr.exceptions.UnannotatedAttributeError
is raised. Usefield_name: typing.Any = attr.ib(...)
if you don’t want to set a type.If you assign a value to those attributes (e.g.
x: int = 42
), that value becomes the default value like if it were passed usingattr.ib(default=42)
. Passing an instance ofFactory
also works as expected.Attributes annotated as
typing.ClassVar
are ignored. - kw_only (bool) – Make all attributes keyword-only (Python 3+)
in the generated
__init__
(ifinit
isFalse
, this parameter is ignored). - cache_hash (bool) – Ensure that the object’s hash code is computed
only once and stored on the object. If this is set to
True
, hashing must be either explicitly or implicitly enabled for this class. If the hash code is cached, avoid any reassignments of fields involved in hash code computation or mutations of the objects those fields point to after object creation. If such changes occur, the behavior of the object’s hash code is undefined. - auto_exc (bool) –
If the class subclasses
BaseException
(which implicitly includes any subclass of any exception), the following happens to behave like a well-behaved Python exceptions class:- the values for cmp and hash are ignored and the instances compare
and hash by the instance’s ids (N.B.
attrs
will not remove existing implementations of__hash__
or the equality methods. It just won’t add own ones.), - all attributes that are either passed into
__init__
or have a default value are additionally available as a tuple in theargs
attribute, - the value of str is ignored leaving
__str__
to base classes.
- the values for cmp and hash are ignored and the instances compare
and hash by the instance’s ids (N.B.
New in version 16.0.0: slots
New in version 16.1.0: frozen
New in version 16.3.0: str
New in version 16.3.0: Support for
__attrs_post_init__
.Changed in version 17.1.0: hash supports
None
as value which is also the default now.New in version 17.3.0: auto_attribs
Changed in version 18.1.0: If these is passed, no attributes are deleted from the class body.
Changed in version 18.1.0: If these is ordered, the order is retained.
New in version 18.2.0: weakref_slot
Deprecated since version 18.2.0:
__lt__
,__le__
,__gt__
, and__ge__
now raise aDeprecationWarning
if the classes compared are subclasses of each other.__eq
and__ne__
never tried to compared subclasses to each other.New in version 18.2.0: kw_only
New in version 18.2.0: cache_hash
New in version 19.1.0: auto_exc
- these (
mautrix.client.api.types.event.state module¶
-
class
mautrix.client.api.types.event.state.
AliasesStateEventContent
(aliases: List[str] = None)[source]¶ Bases:
mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
-
aliases
= None¶
-
-
class
mautrix.client.api.types.event.state.
CanonicalAliasStateEventContent
(canonical_alias: str = None)[source]¶ Bases:
mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
-
class
mautrix.client.api.types.event.state.
MemberStateEventContent
(membership: <unknown>.Membership = leave, avatar_url: str = None, displayname: str = None, reason: str = None, third_party_invite: NewType.<locals>.new_type = None)[source]¶ Bases:
mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
The content of a membership event.
-
avatar_url
= None¶
-
displayname
= None¶
-
reason
= None¶
-
third_party_invite
= None¶
-
-
class
mautrix.client.api.types.event.state.
PowerLevelStateEventContent
(users: Dict[str, int] = {}, users_default: int = 0, events: Dict[mautrix.client.api.types.event.base.EventType, int] = {}, events_default: int = 0, state_default: int = 50, invite: int = 50, kick: int = 50, ban: int = 50, redact: int = 50)[source]¶ Bases:
mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
The content of a power level event.
-
ensure_event_level
(event_type: mautrix.client.api.types.event.base.EventType, level: int) → bool[source]¶ Return type: bool
-
get_event_level
(event_type: mautrix.client.api.types.event.base.EventType) → int[source]¶ Return type: int
-
-
class
mautrix.client.api.types.event.state.
RoomAvatarStateEventContent
(url: NewType.<locals>.new_type = None)[source]¶ Bases:
mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
-
url
= None¶
-
-
class
mautrix.client.api.types.event.state.
RoomNameStateEventContent
(name: str = None)[source]¶ Bases:
mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
-
name
= None¶
-
-
class
mautrix.client.api.types.event.state.
RoomPinnedEventsStateEventContent
(pinned: List[NewType.<locals>.new_type] = None)[source]¶ Bases:
mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
-
pinned
= None¶
-
-
class
mautrix.client.api.types.event.state.
RoomTombstoneEventContent
(body: str = None, replacement_room: NewType.<locals>.new_type = None)[source]¶ Bases:
mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
-
body
= None¶
-
replacement_room
= None¶
-
-
class
mautrix.client.api.types.event.state.
RoomTopicStateEventContent
(topic: str = None)[source]¶ Bases:
mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
-
topic
= None¶
-
-
class
mautrix.client.api.types.event.state.
StateEvent
(type: mautrix.client.api.types.event.base.EventType, room_id: NewType.<locals>.new_type, event_id: NewType.<locals>.new_type, sender: NewType.<locals>.new_type, timestamp: int, state_key: str, content: Union[mautrix.client.api.types.event.state.PowerLevelStateEventContent, mautrix.client.api.types.event.state.MemberStateEventContent, mautrix.client.api.types.event.state.AliasesStateEventContent, mautrix.client.api.types.event.state.CanonicalAliasStateEventContent, mautrix.client.api.types.event.state.RoomNameStateEventContent, mautrix.client.api.types.event.state.RoomAvatarStateEventContent, mautrix.client.api.types.event.state.RoomTopicStateEventContent, mautrix.client.api.types.event.state.RoomPinnedEventsStateEventContent, mautrix.client.api.types.event.state.RoomTombstoneEventContent, mautrix.client.api.types.util.obj.Obj], unsigned: Optional[mautrix.client.api.types.event.state.StateUnsigned] = None)[source]¶ Bases:
mautrix.client.api.types.event.base.BaseRoomEvent
,mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
A room state event.
-
classmethod
deserialize
(data: NewType.<locals>.new_type) → mautrix.client.api.types.event.state.StateEvent[source]¶ Convert the given data parsed from JSON into an object of this type.
Return type: StateEvent
-
static
deserialize_content
(data: NewType.<locals>.new_type) → Union[mautrix.client.api.types.event.state.PowerLevelStateEventContent, mautrix.client.api.types.event.state.MemberStateEventContent, mautrix.client.api.types.event.state.AliasesStateEventContent, mautrix.client.api.types.event.state.CanonicalAliasStateEventContent, mautrix.client.api.types.event.state.RoomNameStateEventContent, mautrix.client.api.types.event.state.RoomAvatarStateEventContent, mautrix.client.api.types.event.state.RoomTopicStateEventContent, mautrix.client.api.types.event.state.RoomPinnedEventsStateEventContent, mautrix.client.api.types.event.state.RoomTombstoneEventContent, mautrix.client.api.types.util.obj.Obj][source]¶
-
unsigned
= None¶
-
classmethod
-
class
mautrix.client.api.types.event.state.
StateUnsigned
(age: int = None, prev_content: Union[mautrix.client.api.types.event.state.PowerLevelStateEventContent, mautrix.client.api.types.event.state.MemberStateEventContent, mautrix.client.api.types.event.state.AliasesStateEventContent, mautrix.client.api.types.event.state.CanonicalAliasStateEventContent, mautrix.client.api.types.event.state.RoomNameStateEventContent, mautrix.client.api.types.event.state.RoomAvatarStateEventContent, mautrix.client.api.types.event.state.RoomTopicStateEventContent, mautrix.client.api.types.event.state.RoomPinnedEventsStateEventContent, mautrix.client.api.types.event.state.RoomTombstoneEventContent, mautrix.client.api.types.util.obj.Obj] = None, prev_sender: NewType.<locals>.new_type = None, replaces_state: NewType.<locals>.new_type = None, invite_room_state: Optional[List[mautrix.client.api.types.event.state.StrippedStateEvent]] = None)[source]¶ Bases:
mautrix.client.api.types.event.state.StrippedStateUnsigned
,mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
-
invite_room_state
= None¶
-
-
class
mautrix.client.api.types.event.state.
StrippedStateEvent
(content: Union[mautrix.client.api.types.event.state.PowerLevelStateEventContent, mautrix.client.api.types.event.state.MemberStateEventContent, mautrix.client.api.types.event.state.AliasesStateEventContent, mautrix.client.api.types.event.state.CanonicalAliasStateEventContent, mautrix.client.api.types.event.state.RoomNameStateEventContent, mautrix.client.api.types.event.state.RoomAvatarStateEventContent, mautrix.client.api.types.event.state.RoomTopicStateEventContent, mautrix.client.api.types.event.state.RoomPinnedEventsStateEventContent, mautrix.client.api.types.event.state.RoomTombstoneEventContent, mautrix.client.api.types.util.obj.Obj] = None, room_id: NewType.<locals>.new_type = None, type: mautrix.client.api.types.event.base.EventType = None, state_key: str = None, unsigned: Optional[mautrix.client.api.types.event.state.StrippedStateUnsigned] = None)[source]¶ Bases:
mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
Stripped state events included with some invite events.
-
content
= None¶
-
classmethod
deserialize
(data: NewType.<locals>.new_type) → mautrix.client.api.types.event.state.StrippedStateEvent[source]¶ Convert the given data parsed from JSON into an object of this type.
Return type: StrippedStateEvent
-
room_id
= None¶
-
state_key
= None¶
-
type
= None¶
-
unsigned
= None¶
-
-
class
mautrix.client.api.types.event.state.
StrippedStateUnsigned
(age: int = None, prev_content: Union[mautrix.client.api.types.event.state.PowerLevelStateEventContent, mautrix.client.api.types.event.state.MemberStateEventContent, mautrix.client.api.types.event.state.AliasesStateEventContent, mautrix.client.api.types.event.state.CanonicalAliasStateEventContent, mautrix.client.api.types.event.state.RoomNameStateEventContent, mautrix.client.api.types.event.state.RoomAvatarStateEventContent, mautrix.client.api.types.event.state.RoomTopicStateEventContent, mautrix.client.api.types.event.state.RoomPinnedEventsStateEventContent, mautrix.client.api.types.event.state.RoomTombstoneEventContent, mautrix.client.api.types.util.obj.Obj] = None, prev_sender: NewType.<locals>.new_type = None, replaces_state: NewType.<locals>.new_type = None)[source]¶ Bases:
mautrix.client.api.types.event.base.BaseUnsigned
,mautrix.client.api.types.util.serializable_attrs.SerializableAttrs
Unsigned information sent with state events.
-
prev_content
= None¶
-
prev_sender
= None¶
-
replaces_state
= None¶
-
-
mautrix.client.api.types.event.state.
dataclass
(maybe_cls=None, these=None, repr_ns=None, repr=True, cmp=True, hash=None, init=True, slots=False, frozen=False, weakref_slot=True, str=False, *, auto_attribs=True, kw_only=False, cache_hash=False, auto_exc=False)¶ A class decorator that adds dunder-methods according to the specified attributes using
attr.ib()
or the these argument.Parameters: - these (
dict
ofstr
toattr.ib()
) –A dictionary of name to
attr.ib()
mappings. This is useful to avoid the definition of your attributes within the class body because you can’t (e.g. if you want to add__repr__
methods to Django models) or don’t want to.If these is not
None
,attrs
will not search the class body for attributes and will not remove any attributes from it.If these is an ordered dict (
dict
on Python 3.6+,collections.OrderedDict
otherwise), the order is deduced from the order of the attributes inside these. Otherwise the order of the definition of the attributes is used. - repr_ns (str) – When using nested classes, there’s no way in Python 2
to automatically detect that. Therefore it’s possible to set the
namespace explicitly for a more meaningful
repr
output. - repr (bool) – Create a
__repr__
method with a human readable representation ofattrs
attributes.. - str (bool) – Create a
__str__
method that is identical to__repr__
. This is usually not necessary except forException
s. - cmp (bool) – Create
__eq__
,__ne__
,__lt__
,__le__
,__gt__
, and__ge__
methods that compare the class as if it were a tuple of itsattrs
attributes. But the attributes are only compared, if the types of both classes are identical! - hash (
bool
orNone
) –If
None
(default), the__hash__
method is generated according how cmp and frozen are set.- If both are True,
attrs
will generate a__hash__
for you. - If cmp is True and frozen is False,
__hash__
will be set to None, marking it unhashable (which it is). - If cmp is False,
__hash__
will be left untouched meaning the__hash__
method of the base class will be used (if base class isobject
, this means it will fall back to id-based hashing.).
Although not recommended, you can decide for yourself and force
attrs
to create one (e.g. if the class is immutable even though you didn’t freeze it programmatically) by passingTrue
or not. Both of these cases are rather special and should be used carefully.See the Python documentation and the GitHub issue that led to the default behavior for more details.
- If both are True,
- init (bool) – Create a
__init__
method that initializes theattrs
attributes. Leading underscores are stripped for the argument name. If a__attrs_post_init__
method exists on the class, it will be called after the class is fully initialized. - slots (bool) – Create a slots-style class that’s more memory-efficient. See slots for further ramifications.
- frozen (bool) –
Make instances immutable after initialization. If someone attempts to modify a frozen instance,
attr.exceptions.FrozenInstanceError
is raised.Please note:
- This is achieved by installing a custom
__setattr__
method on your class so you can’t implement an own one. - True immutability is impossible in Python.
- This does have a minor a runtime performance impact when initializing new instances. In other words:
__init__
is slightly slower withfrozen=True
. - If a class is frozen, you cannot modify
self
in__attrs_post_init__
or a self-written__init__
. You can circumvent that limitation by usingobject.__setattr__(self, "attribute_name", value)
.
- This is achieved by installing a custom
- weakref_slot (bool) – Make instances weak-referenceable. This has no
effect unless
slots
is also enabled. - auto_attribs (bool) –
If True, collect PEP 526-annotated attributes (Python 3.6 and later only) from the class body.
In this case, you must annotate every field. If
attrs
encounters a field that is set to anattr.ib()
but lacks a type annotation, anattr.exceptions.UnannotatedAttributeError
is raised. Usefield_name: typing.Any = attr.ib(...)
if you don’t want to set a type.If you assign a value to those attributes (e.g.
x: int = 42
), that value becomes the default value like if it were passed usingattr.ib(default=42)
. Passing an instance ofFactory
also works as expected.Attributes annotated as
typing.ClassVar
are ignored. - kw_only (bool) – Make all attributes keyword-only (Python 3+)
in the generated
__init__
(ifinit
isFalse
, this parameter is ignored). - cache_hash (bool) – Ensure that the object’s hash code is computed
only once and stored on the object. If this is set to
True
, hashing must be either explicitly or implicitly enabled for this class. If the hash code is cached, avoid any reassignments of fields involved in hash code computation or mutations of the objects those fields point to after object creation. If such changes occur, the behavior of the object’s hash code is undefined. - auto_exc (bool) –
If the class subclasses
BaseException
(which implicitly includes any subclass of any exception), the following happens to behave like a well-behaved Python exceptions class:- the values for cmp and hash are ignored and the instances compare
and hash by the instance’s ids (N.B.
attrs
will not remove existing implementations of__hash__
or the equality methods. It just won’t add own ones.), - all attributes that are either passed into
__init__
or have a default value are additionally available as a tuple in theargs
attribute, - the value of str is ignored leaving
__str__
to base classes.
- the values for cmp and hash are ignored and the instances compare
and hash by the instance’s ids (N.B.
New in version 16.0.0: slots
New in version 16.1.0: frozen
New in version 16.3.0: str
New in version 16.3.0: Support for
__attrs_post_init__
.Changed in version 17.1.0: hash supports
None
as value which is also the default now.New in version 17.3.0: auto_attribs
Changed in version 18.1.0: If these is passed, no attributes are deleted from the class body.
Changed in version 18.1.0: If these is ordered, the order is retained.
New in version 18.2.0: weakref_slot
Deprecated since version 18.2.0:
__lt__
,__le__
,__gt__
, and__ge__
now raise aDeprecationWarning
if the classes compared are subclasses of each other.__eq
and__ne__
never tried to compared subclasses to each other.New in version 18.2.0: kw_only
New in version 18.2.0: cache_hash
New in version 19.1.0: auto_exc
- these (