-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add runtime and static type checks #639
Changes from 12 commits
4d6c2aa
52a4ccf
9b73d06
0e73b26
e435c7d
dabbfed
faa5da0
1b25363
bff3926
5a8445b
8dbc81e
b95bfde
6a8dbd2
2169c6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Setting up runtime type checking for this package | ||
from beartype.claw import beartype_this_package | ||
|
||
beartype_this_package() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from typing import TYPE_CHECKING, Optional | ||
from typing import TYPE_CHECKING | ||
|
||
from bitbots_utils.utils import nobeartype | ||
from rclpy.node import Node | ||
|
||
if TYPE_CHECKING: | ||
|
@@ -9,6 +10,7 @@ | |
class AbstractBlackboardCapsule: | ||
"""Abstract class for blackboard capsules.""" | ||
|
||
def __init__(self, node: Node, blackboard: Optional["BodyBlackboard"] = None): | ||
@nobeartype | ||
def __init__(self, node: Node, blackboard: "BodyBlackboard"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is nobeartype needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has something to do with circular imports. The blackboard is imported for static type checking, but importing it for dynamic type checking leads to a circular dependency during runtime. Afaik bear type has no mechanism to handle this. |
||
self._node = node | ||
self._blackboard = blackboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, but VS code always adds it and I dont want to make a special rule.