Skip to content

Commit

Permalink
update style to satisfy new flake8 plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas committed Aug 30, 2017
1 parent 117132c commit ba56936
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions ros2cli/ros2cli/command/__init__.py
Expand Up @@ -80,9 +80,9 @@ def add_subparsers(
# add subparser with description of available subparsers
description = ''
if command_extensions:
max_length = max([
max_length = max(
len(name) for name in command_extensions.keys()
if hide_extensions is None or name not in hide_extensions])
if hide_extensions is None or name not in hide_extensions)
for name in sorted(command_extensions.keys()):
if hide_extensions is not None and name in hide_extensions:
continue
Expand Down
2 changes: 1 addition & 1 deletion ros2cli/ros2cli/node/daemon.py
Expand Up @@ -56,7 +56,7 @@ def spawn_daemon(args):
os.path.dirname(os.path.dirname(__file__)),
'daemon/__init__.py')]
# Process Creation Flag documented in the MSDN
DETACHED_PROCESS = 0x00000008
DETACHED_PROCESS = 0x00000008 # noqa: N806
kwargs.update(creationflags=DETACHED_PROCESS)
# don't keep handle of current working directory in daemon process
kwargs.update(cwd=os.environ.get('SYSTEMROOT', None))
Expand Down
4 changes: 2 additions & 2 deletions ros2cli/ros2cli/plugin_system.py
Expand Up @@ -93,12 +93,12 @@ def satisfies_version(version, caret_range):

if extension_point_version < extension_version:
raise PluginException(
"Extension point is too old (%s), the extension requires "
'Extension point is too old (%s), the extension requires '
"'%s'" % (extension_point_version, extension_version))

if extension_point_version >= next_extension_version:
raise PluginException(
"Extension point is newer (%s), than what the extension "
'Extension point is newer (%s), than what the extension '
"supports '%s'" % (extension_point_version, extension_version))


Expand Down
2 changes: 1 addition & 1 deletion ros2msg/test/test_cli.py
Expand Up @@ -29,7 +29,7 @@ def test_cli():
package_result = subprocess.run(
package_cmd, stdout=subprocess.PIPE, check=True)
message_types = package_result.stdout.decode().splitlines()
assert all([t.startswith(package_name + '/') for t in message_types])
assert all(t.startswith(package_name + '/') for t in message_types)
count += len(message_types)

if package_name != 'std_msgs':
Expand Down
12 changes: 6 additions & 6 deletions ros2run/ros2run/command/run.py
Expand Up @@ -29,8 +29,8 @@ class RunCommand(CommandExtension):
def add_arguments(self, parser, cli_name):
arg = parser.add_argument(
'--prefix',
help="Prefix command, which should go before the executable. "
"Command must be wrapped in quotes if it contains spaces "
help='Prefix command, which should go before the executable. '
'Command must be wrapped in quotes if it contains spaces '
"(e.g. --prefix 'gdb -ex run --args').")
try:
from argcomplete.completers import SuppressCompleter
Expand All @@ -40,18 +40,18 @@ def add_arguments(self, parser, cli_name):
arg.completer = SuppressCompleter()
arg = parser.add_argument(
'package_name',
help="Name of the ROS package")
help='Name of the ROS package')
arg.completer = package_name_completer
arg = parser.add_argument(
'executable_name',
help="Name of the executable")
help='Name of the executable')
arg.completer = ExecutableNameCompleter(
package_name_key='package_name')
parser.add_argument(
'argv', nargs='*',
help="Pass arbitrary arguments to the executable (use '--' before "
"these arguments to ensure they are not handled by this "
"command)")
'these arguments to ensure they are not handled by this '
'command)')

def main(self, *, parser, args):
try:
Expand Down
2 changes: 1 addition & 1 deletion ros2srv/test/test_cli.py
Expand Up @@ -29,7 +29,7 @@ def test_cli():
package_result = subprocess.run(
package_cmd, stdout=subprocess.PIPE, check=True)
service_types = package_result.stdout.decode().splitlines()
assert all([t.startswith(package_name + '/') for t in service_types])
assert all(t.startswith(package_name + '/') for t in service_types)
count += len(service_types)

if package_name != 'std_srvs':
Expand Down
14 changes: 7 additions & 7 deletions ros2topic/ros2topic/verb/echo.py
Expand Up @@ -56,7 +56,7 @@ def add_arguments(self, parser, cli_name):
'plotting)')
parser.add_argument(
'--full-length', '-f', action='store_true',
help="Output all elements for arrays, bytes, and string with a "
help='Output all elements for arrays, bytes, and string with a '
"length > '--truncate-length', by default they are truncated "
"after '--truncate-length' elements with '...''")
parser.add_argument(
Expand Down Expand Up @@ -149,16 +149,16 @@ def msg_to_csv(args, msg):
def to_string(val):
nonlocal args
r = ''
if any([isinstance(val, t) for t in [list, tuple]]):
if any(isinstance(val, t) for t in [list, tuple]):
for i, v in enumerate(val):
if r:
r += ','
if not args.full_length and i >= args.truncate_length:
r += '...'
break
r += to_string(v)
elif any([isinstance(val, t) for t in [bool, bytes, float, int, str]]):
if any([isinstance(val, t) for t in [bytes, str]]):
elif any(isinstance(val, t) for t in [bool, bytes, float, int, str]):
if any(isinstance(val, t) for t in [bytes, str]):
if not args.full_length and len(val) > args.truncate_length:
val = val[:args.truncate_length]
if isinstance(val, bytes):
Expand Down Expand Up @@ -188,12 +188,12 @@ def msg_to_ordereddict(args, msg):
types = [bool, bytes, dict, float, int, list, str, tuple, OrderedDict]
for field_name in msg.__slots__:
value = getattr(msg, field_name, None)
if not any([isinstance(value, t) for t in types]):
if not any(isinstance(value, t) for t in types):
value = msg_to_ordereddict(args, value)
elif any([isinstance(value, t) for t in [bytes, list, str, tuple]]):
elif any(isinstance(value, t) for t in [bytes, list, str, tuple]):
if not args.full_length and len(value) > args.truncate_length:
value = value[:args.truncate_length]
if any([isinstance(value, t) for t in [list, tuple]]):
if any(isinstance(value, t) for t in [list, tuple]):
value.append('...')
elif isinstance(value, bytes):
value += b'...'
Expand Down

0 comments on commit ba56936

Please sign in to comment.