Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xAAL
Code
Python
Commits
40cf3231
Commit
40cf3231
authored
9 months ago
by
KERDREUX Jerome
Browse files
Options
Downloads
Patches
Plain Diff
First try of type hints
Some issues arise .. will need another round soon
parent
f06d49fd
No related branches found
No related tags found
1 merge request
!1
First try of type hints
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
libs/lib/xaal/lib/devices.py
+17
-17
17 additions, 17 deletions
libs/lib/xaal/lib/devices.py
with
17 additions
and
17 deletions
libs/lib/xaal/lib/devices.py
+
17
−
17
View file @
40cf3231
...
...
@@ -28,7 +28,7 @@ from . import config
from
.
import
tools
from
.
import
bindings
from
.exceptions
import
DeviceError
from
.types
import
UUIDT
,
DeviceT
,
EngineT
,
AsyncEngineT
from
.types
import
DeviceT
,
EngineT
,
AsyncEngineT
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -39,7 +39,7 @@ class Attribute(object):
def
__init__
(
self
,
name
,
dev
:
Optional
[
DeviceT
]
=
None
,
default
:
Any
=
None
):
self
.
name
=
name
self
.
default
=
default
self
.
device
=
dev
self
.
device
:
Optional
[
Device
]
=
dev
self
.
__value
=
default
@property
...
...
@@ -104,7 +104,7 @@ class Device(object):
def
__init__
(
self
,
dev_type
:
str
,
addr
:
Optional
[
UUID
T
]
=
None
,
addr
:
Optional
[
bindings
.
UUID
]
=
None
,
engine
:
Union
[
EngineT
,
AsyncEngineT
,
None
]
=
None
,
):
...
...
@@ -156,11 +156,11 @@ class Device(object):
self
.
__version
=
None
@property
def
address
(
self
):
def
address
(
self
)
->
Optional
[
bindings
.
UUID
]
:
return
self
.
__address
@address.setter
def
address
(
self
,
value
:
Optional
[
UUID
T
]):
def
address
(
self
,
value
:
Optional
[
bindings
.
UUID
]):
if
value
is
None
:
self
.
__address
=
None
return
...
...
@@ -169,60 +169,60 @@ class Device(object):
self
.
__address
=
value
@property
def
url
(
self
):
def
url
(
self
)
->
Optional
[
bindings
.
URL
]
:
return
self
.
__url
@url.setter
def
url
(
self
,
value
):
def
url
(
self
,
value
:
Optional
[
str
]
):
if
value
is
None
:
self
.
__url
=
None
else
:
self
.
__url
=
bindings
.
URL
(
value
)
# attributes
def
new_attribute
(
self
,
name
,
default
=
None
):
def
new_attribute
(
self
,
name
:
str
,
default
:
Any
=
None
):
attr
=
Attribute
(
name
,
self
,
default
)
self
.
add_attribute
(
attr
)
return
attr
def
add_attribute
(
self
,
attr
):
def
add_attribute
(
self
,
attr
:
Attribute
):
if
attr
:
self
.
__attributes
.
append
(
attr
)
attr
.
device
=
self
def
del_attribute
(
self
,
attr
):
def
del_attribute
(
self
,
attr
:
Attribute
):
if
attr
:
attr
.
device
=
None
self
.
__attributes
.
remove
(
attr
)
def
get_attribute
(
self
,
name
)
:
def
get_attribute
(
self
,
name
:
str
)
->
Optional
[
Attribute
]
:
for
attr
in
self
.
__attributes
:
if
attr
.
name
==
name
:
return
attr
return
None
@property
def
attributes
(
self
):
def
attributes
(
self
)
->
Attributes
:
return
self
.
__attributes
@attributes.setter
def
attributes
(
self
,
values
):
def
attributes
(
self
,
values
:
Attributes
):
if
isinstance
(
values
,
Attributes
):
self
.
__attributes
=
values
else
:
raise
DeviceError
(
"
Invalid attributes list, use class Attributes)
"
)
def
add_method
(
self
,
name
,
func
):
def
add_method
(
self
,
name
:
str
,
func
:
Any
):
self
.
methods
.
update
({
name
:
func
})
def
get_methods
(
self
):
def
get_methods
(
self
)
->
dict
:
return
self
.
methods
def
update_alive
(
self
):
"""
update the alive timimg
"""
self
.
next_alive
=
time
.
time
()
+
self
.
alive_period
def
get_timeout
(
self
):
def
get_timeout
(
self
)
->
int
:
"""
return Alive timeout used for isAlive msg
"""
return
2
*
self
.
alive_period
...
...
@@ -313,7 +313,7 @@ class Device(object):
result
.
update
({
attr
.
name
:
attr
.
value
})
return
result
def
send_notification
(
self
,
notification
,
body
=
{}):
def
send_notification
(
self
,
notification
:
str
,
body
:
dict
=
{}):
"""
queue an notification, this is just a method helper
"""
if
self
.
engine
:
self
.
engine
.
send_notification
(
self
,
notification
,
body
)
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
sign in
to comment