[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
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

Merged
merged 15 commits into from
Nov 20, 2018

Conversation

mlautman
Copy link
Member
@mlautman mlautman commented Nov 8, 2018

This cleans up some rqt_py_common code and adds the get_field_type function call

@ghost ghost assigned mlautman Nov 8, 2018
@ghost ghost added the in progress label Nov 8, 2018
@mlautman mlautman force-pushed the rqt-py-common-fixup branch from ac3e30a to 15c9078 Compare November 8, 2018 02:07
@brawner brawner mentioned this pull request Nov 9, 2018
Copy link
Contributor
@dirk-thomas dirk-thomas left a 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.

@@ -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>
Copy link
Contributor

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.

@mlautman mlautman mentioned this pull request Nov 10, 2018
@mlautman
Copy link
Member Author

@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.

@mlautman mlautman force-pushed the rqt-py-common-fixup branch from 3be2dc8 to 668bd22 Compare November 10, 2018 03:38
@brawner
Copy link
Contributor
brawner commented Nov 13, 2018

If you want to skip flake8 tests on a file, you can place the following at the top of your file

# flake8: noqa 

Copy link
Contributor
@dirk-thomas dirk-thomas left a 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.

@mlautman mlautman force-pushed the rqt-py-common-fixup branch from 80d9076 to 5e37963 Compare November 13, 2018 22:23
@mlautman
Copy link
Member Author

@dirk-thomas I removed the # noqa's as suppressing specific warnings would take significant time.

@mlautman mlautman force-pushed the rqt-py-common-fixup branch 3 times, most recently from 0cf24aa to a93b7c4 Compare November 13, 2018 23:00
@mlautman
Copy link
Member Author

@mlautman mlautman mentioned this pull request Nov 13, 2018
@type sysmsg: str
"""
self._logger.info('{}'.format(sysmsg))
# self._sysmsg_widget.setPlainText(sysmsg)
self._sysmsg_widget.append(sysmsg)

def shutdown(self):

"""PluginContainerWidget.shutdown."""
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling

rqt_py_common/src/rqt_py_common/topic_helpers.py Outdated Show resolved Hide resolved
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling

Suggested change
# 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
Copy link
Contributor

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.

@mlautman mlautman force-pushed the rqt-py-common-fixup branch 3 times, most recently from 692a99d to d2cd844 Compare November 15, 2018 18:15
@mlautman
Copy link
Member Author

@dirk-thomas @brawner Changes made. Merge?

@mlautman mlautman force-pushed the rqt-py-common-fixup branch from 40ba30a to bf6f31f Compare November 19, 2018 21:10
Copy link
Contributor
@brawner brawner left a 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()
Copy link
Contributor

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.

Copy link
Contributor

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'):
Copy link
Contributor

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.

rqt_py_common/src/rqt_py_common/plugin_container_widget.py Outdated Show resolved Hide resolved
class TopicDict(object):
"""TopicDict class."""
Copy link
Contributor

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

@mlautman mlautman force-pushed the rqt-py-common-fixup branch from 37de6b5 to 33cd6bf Compare November 19, 2018 21:45
@mlautman
Copy link
Member Author

@brawner feedback addressed

rqt_py_common/src/rqt_py_common/topic_helpers.py Outdated Show resolved Hide resolved
# 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()
Copy link
Contributor

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.

rqt_py_common/src/rqt_py_common/topic_helpers.py Outdated Show resolved Hide resolved
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:
Copy link
Contributor

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):].

Copy link
Member Author

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)

Copy link
Contributor
@dirk-thomas dirk-thomas Nov 20, 2018

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.

Copy link
Member Author

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

rqt_py_common/src/rqt_py_common/topic_helpers.py Outdated Show resolved Hide resolved
@mlautman
Copy link
Member Author
mlautman commented Nov 19, 2018

@dirk-thomas comments addressed.

@mlautman mlautman force-pushed the rqt-py-common-fixup branch from bc055c2 to db77038 Compare November 20, 2018 00:08
@mlautman mlautman merged commit fadface into crystal-devel Nov 20, 2018
@ghost ghost removed the in progress label Nov 20, 2018
@mlautman mlautman deleted the rqt-py-common-fixup branch November 20, 2018 02:34
@mlautman
Copy link
Member Author

This was blocking both me and @brawner. After many rounds of reviews, I am merging it with only one approval

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants