Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mesonium
gajim
Commits
4ea4d916
Commit
4ea4d916
authored
2 years ago
by
Daniel Brötzmann
Browse files
Options
Downloads
Patches
Plain Diff
chore: Structs: Add type annotations
parent
c3d11637
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gajim/common/structs.py
+18
-14
18 additions, 14 deletions
gajim/common/structs.py
with
18 additions
and
14 deletions
gajim/common/structs.py
+
18
−
14
View file @
4ea4d916
...
...
@@ -15,7 +15,6 @@
from
__future__
import
annotations
from
typing
import
Any
from
typing
import
Dict
from
typing
import
Type
from
typing
import
TypeVar
from
typing
import
NamedTuple
...
...
@@ -28,11 +27,14 @@
from
gi.repository
import
GLib
from
nbxmpp.protocol
import
JID
from
nbxmpp.const
import
Role
from
nbxmpp.const
import
Affiliation
from
nbxmpp.const
import
Chatstate
from
nbxmpp.const
import
PresenceShow
from
nbxmpp.const
import
Role
from
nbxmpp.protocol
import
JID
from
nbxmpp.structs
import
PresenceProperties
from
gajim.common
import
types
from
gajim.common.const
import
MUCJoinedState
from
gajim.common.const
import
KindConstant
from
gajim.common.const
import
PresenceShowExt
...
...
@@ -46,7 +48,7 @@
class
URI
(
NamedTuple
):
type
:
URIType
action
:
Optional
[
URIAction
]
=
None
data
:
Optional
[
Union
[
D
ict
[
str
,
str
],
str
]]
=
None
data
:
Optional
[
Union
[
d
ict
[
str
,
str
],
str
]]
=
None
class
MUCData
:
...
...
@@ -54,7 +56,8 @@ def __init__(self,
room_jid
:
str
,
nick
:
str
,
password
:
str
,
config
=
None
)
->
None
:
config
:
Optional
[
dict
[
str
,
Any
]]
=
None
)
->
None
:
self
.
_room_jid
=
JID
.
from_string
(
room_jid
)
self
.
_config
=
config
...
...
@@ -74,29 +77,30 @@ def occupant_jid(self) -> JID:
return
self
.
_room_jid
.
new_with
(
resource
=
self
.
nick
)
@property
def
config
(
self
):
def
config
(
self
)
->
Optional
[
dict
[
str
,
Any
]]
:
return
self
.
_config
class
OutgoingMessage
:
def
__init__
(
self
,
account
:
str
,
contact
,
contact
:
types
.
ChatContactT
,
message
:
Optional
[
str
],
type_
:
str
,
subject
:
Optional
[
str
]
=
None
,
chatstate
=
None
,
chatstate
:
Optional
[
Chatstate
]
=
None
,
marker
:
Optional
[
tuple
[
str
,
str
]]
=
None
,
resource
:
Optional
[
str
]
=
None
,
user_nick
:
Optional
[
str
]
=
None
,
label
:
Optional
[
str
]
=
None
,
control
=
None
,
control
:
Optional
[
Any
]
=
None
,
attention
:
Optional
[
bool
]
=
None
,
correct_id
:
Optional
[
str
]
=
None
,
oob_url
:
Optional
[
str
]
=
None
,
xhtml
=
None
,
nodes
=
None
,
play_sound
:
bool
=
True
):
xhtml
:
Optional
[
str
]
=
None
,
nodes
:
Optional
[
Any
]
=
None
,
play_sound
:
bool
=
True
)
->
None
:
if
type_
not
in
(
'
chat
'
,
'
groupchat
'
,
'
normal
'
,
'
headline
'
):
raise
ValueError
(
'
Unknown message type: %s
'
%
type_
)
...
...
@@ -207,7 +211,7 @@ class PresenceData:
available
:
bool
@classmethod
def
from_presence
(
cls
,
properties
)
:
def
from_presence
(
cls
,
properties
:
PresenceProperties
)
->
PresenceData
:
return
cls
(
show
=
properties
.
show
,
status
=
properties
.
status
,
priority
=
properties
.
priority
,
...
...
@@ -233,7 +237,7 @@ class MUCPresenceData:
real_jid
:
Optional
[
JID
]
@classmethod
def
from_presence
(
cls
,
properties
)
:
def
from_presence
(
cls
,
properties
:
PresenceProperties
)
->
MUCPresenceData
:
return
cls
(
show
=
properties
.
show
,
status
=
properties
.
status
,
idle_time
=
properties
.
idle_timestamp
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment