Skip to content

Commit

Permalink
Updates to run and pass flake8-quotes linter (#972)
Browse files Browse the repository at this point in the history
We use this linter plugin elsewhere in the ROS world, so it would be
nice to pass the tests here too.
  • Loading branch information
cottsay authored Jun 21, 2024
1 parent d56814c commit 78a3d2c
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 18 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'flake8',
'flake8-builtins',
'flake8-comprehensions',
'flake8-quotes',
'pytest',
],
},
Expand Down
6 changes: 3 additions & 3 deletions src/rosdep2/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@


def install_main():
parser = OptionParser(usage="usage: %prog install <rdmanifest-url>", prog=NAME)
parser = OptionParser(usage='usage: %prog install <rdmanifest-url>', prog=NAME)
options, args = parser.parse_args()
if len(args) != 2:
parser.error("please specify one and only one rdmanifest url")
parser.error('please specify one and only one rdmanifest url')
if args[0] != 'install':
parser.error("currently only support the 'install' command")
rdmanifest_url = args[1]
Expand All @@ -53,5 +53,5 @@ def install_main():
else:
source.install_from_url(rdmanifest_url)
except InstallFailed as e:
print("ERROR: installation failed:\n%s" % e, file=sys.stderr)
print('ERROR: installation failed:\n%s' % e, file=sys.stderr)
sys.exit(1)
2 changes: 1 addition & 1 deletion src/rosdep2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def _rosdep_main(args):
'If specified end-of-life distros are being '
'fetched too.')
parser.add_option('-t', '--dependency-types', dest='dependency_types',
type="choice", choices=list(VALID_DEPENDENCY_TYPES),
type='choice', choices=list(VALID_DEPENDENCY_TYPES),
default=[], action='append',
help='Dependency types to install, can be given multiple times. '
'Choose from {}. Default: all except doc.'.format(VALID_DEPENDENCY_TYPES))
Expand Down
2 changes: 1 addition & 1 deletion src/rosdep2/platforms/alpine.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def register_platforms(context):
context.add_os_installer_key(OS_ALPINE, PIP_INSTALLER)
context.add_os_installer_key(OS_ALPINE, SOURCE_INSTALLER)
context.set_default_os_installer_key(OS_ALPINE, lambda self: APK_INSTALLER)
context.set_os_version_type(OS_ALPINE, lambda self: ".".join(self.get_version().split('.')[:2]))
context.set_os_version_type(OS_ALPINE, lambda self: '.'.join(self.get_version().split('.')[:2]))


def apk_detect(pkgs, exec_fn=read_stdout):
Expand Down
8 changes: 4 additions & 4 deletions src/rosdep2/platforms/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def register_mx(context):
print('rosdep detected OS: [%s] aliasing it to: [%s]' %
(OS_MX, OS_DEBIAN), file=sys.stderr)
release_info = read_os_release()
version = read_os_release()["VERSION"]
context.set_os_override(OS_DEBIAN, version[version.find("(") + 1:version.find(")")])
version = read_os_release()['VERSION']
context.set_os_override(OS_DEBIAN, version[version.find('(') + 1:version.find(')')])


def register_pop(context):
Expand Down Expand Up @@ -239,13 +239,13 @@ def dpkg_detect(pkgs, exec_fn=None):
version_lock_map[p.split('=')[0]] = p
else:
version_lock_map[p] = p
cmd = ['dpkg-query', '-W', '-f=\'${Package} ${Status}\n\'']
cmd = ['dpkg-query', '-W', "-f='${Package} ${Status}\n'"]
cmd.extend(version_lock_map.keys())

if exec_fn is None:
exec_fn = read_stdout
std_out, std_err = exec_fn(cmd, True)
std_out = std_out.replace('\'', '')
std_out = std_out.replace("'", '')
pkg_list = std_out.split('\n')
for pkg in pkg_list:
pkg_row = pkg.split()
Expand Down
2 changes: 1 addition & 1 deletion src/rosdep2/platforms/freebsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def register_platforms(context):


def pkg_detect_single(p, exec_fn):
if p == "builtin":
if p == 'builtin':
return True

cmd = ['/usr/sbin/pkg', 'query', '%n', p]
Expand Down
2 changes: 1 addition & 1 deletion src/rosdep2/platforms/openembedded.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def opkg_detect(pkgs, exec_fn=None):
:param exec_fn: function to execute Popen and read stdout (for testing)
:return: list elements in *pkgs* that were found installed on the system
"""
raise NotImplementedError("opkg_detect is not implemented yet")
raise NotImplementedError('opkg_detect is not implemented yet')


class OpkgInstaller(PackageManagerInstaller):
Expand Down
4 changes: 2 additions & 2 deletions src/rosdep2/platforms/redhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def rpm_expand_py(macro):
if '%' not in macro:
return macro
expanded = rpm.expandMacro(macro)
rd_debug('Expanded rpm macro in \'%s\' to \'%s\'' % (macro, expanded))
rd_debug("Expanded rpm macro in '%s' to '%s'" % (macro, expanded))
return expanded


Expand All @@ -153,7 +153,7 @@ def rpm_expand_cmd(macro, exec_fn=None):
exec_fn = read_stdout

expanded = exec_fn(cmd).strip()
rd_debug('Expanded rpm macro in \'%s\' to \'%s\'' % (macro, expanded))
rd_debug("Expanded rpm macro in '%s' to '%s'" % (macro, expanded))
return expanded


Expand Down
2 changes: 1 addition & 1 deletion src/rosdep2/url_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
def urlopen_gzip(url, **kwargs):
# http/https URLs need custom requests to specify the user-agent, since some repositories reject
# requests from the default user-agent.
if url.startswith("http://") or url.startswith("https://"):
if url.startswith('http://') or url.startswith('https://'):
url_request = request.Request(url, headers={
'Accept-Encoding': 'gzip',
'User-Agent': 'rosdep/{version}'.format(version=__version__),
Expand Down
4 changes: 2 additions & 2 deletions test/test_flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def test_flake8():
# Calling through subprocess is the most stable way to run it.

result = subprocess.run(
[sys.executable, "-m", "flake8"],
[sys.executable, '-m', 'flake8'],
cwd=os.path.dirname(os.path.dirname(__file__)),
check=False,
)
assert 0 == result.returncode, "flake8 found violations"
assert 0 == result.returncode, 'flake8 found violations'
4 changes: 2 additions & 2 deletions test/test_rosdep_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ def read_stdout(cmd, capture_stderr=False):
result = ''
elif cmd[0] == 'dpkg-query':
if cmd[-1] == 'python3-dev':
result = '\'python3-dev install ok installed\n\''
result = "'python3-dev install ok installed\n'"
else:
result = '\n'.join(["dpkg-query: no packages found matching %s" % f for f in cmd[3:]])
result = '\n'.join(['dpkg-query: no packages found matching %s' % f for f in cmd[3:]])

if capture_stderr:
return result, ''
Expand Down

0 comments on commit 78a3d2c

Please sign in to comment.