Skip to content

Commit 78a3d2c

Browse files
authored
Updates to run and pass flake8-quotes linter (#972)
We use this linter plugin elsewhere in the ROS world, so it would be nice to pass the tests here too.
1 parent d56814c commit 78a3d2c

11 files changed

Lines changed: 19 additions & 18 deletions

File tree

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
'flake8',
2020
'flake8-builtins',
2121
'flake8-comprehensions',
22+
'flake8-quotes',
2223
'pytest',
2324
],
2425
},

src/rosdep2/install.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040

4141

4242
def install_main():
43-
parser = OptionParser(usage="usage: %prog install <rdmanifest-url>", prog=NAME)
43+
parser = OptionParser(usage='usage: %prog install <rdmanifest-url>', prog=NAME)
4444
options, args = parser.parse_args()
4545
if len(args) != 2:
46-
parser.error("please specify one and only one rdmanifest url")
46+
parser.error('please specify one and only one rdmanifest url')
4747
if args[0] != 'install':
4848
parser.error("currently only support the 'install' command")
4949
rdmanifest_url = args[1]
@@ -53,5 +53,5 @@ def install_main():
5353
else:
5454
source.install_from_url(rdmanifest_url)
5555
except InstallFailed as e:
56-
print("ERROR: installation failed:\n%s" % e, file=sys.stderr)
56+
print('ERROR: installation failed:\n%s' % e, file=sys.stderr)
5757
sys.exit(1)

src/rosdep2/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def _rosdep_main(args):
378378
'If specified end-of-life distros are being '
379379
'fetched too.')
380380
parser.add_option('-t', '--dependency-types', dest='dependency_types',
381-
type="choice", choices=list(VALID_DEPENDENCY_TYPES),
381+
type='choice', choices=list(VALID_DEPENDENCY_TYPES),
382382
default=[], action='append',
383383
help='Dependency types to install, can be given multiple times. '
384384
'Choose from {}. Default: all except doc.'.format(VALID_DEPENDENCY_TYPES))

src/rosdep2/platforms/alpine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def register_platforms(context):
4848
context.add_os_installer_key(OS_ALPINE, PIP_INSTALLER)
4949
context.add_os_installer_key(OS_ALPINE, SOURCE_INSTALLER)
5050
context.set_default_os_installer_key(OS_ALPINE, lambda self: APK_INSTALLER)
51-
context.set_os_version_type(OS_ALPINE, lambda self: ".".join(self.get_version().split('.')[:2]))
51+
context.set_os_version_type(OS_ALPINE, lambda self: '.'.join(self.get_version().split('.')[:2]))
5252

5353

5454
def apk_detect(pkgs, exec_fn=read_stdout):

src/rosdep2/platforms/debian.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ def register_mx(context):
108108
print('rosdep detected OS: [%s] aliasing it to: [%s]' %
109109
(OS_MX, OS_DEBIAN), file=sys.stderr)
110110
release_info = read_os_release()
111-
version = read_os_release()["VERSION"]
112-
context.set_os_override(OS_DEBIAN, version[version.find("(") + 1:version.find(")")])
111+
version = read_os_release()['VERSION']
112+
context.set_os_override(OS_DEBIAN, version[version.find('(') + 1:version.find(')')])
113113

114114

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

245245
if exec_fn is None:
246246
exec_fn = read_stdout
247247
std_out, std_err = exec_fn(cmd, True)
248-
std_out = std_out.replace('\'', '')
248+
std_out = std_out.replace("'", '')
249249
pkg_list = std_out.split('\n')
250250
for pkg in pkg_list:
251251
pkg_row = pkg.split()

src/rosdep2/platforms/freebsd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def register_platforms(context):
4949

5050

5151
def pkg_detect_single(p, exec_fn):
52-
if p == "builtin":
52+
if p == 'builtin':
5353
return True
5454

5555
cmd = ['/usr/sbin/pkg', 'query', '%n', p]

src/rosdep2/platforms/openembedded.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def opkg_detect(pkgs, exec_fn=None):
5656
:param exec_fn: function to execute Popen and read stdout (for testing)
5757
:return: list elements in *pkgs* that were found installed on the system
5858
"""
59-
raise NotImplementedError("opkg_detect is not implemented yet")
59+
raise NotImplementedError('opkg_detect is not implemented yet')
6060

6161

6262
class OpkgInstaller(PackageManagerInstaller):

src/rosdep2/platforms/redhat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def rpm_expand_py(macro):
140140
if '%' not in macro:
141141
return macro
142142
expanded = rpm.expandMacro(macro)
143-
rd_debug('Expanded rpm macro in \'%s\' to \'%s\'' % (macro, expanded))
143+
rd_debug("Expanded rpm macro in '%s' to '%s'" % (macro, expanded))
144144
return expanded
145145

146146

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

155155
expanded = exec_fn(cmd).strip()
156-
rd_debug('Expanded rpm macro in \'%s\' to \'%s\'' % (macro, expanded))
156+
rd_debug("Expanded rpm macro in '%s' to '%s'" % (macro, expanded))
157157
return expanded
158158

159159

src/rosdep2/url_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
def urlopen_gzip(url, **kwargs):
4343
# http/https URLs need custom requests to specify the user-agent, since some repositories reject
4444
# requests from the default user-agent.
45-
if url.startswith("http://") or url.startswith("https://"):
45+
if url.startswith('http://') or url.startswith('https://'):
4646
url_request = request.Request(url, headers={
4747
'Accept-Encoding': 'gzip',
4848
'User-Agent': 'rosdep/{version}'.format(version=__version__),

test/test_flake8.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def test_flake8():
2727
# Calling through subprocess is the most stable way to run it.
2828

2929
result = subprocess.run(
30-
[sys.executable, "-m", "flake8"],
30+
[sys.executable, '-m', 'flake8'],
3131
cwd=os.path.dirname(os.path.dirname(__file__)),
3232
check=False,
3333
)
34-
assert 0 == result.returncode, "flake8 found violations"
34+
assert 0 == result.returncode, 'flake8 found violations'

0 commit comments

Comments
 (0)