-
Notifications
You must be signed in to change notification settings - Fork 72
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
addressing Dirk's feedback on the rqt_py_common port #155
Conversation
ac3e30a
to
15c9078
Compare
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.
Please don't use blank noqa
. Either ignore specific warnings in very individual cases or if you don't want make the package follow the style guide disable the linter. Adding blank noqa's all over the place isn't helpful.
rqt_py_common/package.xml
Outdated
@@ -33,8 +33,6 @@ | |||
<test_depend>ament_lint_auto</test_depend> | |||
<test_depend>ament_lint_common</test_depend> | |||
<test_depend>ament_cmake_pytest</test_depend> | |||
<test_depend>ament_flake8</test_depend> | |||
<test_depend>ament_pep257</test_depend> | |||
<test_depend>python3-pytest</test_depend> |
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.
Same comment: python3-pytest
doesn't seem to be used anywhere directly.
@dirk-thomas I am only putting #noqa on existing lines of code. It would take too much time to go through each flake8 warning in the repo and fix or disable the exact warnings. All new lines of code adhere to strict flake8. |
3be2dc8
to
668bd22
Compare
If you want to skip flake8 tests on a file, you can place the following at the top of your file
|
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.
Please don't use blank
noqa
.
I am only putting #noqa on existing lines of code.
Please only suppress specific warnings, e.g. # noqa: D102
.
80d9076
to
5e37963
Compare
@dirk-thomas I removed the |
0cf24aa
to
a93b7c4
Compare
@type sysmsg: str | ||
""" | ||
self._logger.info('{}'.format(sysmsg)) | ||
# self._sysmsg_widget.setPlainText(sysmsg) | ||
self._sysmsg_widget.append(sysmsg) | ||
|
||
def shutdown(self): | ||
|
||
"""PluginContainerWidget.shutdown.""" |
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.
This docblock has no added value beyond the already known class name and method name. Please use # noqa: D102
instead if there is no documentation.
Same for similar cases below.
""" | ||
update_topics. | ||
|
||
Update the topics contained in the dictionary with new information from a node |
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.
This line is valuable but please remove the two line above.
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.
Also add a period
@@ -70,106 +77,173 @@ def get_topic_names_and_types(node=None): | |||
|
|||
|
|||
_message_class_cache = {} | |||
def get_message_class(message_type): | |||
logger = logging.get_logger("get_message_class") | |||
def get_message_class(message_type): # noqa: C901 E302 |
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.
You don't need E302
here. Simply at two empty lines between the cache variable and the function definition.
logger = logging.get_logger("get_message_class") | ||
def get_message_class(message_type): # noqa: C901 E302 | ||
""" | ||
get_message_class: gets the message class from a string representation. |
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.
No need to repeat the function name:
Get the message class from a string representation.
""" | ||
TopicDict(node). | ||
|
||
Create a Topic Dict with an option node passed in |
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.
Add a period and use this line as the summary
""" | ||
get_topics. | ||
|
||
Get the topic dictionary |
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.
Use this as the summary line on a single line docstring.
""" | ||
update_topics. | ||
|
||
Update the topics contained in the dictionary with new information from a node |
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.
Also add a period
return float | ||
|
||
elif type_name in ['string']: | ||
# string constants are always stripped | ||
# TODO(mlautman): char should be a string of lenght one. We do not currently suppor this |
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.
Spelling
unittest.TestCase.setUp(self) | ||
|
||
def tearDown(self): | ||
def tearDown(self): # noqa | ||
unittest.TestCase.tearDown(self) | ||
# del self._model | ||
|
||
# TODO(mlautman): Replace this test with an apropriate ROS2 test. |
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.
Spelling
# TODO(mlautman): Replace this test with an apropriate ROS2 test. | |
# TODO(mlautman): Replace this test with an appropriate ROS2 test. |
unittest.TestCase.tearDown(self) | ||
# del self._model | ||
|
||
# TODO(mlautman): Replace this test with an apropriate ROS2 test. | ||
def test_iterate_packages(self): | ||
""" | ||
""" # noqa |
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.
Just make this a single line docstring and add a period.
692a99d
to
d2cd844
Compare
@dirk-thomas @brawner Changes made. Merge? |
b07d579
to
ccc9fe3
Compare
ccc9fe3
to
40ba30a
Compare
40ba30a
to
bf6f31f
Compare
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.
Looks pretty good to me, just a couple more changes
# Disabling copyright test. The copyright used in this package does not conform to | ||
# ament's copyright tests | ||
set(ament_cmake_copyright_FOUND TRUE) | ||
ament_lint_auto_find_test_dependencies() |
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.
If you remove the auto tests here, you can remove the find_package line above.
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.
As well as the test dependencies in the manifest.
# TODO(mlautman): Work around missing _slot_types in new msg types | ||
if hasattr(slot, '__slots__') and hasattr(slot, '_slot_types'): | ||
for child_slot_name, child_slot_type in zip(slot.__slots__, slot._slot_types): | ||
if hasattr(slot, '__slots__') and hasattr(slot, 'get_fields_and_field_types'): |
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.
If you check for get_fields_and_field_types you can remove the check for '__slots__', since that's not used here.
class TopicDict(object): | ||
"""TopicDict class.""" |
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.
Remove docstring, if you don't want a useful summary
37de6b5
to
33cd6bf
Compare
@brawner feedback addressed |
# Disabling copyright test. The copyright used in this package does not conform to | ||
# ament's copyright tests | ||
set(ament_cmake_copyright_FOUND TRUE) | ||
ament_lint_auto_find_test_dependencies() |
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.
As well as the test dependencies in the manifest.
logger = logging.get_logger('topic_helpers._get_field_type') | ||
for name, types in topic_names_and_types: | ||
# If the topic is a substring of the target param, then we have found a match | ||
if target.find(name) >= 0: |
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.
I don't understand why target.find(name) > 0
would be a match? In the following code you expect target == name
or use it as target[len(name):]
.
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.
I changed this line of logic to target.startswith(name)
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.
The updated condition still seems to match unrelated ones. E.g. target
being /foobar/baz
and name
being /foo
.
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.
Good point. New commit covers that corner case and tests for it as well
@dirk-thomas comments addressed. |
bc055c2
to
db77038
Compare
This was blocking both me and @brawner. After many rounds of reviews, I am merging it with only one approval |
This cleans up some rqt_py_common code and adds the get_field_type function call